Code Monkey home page Code Monkey logo

Comments (6)

nargesr avatar nargesr commented on July 26, 2024

Hi,

You can set save=False to avoid doing all the visualization and downstream analysis besides the module trait relationship heatmap

this function is mostly wanted to do downstream analysis and an appropriate way to visualise them.
so mainly in this function, I try to combine all the useful analyses in a single function to be able to run all of them in an easier way.

I will add one single function for the module trait relationship heatmap so that one would be doable with a single function as well.

from pywgcna.

wangjiawen2013 avatar wangjiawen2013 commented on July 26, 2024

Hi,
Sometimes we don't want to plot the heatmap and barplots. Now we can set sort=[] and save=False in analyseWGCNA. In this case, all the information are still be stored in pyWGCNA object, although the function will be interrupted by the empty list (sort=[]). Could you support sort = [], so we can run analyseWGCNA() without interruption ? then we can plot by ourselves in our favorite style and tools. Besides, could you return an ax for the figure in pyWGCNA so that we can revise and becautify the figures, now we cannot beautify the figures (such as barploteigengene, I think this also exists in other plotting functions) becuase of the lack of an ax.

from pywgcna.

nargesr avatar nargesr commented on July 26, 2024

Hi

there is no parameter called sort! So I assume you mean order! but you don't need to mess with this parameter in the new version you just need to set save=False so it's not gonna do any visualization!

For complicated plots, I also add return axs if you set save=FALSE but you have to call each function separately!

As I told you before, in this function I combine all the useful downstream analysis in a single function to be able to run all of them in an easier way. But if you want axs, you should run each of them separately.

if you have more questions about this, please reopen this issue :)

from pywgcna.

wangjiawen2013 avatar wangjiawen2013 commented on July 26, 2024

Hi, I mean it's better to support order=[""],here is the error when I set order=[""], then I can plot using our own tools, such as altair, echart, bokeh and so on.
image
I set order=[""] becuase I don't want to run the following code:
print(f"{OKCYAN}Calculating module trait relationship ...{ENDC}")

    self.moduleTraitCor = pd.DataFrame(index=self.MEs.columns,
                                       columns=datTraits.columns,
                                       dtype="float")
    self.moduleTraitPvalue = pd.DataFrame(index=self.MEs.columns,
                                          columns=datTraits.columns,
                                          dtype="float")

    for i in self.MEs.columns:
        for j in datTraits.columns:
            tmp = stats.pearsonr(self.MEs[i], datTraits[j], alternative='greater')
            self.moduleTraitCor.loc[i, j] = tmp[0]
            self.moduleTraitPvalue.loc[i, j] = tmp[1]

    fig, ax = plt.subplots(figsize=(max(20, int(self.moduleTraitPvalue.shape[0] * 1.5)),
                                    self.moduleTraitPvalue.shape[1] * 1.5), facecolor='white')
    # names
    xlabels = []
    for label in self.MEs.columns:
        xlabels.append(label[2:].capitalize() + '(' + str(sum(self.datExpr.var['moduleColors'] == label[2:])) + ')')
    ylabels = datTraits.columns

    # Loop over data dimensions and create text annotations.
    tmp_cor = self.moduleTraitCor.T.round(decimals=2)
    tmp_pvalue = self.moduleTraitPvalue.T.round(decimals=3)
    labels = (np.asarray(["{0}\n({1})".format(cor, pvalue)
                          for cor, pvalue in zip(tmp_cor.values.flatten(),
                                                 tmp_pvalue.values.flatten())])) \
        .reshape(self.moduleTraitCor.T.shape)

    sns.set(font_scale=1.5)
    res = sns.heatmap(self.moduleTraitCor.T, annot=labels, fmt="", cmap='RdBu_r',
                      vmin=-1, vmax=1, ax=ax, annot_kws={'size': 20, "weight": "bold"},
                      xticklabels=xlabels, yticklabels=ylabels)
    res.set_xticklabels(res.get_xmajorticklabels(), fontsize=20, fontweight="bold", rotation=90)
    res.set_yticklabels(res.get_ymajorticklabels(), fontsize=20, fontweight="bold")
    plt.yticks(rotation=0)
    ax.set_title(f"Module-trait Relationships heatmap for {self.name}",
                 fontsize=30, fontweight="bold")
    ax.set_facecolor('white')
    fig.tight_layout()
    if not show:
        plt.close(fig)
    if self.save:
        fig.savefig(f"{self.outputPath}figures/Module_trait_relationships.{self.figureType}")
    print("\tDone..\n")

    print(f"{OKCYAN}Adding (signed) eigengene-based connectivity (module membership) ...{ENDC}")
    self.CalculateSignedKME()
    print("\tDone..\n")

    if geneList is not None:
        print(f"{OKCYAN}Updating gene information based on given gene list ...{ENDC}")
        self.updateGeneInfo(geneInfo=geneList)
        print("\tDone..\n")

............

from pywgcna.

wangjiawen2013 avatar wangjiawen2013 commented on July 26, 2024

Perhaps you can teach me how to run the functions in analyseWGCNA separately. Is it a wrapper of the following functions, I can run them sequentially to replace analyseWGCNA() ?
self.getDatTraits()
self.CalculateSignedKME()
self.plotModuleEigenGene

from pywgcna.

nargesr avatar nargesr commented on July 26, 2024

Hi

In my perspective, order=[""] does not make sense and that's exactly why you get that error :)

I'm not sure why you need self.getDatTraits() if you don't want to calculate module-trait relationship heatmap

To know how you should call each function, please look at the API documentation and search for the function you want to run!

from pywgcna.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.