smorabit / hdWGCNA

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

Error in TestSoftPowers() #105

Closed Prakrithi-P closed 1 year ago

Prakrithi-P commented 1 year ago

Hi Sam, I am trying to reproduce the tutorial and am using the provided dataset. While trying to run TestSoftPowers(), I come across the following error. Could you please help me figure out what's wrong?

Error in datk[c(startG:endG), ] = foreach(t = actualThreads, .combine = rbind) %dopar% : number of items to replace is not a multiple of replacement length In addition: Warning message: In mclapply(argsList, FUN, mc.preschedule = preschedule, mc.set.seed = set.seed, : scheduled cores 1, 2, 3, 4, 5, 6, 7, 8 did not deliver results, all values of the jobs will be affected

Thanks, Prakrithi

smorabit commented 1 year ago

Hi,

Can you please send the code that you ran?

Prakrithi-P commented 1 year ago

Hi, This was the code I ran, the exact same thing on the tutorial:

single-cell analysis package

library(Seurat)

plotting and data science packages

library(tidyverse) library(cowplot) library(patchwork)

co-expression network analysis packages:

library(WGCNA)

devtools::install_github('smorabit/hdWGCNA', ref='dev')

library(hdWGCNA)

using the cowplot theme for ggplot

theme_set(theme_cowplot())

set random seed for reproducibility

set.seed(12345)

optionally enable multithreading

enableWGCNAThreads(nThreads = 8)

load the Zhou et al snRNA-seq dataset

seurat_obj <- readRDS('~/Downloads/Zhou_2020.rds')

p <- DimPlot(seurat_obj, group.by='cell_type', label=TRUE) + umap_theme() + ggtitle('Zhou et al Control Cortex') + NoLegend()

p

Set up seurat object for WGCNA

seurat_obj <- SetupForWGCNA( seurat_obj, gene_select = "fraction", # the gene selection approach fraction = 0.05, # fraction of cells that a gene needs to be expressed in order to be included wgcna_name = "tutorial" # the name of the hdWGCNA experiment )

construct metacells in each group

seurat_obj <- MetacellsByGroups( seurat_obj = seurat_obj, group.by = c("cell_type", "Sample"), # specify the columns in @.*** to group by reduction = 'harmony', # select the dimensionality reduction to perform KNN on k = 25, # nearest-neighbors parameter max_shared = 10, # maximum number of shared cells between two metacells ident.group = 'cell_type' # set the Idents of the metacell seurat object ) ##takes ~15 mins

normalize metacell expression matrix:

seurat_obj <- NormalizeMetacells(seurat_obj)

Co-expression network analysis

set-up

seurat_obj <- SetDatExpr( seurat_obj, group_name = "INH", # the name of the group of interest in the group.by column group.by='cell_type', # the metadata column containing the cell type info. This same column should have also been used in MetacellsByGroups assay = 'RNA', # using RNA assay slot = 'data' # using normalized data )

select soft-power threshold

Test different soft powers:

seurat_obj <- TestSoftPowers( seurat_obj, networkType = 'signed' # you can also use "unsigned" or "signed hybrid" )

On Wed, Mar 29, 2023 at 12:00 PM Sam Morabito @.***> wrote:

Hi,

Can you please send the code that you ran?

— Reply to this email directly, view it on GitHub https://github.com/smorabit/hdWGCNA/issues/105#issuecomment-1487839881, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ5NXC54LEXHGUSEA5L5GWDW6OJSXANCNFSM6AAAAAAWLJ3FAY . You are receiving this because you authored the thread.Message ID: @.***>

-- Regards, Prakrithi. P PhD Fellow, University of Queensland-IIT Delhi Academy of Research.

smorabit commented 1 year ago

Based on the error message it looks like there is some issue pertaining to running parallel threads. Maybe try running the code again but this time skip this line: enableWGCNAThreads(nThreads = 8)

Prakrithi-P commented 1 year ago

Thank you so much. It worked fine now. I had also posted another query. Some suggestions would be great:

I am trying to run hdWGCNA to analyze the co-expression of some interesting novel ncRNAs with coding genes. I am not sure how to go about it, like, the ncRNAs are expressed in very few cells and show low expression. Is it okay to concatenate their counts with gene counts and carry out the analysis? Will doing so skew the results in any way? And is there a way to check which gene modules the chosen ncRNAs belong to ?

On Wed, Mar 29, 2023 at 12:16 PM Sam Morabito @.***> wrote:

Based on the error message it looks like there is some issue pertaining to running parallel threads. Maybe try running the code again but this time skip this line: enableWGCNAThreads(nThreads = 8)

— Reply to this email directly, view it on GitHub https://github.com/smorabit/hdWGCNA/issues/105#issuecomment-1487851902, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ5NXC7TRUKTJ3IDU6MWKB3W6OLQPANCNFSM6AAAAAAWLJ3FAY . You are receiving this because you authored the thread.Message ID: @.***>

-- Regards, Prakrithi. P PhD Fellow, University of Queensland-IIT Delhi Academy of Research.

smorabit commented 1 year ago

Glad it worked out for you. Also I will respond to your question about the ncRNAs in issue #104.