smorabit/hdWGCNA

Error in !CheckWGCNAName(seurat_obj, wgcna_name) : invalid argument type

Closed this issue · 2 comments

Hi!

while using "ModuleEigengenes" function in hdWGCNA analysis on single-cell RNA-seq data, I face the following error:

seurat_obj <- ModuleEigengenes(seurat_obj = seurat_obj, group.by.vars = 'DataSet', wgcna_name = 'GBM_PBMC')
Error in !CheckWGCNAName(seurat_obj, wgcna_name) : invalid argument type

I don't understand what's the reason behind this error. Could you help me solve it?

In the following, I attach the previous steps:

> seurat_obj <- readRDS('end-cell-typing-with res 07.rds')
> p <- DimPlot(seurat_obj, group.by='customclassif', label=TRUE) +
+   umap_theme() + ggtitle('GBM_PBMC') + NoLegend()
> p
> # Set up Seurat object for WGCNA
> common_genes <- read.csv(file = 'commonGenes.csv')
> common_genes <- subset(common_genes, select = commons)
> gene_list <- common_genes$commons
> seurat_obj <- SetWGCNAGenes(seurat_obj, gene_list, "GBM_PBMC")
> seurat_obj <- SetupForWGCNA(
+     seurat_obj,
+     features = gene_list, # the gene selection approach
+     wgcna_name = "GBM_PBMC" # the name of the hdWGCNA experiment
+ )
> # construct metacells  in each group
> seurat_obj <- MetacellsByGroups(
+   seurat_obj = seurat_obj,
+   assay = 'RNA',
+   group.by = c("customclassif" , "DataSet"), # specify the columns in seurat_obj@meta.data to group by
+   reduction = 'umap', # 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 = 'customclassif' # set the Idents of the metacell seurat object
+ )
Warning message:
In MetacellsByGroups(seurat_obj = seurat_obj, assay = "RNA", group.by = c("customclassif",  :
  Removing the following groups that did not meet min_cells: CD8+ NKT-like cells#G, Classical Monocytes#C, Effector CD4+ T cells#D, Effector CD4+ T cells#G, Erythroid-like and erythroid precursor cells#F, HSC/MPP cells#G, Macrophages#A, Memory CD4+ T cells#G, Naive B cells#D, Naive B cells#E, Naive B cells#G, Naive CD4+ T cells#G, Naive CD8+ T cells#A, Naive CD8+ T cells#F, Natural killer  cells#G, Progenitor cells#G, γδ-T cells#A, γδ-T cells#B, γδ-T cells#C, γδ-T cells#E
> # normalize metacell expression matrix:
> seurat_obj <- NormalizeMetacells(seurat_obj)
Performing log-normalization
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
> ## Co-expression network analysis
> # Set up the expression matrix
> seurat_obj <- SetDatExpr(
+   seurat_obj, 
+   group_name = "CD8+ NKT-like cells", # the name of the group of interest in the group.by column
+   group.by='customclassif', # 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
+ )
  ..Excluding 65 genes from the calculation due to too many missing samples or zero variance.
> ## Select soft-power threshold
> # Test different soft powers:
> seurat_obj <- TestSoftPowers(
+     seurat_obj,
+     powers = c(seq(1, 10, by = 1), seq(12, 40, by = 2))
+ )
pickSoftThreshold: will use block size 4170.
 pickSoftThreshold: calculating connectivity for given powers...
   ..working on genes 1 through 4170 of 10727
   ..working on genes 4171 through 8340 of 10727
   ..working on genes 8341 through 10727 of 10727
   Power SFT.R.sq  slope truncated.R.sq  mean.k. median.k. max.k.
1      1 0.250000 11.500          0.870 5440.000  5.46e+03 5880.0
2      2 0.000735 -0.315          0.908 2820.000  2.81e+03 3440.0
3      3 0.198000 -3.610          0.650 1500.000  1.46e+03 2150.0
4      4 0.719000 -4.820          0.836  812.000  7.70e+02 1420.0
5      5 0.950000 -4.740          0.971  450.000  4.15e+02  974.0
6      6 0.969000 -4.120          0.980  255.000  2.26e+02  691.0
7      7 0.976000 -3.530          0.985  148.000  1.25e+02  505.0
8      8 0.976000 -3.080          0.984   88.200  6.99e+01  377.0
9      9 0.985000 -2.700          0.998   54.000  3.95e+01  288.0
10    10 0.982000 -2.420          0.995   34.100  2.26e+01  225.0
11    12 0.978000 -1.950          0.977   14.900  7.62e+00  145.0
12    14 0.986000 -1.690          0.984    7.400  2.69e+00  109.0
13    16 0.989000 -1.540          0.991    4.170  9.80e-01   92.9
14    18 0.987000 -1.430          0.991    2.620  3.72e-01   80.8
15    20 0.989000 -1.350          0.994    1.790  1.44e-01   71.2
16    22 0.981000 -1.290          0.990    1.310  5.80e-02   63.2
17    24 0.977000 -1.240          0.987    1.000  2.36e-02   56.5
18    26 0.980000 -1.200          0.989    0.796  9.80e-03   50.8
19    28 0.977000 -1.190          0.984    0.648  4.17e-03   45.8
20    30 0.965000 -1.180          0.975    0.538  1.79e-03   41.5
21    32 0.968000 -1.170          0.980    0.454  7.86e-04   37.8
22    34 0.957000 -1.170          0.968    0.387  3.48e-04   34.4
23    36 0.958000 -1.150          0.974    0.333  1.58e-04   31.5
24    38 0.960000 -1.140          0.975    0.290  7.15e-05   28.8
25    40 0.961000 -1.130          0.975    0.253  3.30e-05   26.5
> # plot the results:
> plot_list <- PlotSoftPowers(seurat_obj)
  Power     SFT.R.sq      slope truncated.R.sq   mean.k. median.k.    max.k.
1     1 0.2497953889 11.5469642      0.8704824 5440.1972 5456.4324 5878.6463
2     2 0.0007348253 -0.3154286      0.9075126 2823.0972 2805.3934 3435.5756
3     3 0.1976589818 -3.6079486      0.6495899 1497.3079 1458.7513 2153.1684
4     4 0.7188796182 -4.8235474      0.8358224  811.5016  770.2368 1419.6430
5     5 0.9499023482 -4.7444080      0.9710241  449.6127  414.8648  974.2832
6     6 0.9694440677 -4.1236134      0.9802769  254.8813  226.4413  691.3262
> # assemble with patchwork
> wrap_plots(plot_list, ncol=2)
Warning message:
In grid.Call.graphics(C_rect, x$x, x$y, x$width, x$height, resolveHJust(x$just,  :
  semi-transparency is not supported on this device: reported only once per page
> ## Construct co-expression network
Warning messages:
1: In grid.Call.graphics(C_rect, x$x, x$y, x$width, x$height, resolveHJust(x$just,  :
  semi-transparency is not supported on this device: reported only once per page
2: In grid.Call.graphics(C_rect, x$x, x$y, x$width, x$height, resolveHJust(x$just,  :
  semi-transparency is not supported on this device: reported only once per page
> # construct co-expression network:
> seurat_obj <- ConstructNetwork(
+   seurat_obj, soft_power= 5 ,
+   setDatExpr= FALSE,
+   tom_name = 'CD8+ NKT-like cells',# name of the topoligical overlap matrix written to disk
+   networkType = "signed hybrid"
+ )
 Calculating consensus modules and module eigengenes block-wise from all genes
 Calculating topological overlaps block-wise from all genes
   Flagging genes and samples with too many missing values...
    ..step 1
    TOM calculation: adjacency..
    ..will use 8 parallel threads.
     Fraction of slow calculations: 0.000000
    ..connectivity..
    ..matrix multiplication (system BLAS)..
    ..normalization..
    ..done.
 ..Working on block 1 .
 ..Working on block 1 .
 ..merging consensus modules that are too close..
> PlotDendrogram(seurat_obj, main='CD8+ NKT-like cells_hdWGCNA Dendrogram')
> ## Module Eigengenes and Connectivity
> ## Compute harmonized module eigengenes
> # need to run ScaleData first or else harmony throws an error:
> seurat_obj <- ScaleData(seurat_obj, features=VariableFeatures(seurat_obj))
Centering and scaling data matrix
  |=====================================================================| 100%
> # compute all MEs in the full single-cell dataset
> seurat_obj <- ModuleEigengenes(seurat_obj = seurat_obj, group.by.vars = 'DataSet', wgcna_name = 'GBM_PBMC')
Error in !CheckWGCNAName(seurat_obj, wgcna_name) : invalid argument type

sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: Asia/Tehran
tzcode source: system (glibc)

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] hdWGCNA_0.3.00 igraph_2.0.2 ggrepel_0.9.5
[4] harmony_1.2.0 Rcpp_1.0.12 WGCNA_1.72-5
[7] fastcluster_1.2.6 dynamicTreeCut_1.63-1 patchwork_1.2.0
[10] cowplot_1.1.3 lubridate_1.9.3 forcats_1.0.0
[13] stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2
[16] readr_2.1.5 tidyr_1.3.1 tibble_3.2.1
[19] ggplot2_3.4.4 tidyverse_2.0.0 SeuratObject_4.1.4
[22] Seurat_4.4.0

loaded via a namespace (and not attached):
[1] RcppAnnoy_0.0.22 splines_4.3.2 later_1.3.2
[4] bitops_1.0-7 polyclip_1.10-6 preprocessCore_1.62.1
[7] rpart_4.1.21 lifecycle_1.0.4 doParallel_1.0.17
[10] globals_0.16.2 lattice_0.21-9 MASS_7.3-60
[13] backports_1.4.1 magrittr_2.0.3 rmarkdown_2.25
[16] Hmisc_5.1-1 plotly_4.10.4 httpuv_1.6.14
[19] sctransform_0.4.1 spam_2.10-0 sp_2.1-3
[22] spatstat.sparse_3.0-3 reticulate_1.35.0 pbapply_1.7-2
[25] DBI_1.2.2 RColorBrewer_1.1-3 abind_1.4-7
[28] zlibbioc_1.46.0 Rtsne_0.17 BiocGenerics_0.46.0
[31] RCurl_1.98-1.14 nnet_7.3-19 GenomeInfoDbData_1.2.10
[34] IRanges_2.34.1 S4Vectors_0.38.2 irlba_2.3.5.1
[37] listenv_0.9.1 spatstat.utils_3.0-4 goftest_1.2-3
[40] spatstat.random_3.2-2 fitdistrplus_1.1-11 parallelly_1.37.0
[43] leiden_0.4.3.1 codetools_0.2-19 tidyselect_1.2.0
[46] farver_2.1.1 tester_0.2.0 matrixStats_1.2.0
[49] stats4_4.3.2 base64enc_0.1-4 spatstat.explore_3.2-6
[52] jsonlite_1.8.8 ellipsis_0.3.2 progressr_0.14.0
[55] Formula_1.2-6 ggridges_0.5.6 survival_3.5-8
[58] iterators_1.0.14 foreach_1.5.2 tools_4.3.2
[61] ica_1.0-3 glue_1.7.0 gridExtra_2.3
[64] xfun_0.42 GenomeInfoDb_1.36.4 withr_3.0.0
[67] fastmap_1.1.1 fansi_1.0.6 digest_0.6.34
[70] timechange_0.3.0 R6_2.5.1 mime_0.12
[73] colorspace_2.1-1 scattermore_1.2 GO.db_3.17.0
[76] tensor_1.5 spatstat.data_3.0-4 RSQLite_2.3.5
[79] utf8_1.2.4 generics_0.1.3 data.table_1.15.0
[82] FNN_1.1.4 httr_1.4.7 htmlwidgets_1.6.4
[85] uwot_0.1.16 pkgconfig_2.0.3 gtable_0.3.4
[88] blob_1.2.4 impute_1.74.1 lmtest_0.9-40
[91] XVector_0.40.0 htmltools_0.5.7 dotCall64_1.1-1
[94] scales_1.3.0 Biobase_2.60.0 png_0.1-8
[97] knitr_1.45 rstudioapi_0.15.0 tzdb_0.4.0
[100] reshape2_1.4.4 checkmate_2.3.1 nlme_3.1-164
[103] proxy_0.4-27 zoo_1.8-13 cachem_1.0.8
[106] KernSmooth_2.23-22 parallel_4.3.2 miniUI_0.1.1.1
[109] foreign_0.8-86 AnnotationDbi_1.62.2 pillar_1.9.0
[112] grid_4.3.2 vctrs_0.6.5 RANN_2.6.1
[115] promises_1.2.1 xtable_1.8-6 cluster_2.1.4
[118] htmlTable_2.4.2 evaluate_0.23 cli_3.6.2
[121] compiler_4.3.2 rlang_1.1.3 crayon_1.5.2
[124] future.apply_1.11.1 labeling_0.4.3 plyr_1.8.9
[127] stringi_1.8.3 viridisLite_0.4.2 deldir_2.0-2
[130] munsell_0.5.0 Biostrings_2.68.1 lazyeval_0.2.2
[133] spatstat.geom_3.2-8 Matrix_1.6-5 hms_1.1.3
[136] bit64_4.0.5 future_1.33.1 KEGGREST_1.40.1
[139] shiny_1.8.0 ROCR_1.0-11 memoise_2.0.1
[142] bit_4.0.5

Hi,

Thank you for taking the time to write this issue. We have seen this issue before and have since resolved in in the latest version of hdWGCNA. Please install the latest version and run your code again.

Hi,

Thank you for taking the time to write this issue. We have seen this issue before and have since resolved in in the latest version of hdWGCNA. Please install the latest version and run your code again.

Thanks!
It worked.

Best regards!