Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetDatExpr error - not finding group_name despite it existing #126

Closed
jmuribes opened this issue Jun 24, 2023 · 1 comment
Closed

SetDatExpr error - not finding group_name despite it existing #126

jmuribes opened this issue Jun 24, 2023 · 1 comment

Comments

@jmuribes
Copy link

jmuribes commented Jun 24, 2023

Hi! Thank you so much for creating hdWGCNA, such a powerful tool.

I'm currently having an issue where after creating the Metacells, when I try to set up the gene expression matrix focusing on a level of the grouping variable I get an error that the group_name is not found. This issue happens with some group_names but not all, so I'm not sure what could be causing the issue. I double checked that the levels of the grouping variable does in fact exist.

Thank you!

Steps to reproduce

My Seurat object includes the variables "orig.ident" for the samples and "clusters_hdwgcna" for the clusters to be tested. After setting up for the WGCNA, I create the metacells using these two variables (orig.ident and clusters_hgwgcna). This runs without any issues. But when I set up an expression matrix focusing on one of the levels of my cluster_hdwgcna variable, I get an error that it cannot be found. This does not happen to all levels, some run without a problem. I double checked that the level of cluster I'm focusing on does exist in the "cluster_hdwgcna" in the meta.data.

# Set up the Seurat object for hdWGCNA:
> all.data.combined.neurons.filt.hdwgcna <- SetupForWGCNA(
  all.data.combined.neurons.filt.hdwgcna,
  gene_select= "fraction",
  fraction= 0.05,
  wgcna_name = "srgap2"
)

# Get metacells:
> all.data.combined.neurons.filt.hdwgcna <- MetacellsByGroups(
  seurat_obj = all.data.combined.neurons.filt.hdwgcna,
  group.by= c("orig.ident", "clusters_hdwgcna"),
  reduction = 'pca',
  k = 25,
  max_shared=10,
  ident.group = 'clusters_hdwgcna'
)

# Normalize metacells:
> all.data.combined.neurons.filt.hdwgcna <- NormalizeMetacells(all.data.combined.neurons.filt.hdwgcna)

# Set expression matrix for hdWGCNA:
> all.data.combined.neurons.filt.hdwgcna <- SetDatExpr(all.data.combined.neurons.filt.hdwgcna,
                                             group_name= "ONL",
                                             group.by= "clusters_hdwgcna",
                                             assay= "RNA",
                                             slot= "data")

