hdWGCNA icon indicating copy to clipboard operation
hdWGCNA copied to clipboard

Error in ConstructPseudobulk (argument is not a matrix) when I don't specify label_col

Open ddressman91 opened this issue 3 months ago • 1 comments

Hello,

Thanks for your effort and maintenance of the package! I am using your pipeline for hdWGCNA with pseudobulk data and am running into a problem with the ConstructPseudobulk function. When I try to run it without specifying label_col, I get the following error message:

Error in t.default(datExpr[genes_use, ]) : argument is not a matrix

This is with setting the L2 cell type labels from Azimuth as the group.by argument, and the PatientID column as the replicate_col argument (see my code below). If I additionally set label_col as the metadata column for diagnosis, the function works as expected. Looking at the datExpr output, I could probably construct this table with Seurat's AggregateExpression function, but it would be nice to use ConstructPseudobulk without having to specify label_col if possible.

Code I used up to this point:

seurat <- SetupForWGCNA(seurat, gene_select = "fraction", 
                        fraction = 0.05, wgcna_name = "pseudobulk")
length(GetWGCNAGenes(seurat))

[email protected]$PatientID <- as.character([email protected]$PatientID)
[email protected]$predicted.celltype.l2 <- str_replace([email protected]$predicted.celltype.l2,
                                                      " ", "_")
datExpr <- ConstructPseudobulk(seurat, group.by = 'predicted.celltype.l2',
                               replicate_col = 'PatientID', assay = 'RNA',
                               layer = 'counts', min_reps = 20, label_col = 'condition')

sessionInfo()

` R version 4.4.0 (2024-04-24 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 [2] LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 [4] LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8

time zone: America/New_York tzcode source: internal

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

other attached packages: [1] patchwork_1.3.0 cowplot_1.1.3 lubridate_1.9.3
[4] forcats_1.0.0 purrr_1.0.2 readr_2.1.5
[7] tidyr_1.3.1 tibble_3.2.1 tidyverse_2.0.0
[10] hdWGCNA_0.4.00 GenomicRanges_1.56.2 GenomeInfoDb_1.40.1
[13] IRanges_2.38.1 S4Vectors_0.42.1 BiocGenerics_0.50.0
[16] GeneOverlap_1.40.0 UCell_2.8.0 tidygraph_1.3.1
[19] ggraph_2.2.1 igraph_2.0.3 dplyr_1.1.4
[22] WGCNA_1.73 fastcluster_1.2.6 dynamicTreeCut_1.63-1 [25] ggrepel_0.9.6 Seurat_5.1.0 SeuratObject_5.0.2
[28] sp_2.1-4 harmony_1.2.1 Rcpp_1.0.12
[31] ggplot2_3.5.1 stringr_1.5.1

loaded via a namespace (and not attached): [1] RcppAnnoy_0.0.22 splines_4.4.0
[3] later_1.3.2 bitops_1.0-9
[5] polyclip_1.10-7 preprocessCore_1.66.0
[7] rpart_4.1.23 fastDummies_1.7.4
[9] lifecycle_1.0.4 doParallel_1.0.17
[11] globals_0.16.3 lattice_0.22-6
[13] MASS_7.3-60.2 backports_1.5.0
[15] magrittr_2.0.3 Hmisc_5.1-3
[17] plotly_4.10.4 rmarkdown_2.28
[19] httpuv_1.6.15 sctransform_0.4.1
[21] spam_2.11-0 spatstat.sparse_3.1-0
[23] reticulate_1.39.0 pbapply_1.7-2
[25] DBI_1.2.3 RColorBrewer_1.1-3
[27] abind_1.4-8 zlibbioc_1.50.0
[29] Rtsne_0.17 nnet_7.3-19
[31] tweenr_2.0.3 GenomeInfoDbData_1.2.12
[33] irlba_2.3.5.1 listenv_0.9.1
[35] spatstat.utils_3.1-0 goftest_1.2-3
[37] RSpectra_0.16-2 spatstat.random_3.3-2
[39] fitdistrplus_1.2-1 parallelly_1.38.0
[41] DelayedArray_0.30.1 leiden_0.4.3.1
[43] codetools_0.2-20 ggforce_0.4.2
[45] tidyselect_1.2.1 UCSC.utils_1.0.0
[47] farver_2.1.2 tester_0.2.0
[49] viridis_0.6.5 matrixStats_1.4.1
[51] base64enc_0.1-3 spatstat.explore_3.3-2
[53] jsonlite_1.8.9 BiocNeighbors_1.22.0
[55] progressr_0.15.0 Formula_1.2-5
[57] ggridges_0.5.6 survival_3.5-8
[59] iterators_1.0.14 foreach_1.5.2
[61] tools_4.4.0 ica_1.0-3
[63] glue_1.7.0 SparseArray_1.4.8
[65] gridExtra_2.3 xfun_0.48
[67] MatrixGenerics_1.16.0 withr_3.0.2
[69] fastmap_1.1.1 fansi_1.0.6
[71] caTools_1.18.3 digest_0.6.35
[73] timechange_0.3.0 R6_2.5.1
[75] mime_0.12 colorspace_2.1-1
[77] scattermore_1.2 GO.db_3.19.1
[79] gtools_3.9.5 tensor_1.5
[81] spatstat.data_3.1-2 RSQLite_2.3.7
[83] utf8_1.2.4 generics_0.1.3
[85] data.table_1.16.2 S4Arrays_1.4.1
[87] graphlayouts_1.2.0 httr_1.4.7
[89] htmlwidgets_1.6.4 uwot_0.2.2
[91] pkgconfig_2.0.3 gtable_0.3.6
[93] blob_1.2.4 lmtest_0.9-40
[95] impute_1.78.0 SingleCellExperiment_1.26.0 [97] XVector_0.44.0 htmltools_0.5.8.1
[99] dotCall64_1.2 scales_1.3.0
[101] Biobase_2.64.0 png_0.1-8
[103] spatstat.univar_3.0-1 knitr_1.48
[105] rstudioapi_0.17.1 tzdb_0.4.0
[107] reshape2_1.4.4 checkmate_2.3.2
[109] nlme_3.1-164 proxy_0.4-27
[111] cachem_1.0.8 zoo_1.8-12
[113] KernSmooth_2.23-22 parallel_4.4.0
[115] miniUI_0.1.1.1 foreign_0.8-86
[117] AnnotationDbi_1.66.0 pillar_1.9.0
[119] grid_4.4.0 vctrs_0.6.5
[121] gplots_3.2.0 RANN_2.6.2
[123] promises_1.3.0 xtable_1.8-4
[125] cluster_2.1.6 htmlTable_2.4.3
[127] evaluate_1.0.1 cli_3.6.2
[129] compiler_4.4.0 rlang_1.1.3
[131] crayon_1.5.3 future.apply_1.11.3
[133] labeling_0.4.3 plyr_1.8.9
[135] stringi_1.8.4 BiocParallel_1.38.0
[137] viridisLite_0.4.2 deldir_2.0-4
[139] munsell_0.5.1 Biostrings_2.72.1
[141] lazyeval_0.2.2 spatstat.geom_3.3-3
[143] Matrix_1.7-0 RcppHNSW_0.6.0
[145] hms_1.1.3 bit64_4.5.2
[147] future_1.34.0 KEGGREST_1.44.1
[149] shiny_1.9.1 SummarizedExperiment_1.34.0 [151] ROCR_1.0-11 memoise_2.0.1
[153] bit_4.5.0 `

ddressman91 avatar Oct 30 '24 15:10 ddressman91