smorabit / hdWGCNA

High dimensional weighted gene co-expression network analysis
https://smorabit.github.io/hdWGCNA/
Other
316 stars 31 forks source link

Module and trait #89

Closed maqingyue closed 1 year ago

maqingyue commented 1 year ago

Hi, I have learned this tutorial (https://smorabit.github.io/hdWGCNA/articles/module_trait_correlation.html), but it is not completely consistent with my needs. I want the relationship between modules and features, as you said in the tutorial: Categorical variables with only 2 categories, such as "control" and "condition" (as shown in Figure 1), but the relationship between modules and cell types is finally shown in the tutorial (as shown in Figure 2). I got Figure 3 according to the tutorial. In fact, the parameter on the right is useless to me, and this parameter cannot be empty. I have tried a lot and failed to get the desired results. I hope you can give me some suggestions. Thank you! Fig1. fig1

Fig2. fig2

Fig3. fig3

smorabit commented 1 year ago

Hi,

Can you please include the code that you ran? Could you also clarify what is the trait that you are interested in?

maqingyue commented 1 year ago

Hi, My sample is three young samples and three old samples. I used the six integrated samples to do the HDEGCNA analysis, and now I have four modules. I want to know how the gene correlation of the module characteristics changes compared with the young.

This is my code about module trait correlation. cur_traits is a parameter that cannot be empty.

sample$orig.ident <- as.factor(sample$orig.ident) cur_traits <- c("percent.mt","nFeature_Spatial","nCount_Spatial") sample <- ModuleTraitCorrelation( sample, traits = cur_traits, group.by = 'orig.ident' )

mt_cor <- GetModuleTraitCorrelation(sample) names(mt_cor) names(mt_cor$cor)

pdf("D:/BGI_learning/select-samples/results/brain/six samples/hippocampus/WGCNA/module-sample.pdf") PlotModuleTraitCorrelation( sample, label = 'fdr', label_symbol = 'numeric', text_size = 2, text_digits = 2, text_color = 'blue', high_color = 'yellow', mid_color = 'black', low_color = 'purple', plot_max = 0.2, combine=TRUE ) dev.off()

smorabit commented 1 year ago

It looks like you never included the young/old as a trait, you are only using cur_traits <- c("percent.mt","nFeature_Spatial","nCount_Spatial") to run ModuleTraitCorrelation, that's why you don't have any information about the relationship between module and age.

maqingyue commented 1 year ago

Can I calculate the correlation between modules and samples? This module is divided by the integrated data of six samples.

smorabit commented 1 year ago

No it is not recommended to correlate module with sample ID. From the tutorial page:

Variables that can not be used:

Categorical variables with more than two categories that are not sequentially linked. For example, suppose you have a dataset consiting of three strains of transgenic mice and one control. Categorical variables must be converted to numeric before running the correlation, so you will end up with a correlation that is not at all biologically meaningful since there’s not a way to order the three different strains in a way that makes sense as a numeric variable. In this case, you should just set up a pairwise correlation between control and each strain separately. We often have a “Sample ID” variable indicating which cell came from which sample, and this is a variable that does not necessarily make sense to order in any particular way, so a variable like this would not be suitable for module-trait correlation analysis.

maqingyue commented 1 year ago

My six samples are three young and three old, which is equivalent to three biological duplicates in each category. Can't we count two categories? Then can I choose a young sample and an old sample for correlation analysis?

smorabit commented 1 year ago

Why don't you just include age as the trait?

maqingyue commented 1 year ago

I want to take age as a trait. It is divided into young and old, and then explores the correlation with the module to find out what changes have taken place in the aging process. But I don't know how to program. Can you give some suggestions.

smorabit commented 1 year ago

Sounds like you want to correlate the module with age, so you need to include age in your list of traits in the ModuleTraitCorrelation function. In the example tutorial, we actually did use age as one of the example traits, so it may help you to look at what was done in the tutorial.