Error in SetDatExpr(all.data.combined.neurons.filt.hdwgcna, group_name = "ONL",  :
  Some groups in group_name are not found in the seurat_obj: ONL

# The level "ONL" does exist in "clusters_hdwgcna"
> levels(all.data.combined.neurons.filt.hdwgcna$clusters_hdwgcna)
 [1] "NB"    "NGlut" "FB"    "MB"    "MHB"   "HB"    "RB"    "GCL"   "INL"  
[10] "ONL"   "RPE"   "NCe"   "NP"    "Ot"    "LL"    "PhA" 

R session info
R version 4.2.2 (2022-10-31)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS

Matrix products: default
BLAS/LAPACK: /share/dennislab/programs/dennis-miniconda/envs/r_scirnaseq/lib/libopenblasp-r0.3.21.so

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

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

other attached packages:
[1] DescTools_0.99.48 enrichR_3.2
[3] ggrepel_0.9.3 UpSetR_1.4.0
[5] slingshot_2.6.0 TrajectoryUtils_1.6.0
[7] princurve_2.1.6 RColorBrewer_1.1-3
[9] tradeSeq_1.12.0 WGCNA_1.72-1
[11] fastcluster_1.2.3 dynamicTreeCut_1.63-1
[13] hdWGCNA_0.2.18 dendextend_1.17.1
[15] anndata_0.7.5.6 sceasy_0.0.7
[17] reticulate_1.28 clustree_0.5.0
[19] ggraph_2.1.0 scater_1.26.1
[21] SC3_1.26.2 MAST_1.24.1
[23] cluster_2.1.4 intrinsicDimension_1.2.0
[25] yaImpute_1.0-33 SingleR_2.0.0
[27] scDblFinder_1.12.0 ggridges_0.5.4
[29] gghalves_0.1.4 ggforce_0.4.1
[31] viridis_0.6.3 viridisLite_0.4.2
[33] scran_1.26.2 scuttle_1.8.4
[35] SingleCellExperiment_1.20.1 SummarizedExperiment_1.28.0
[37] Biobase_2.58.0 GenomicRanges_1.50.2
[39] GenomeInfoDb_1.34.9 IRanges_2.32.0
[41] S4Vectors_0.36.2 BiocGenerics_0.44.0
[43] MatrixGenerics_1.10.0 matrixStats_0.63.0
[45] reshape2_1.4.4 dunn.test_1.3.5
[47] speckle_0.0.3 magrittr_2.0.3
[49] data.table_1.14.8 cowplot_1.1.1
[51] lubridate_1.9.2 forcats_1.0.0
[53] stringr_1.5.0 purrr_1.0.1
[55] readr_2.1.4 tidyr_1.3.0
[57] tibble_3.2.1 tidyverse_2.0.0
[59] patchwork_1.1.2 ggplot2_3.4.2
[61] Matrix_1.5-4 dplyr_1.1.2
[63] SeuratObject_4.1.3 Seurat_4.3.0

loaded via a namespace (and not attached):
[1] rsvd_1.0.5 Hmisc_5.1-0
[3] ica_1.0-3 class_7.3-22
[5] Rsamtools_2.14.0 foreach_1.5.2
[7] lmtest_0.9-40 crayon_1.5.2
[9] MASS_7.3-60 WriteXLS_6.4.0
[11] nlme_3.1-162 backports_1.4.1
[13] qlcMatrix_0.9.7 impute_1.72.3
[15] rlang_1.1.1 readxl_1.4.2
[17] XVector_0.38.0 ROCR_1.0-11
[19] irlba_2.3.5.1 limma_3.54.2
[21] xgboost_1.7.5.1 BiocParallel_1.32.6
[23] rjson_0.2.21 bit64_4.0.5
[25] glue_1.6.2 harmony_0.1.1
[27] pheatmap_1.0.12 rngtools_1.5.2
[29] sctransform_0.3.5 parallel_4.2.2
[31] vipor_0.4.5 spatstat.sparse_3.0-1
[33] AnnotationDbi_1.60.2 spatstat.geom_3.2-1
[35] tidyselect_1.2.0 fitdistrplus_1.1-11
[37] XML_3.99-0.14 zoo_1.8-12
[39] GenomicAlignments_1.34.1 org.Mm.eg.db_3.16.0
[41] xtable_1.8-4 evaluate_0.21
[43] cli_3.6.1 zlibbioc_1.44.0
[45] rstudioapi_0.14 doRNG_1.8.6
[47] miniUI_0.1.1.1 sp_1.6-0
[49] rpart_4.1.19 shiny_1.7.4
[51] BiocSingular_1.14.0 xfun_0.39
[53] tidygraph_1.2.3 KEGGREST_1.38.0
[55] expm_0.999-7 listenv_0.9.0
[57] Biostrings_2.66.0 png_0.1-8
[59] future_1.32.0 withr_2.5.0
[61] slam_0.1-50 bitops_1.0-7
[63] cellranger_1.1.0 plyr_1.8.8
[65] sparsesvd_0.2-2 pcaPP_2.0-3
[67] e1071_1.7-13 dqrng_0.3.0
[69] pillar_1.9.0 cachem_1.0.8
[71] tester_0.1.7 DelayedMatrixStats_1.20.0
[73] vctrs_0.6.2 ellipsis_0.3.2
[75] generics_0.1.3 tools_4.2.2
[77] foreign_0.8-84 beeswarm_0.4.0
[79] munsell_0.5.0 tweenr_2.0.2
[81] proxy_0.4-27 DelayedArray_0.24.0
[83] fastmap_1.1.1 compiler_4.2.2
[85] abind_1.4-5 httpuv_1.6.10
[87] rtracklayer_1.58.0 plotly_4.10.1
[89] GenomeInfoDbData_1.2.9 gridExtra_2.3
[91] edgeR_3.40.2 lattice_0.21-8
[93] deldir_1.0-9 utf8_1.2.3
[95] later_1.3.1 jsonlite_1.8.4
[97] scales_1.2.1 docopt_0.7.1
[99] gld_2.6.6 ScaledMatrix_1.6.0
[101] pbapply_1.7-0 sparseMatrixStats_1.10.0
[103] lazyeval_0.2.2 promises_1.2.0.1
[105] doParallel_1.0.17 goftest_1.2-3
[107] spatstat.utils_3.0-3 checkmate_2.2.0
[109] rmarkdown_2.21 textshaping_0.3.6
[111] statmod_1.5.0 Rtsne_0.16
[113] uwot_0.1.14 igraph_1.4.3
[115] survival_3.5-5 yaml_2.3.7
[117] systemfonts_1.0.4 htmltools_0.5.5
[119] memoise_2.0.1 BiocIO_1.8.0
[121] locfit_1.5-9.7 graphlayouts_1.0.0
[123] digest_0.6.31 rrcov_1.7-2
[125] assertthat_0.2.1 mime_0.12
[127] RSQLite_2.3.1 future.apply_1.11.0
[129] Exact_3.2 blob_1.2.4
[131] preprocessCore_1.60.2 ragg_1.2.4
[133] splines_4.2.2 Formula_1.2-5
[135] labeling_0.4.2 RCurl_1.98-1.12
[137] hms_1.1.3 colorspace_2.1-0
[139] base64enc_0.1-3 ggbeeswarm_0.7.2
[141] ggrastr_1.0.1 nnet_7.3-19
[143] Rcpp_1.0.10 RANN_2.6.1
[145] mvtnorm_1.1-3 fansi_1.0.4
[147] tzdb_0.3.0 parallelly_1.36.0
[149] R6_2.5.1 grid_4.2.2
[151] lifecycle_1.0.3 rootSolve_1.8.2.3
[153] bluster_1.8.0 curl_4.3.3
[155] leiden_0.4.3 robustbase_0.95-1
[157] RcppAnnoy_0.0.20 org.Hs.eg.db_3.16.0
[159] iterators_1.0.14 spatstat.explore_3.2-1
[161] htmlwidgets_1.6.2 beachmat_2.14.2
[163] polyclip_1.10-4 timechange_0.2.0
[165] mgcv_1.8-42 globals_0.16.2
[167] lmom_2.9 htmlTable_2.4.1
[169] spatstat.random_3.1-5 progressr_0.13.0
[171] codetools_0.2-19 FNN_1.1.3.2
[173] GO.db_3.16.0 metapod_1.6.0
[175] gtable_0.3.3 DBI_1.1.3
[177] tensor_1.5 httr_1.4.6
[179] KernSmooth_2.23-21 stringi_1.7.12
[181] farver_2.1.1 boot_1.3-28.1
[183] BiocNeighbors_1.16.0 restfulr_0.0.15
[185] scattermore_1.0 DEoptimR_1.0-13
[187] bit_4.0.5 spatstat.data_3.0-1
[189] pkgconfig_2.0.3 knitr_1.43

@jmuribes
Copy link
Author

jmuribes commented Jun 26, 2023

Hi!

I actually think I found what the issue is. In the metacells Seurat object (created inside seurat_obj@misc$wgcna$wgcna_metacell_obj), I realized my clustering variable (clusters_hdwgcna) was not there. I manually added it as a column in the metadata using the current active identity of the metacells and now is working fine.

# Add a variable 'cluster_hdwgcna' to the metacells Seurat object:
all.data.combined.neurons.filt.hdwgcna@misc$srgap2$wgcna_metacell_obj$cluster_hdwgcna <- all.data.combined.neurons.filt.hdwgcna@misc$srgap2$wgcna_metacell_obj@active.ident

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant