HelenaLC / CATALYST

Cytometry dATa anALYsis Tools
67 stars 30 forks source link

plotDiffHeatmap CATALYST daFrame does not contain cluster lables #342

Closed lucia1106 closed 1 year ago

lucia1106 commented 1 year ago

Hello, I am having trouble with plotDiffHeatmap as below:

paired76_sceA3 is my original sce made into 60 clusters

paired76_sceA4.1<-mergeClusters(paired76_sceA3, k = "meta60", table = paired76_mergingtableA1.1, id = "mergingA1.1")

rowData(paired76_sceA4.1) DataFrame with 39 rows and 4 columns channel_name marker_name marker_class used_for_clustering

141Pr_Ki67 Pr141Di 141Pr_Ki67 type TRUE 147Sm_CD278 Sm147Di 147Sm_CD278 type TRUE 152Sm_CD66b Sm152Di 152Sm_CD66b type TRUE 153Eu_TIGIT Eu153Di 153Eu_TIGIT type TRUE 154Sm_TIM-3 Sm154Di 154Sm_TIM-3 type TRUE da_res1 <- diffcyt(paired76_sceA4.1, formula = da_formula1, contrast = contrast, analysis_type = c("DA"), method_DA = c("diffcyt-DA-edgeR"), clustering_to_use = "mergingA1.1", verbose = FALSE) rowData(da_res1$res) DataFrame with 13 rows and 3 columns cluster_id p_val p_adj B cells B cells 1.17979e-11 1.41575e-10 CD4- CD8- T cells CD4- CD8- T cells 1.02626e-01 2.05251e-01 CD4 T cells CD4 T cells 5.09402e-02 1.52821e-01 CD4 Tregs CD4 Tregs 5.84220e-03 3.50532e-02 CD4+ CD8+ T cells CD4+ CD8+ T cells NA NA ... ... ... ... plotDiffHeatmap(paired76_sceA4.1, da_res1, all = TRUE, fdr = 0.05, normalize = TRUE, hm_pal = NULL, row_anno = TRUE, col_anno = FALSE)

Error in .check_args_plotDiffHeatmap(args) : is.data.frame(u$y) || is(u$y, "DFrame") is not TRUE

Under the arguments for plotDiffHeatmap, if says:

y

lucia1106 commented 1 year ago

Apologies, continued below:

Under the arguments for plotDiffHeatmap, it says:

y should be either SummarizedExperiment, or list returned from Diffcyt

My 'y' is da_res1 in the above code, and is a list returned from Diffcyt

Under the arguments for Diffcyt, it says:

d_input should be a CATALYST daFrame (containing cluster labels in rowData)

My sce object does not have cluster labels in rowData(paired76_sceA4.1) - how can I add cluster labels? Or how do I resolve the above to make the plotDiffheatmap work?

The other arguments in my diffcyt function were defined as follows: ei <- metadata(paired76_sceA4.1)$experiment_inf da_formula1 <- createFormula(ei, cols_fixed = "timepoint2", cols_random = c("sample_id","pt_id")) contrast <- createContrast(c(0,1, rep(0,37)))

HelenaLC commented 1 year ago

If you have a SCE but diffcyt says “daFrame”, you need to update your libraries. The daFrame has been deprecated for years. In any case, please post a sessionInfo() with all issues.

ARNicols commented 6 months ago

I am having the same issue, my libraries are up to date:

R version 4.3.2 (2023-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

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

time zone: America/Los_Angeles tzcode source: internal

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

other attached packages: [1] diffcyt_1.22.0 ggpubr_0.6.0 openxlsx_4.2.5.2 scater_1.30.1
[5] ggplot2_3.5.0 scuttle_1.12.0 flowCore_2.14.1 cowplot_1.1.3
[9] CATALYST_1.26.0 SingleCellExperiment_1.24.0 SummarizedExperiment_1.32.0 Biobase_2.62.0
[13] GenomicRanges_1.54.1 GenomeInfoDb_1.38.6 IRanges_2.36.0 S4Vectors_0.40.2
[17] BiocGenerics_0.48.1 MatrixGenerics_1.14.0 matrixStats_1.2.0 readxl_1.4.3

loaded via a namespace (and not attached): [1] RColorBrewer_1.1-3 rstudioapi_0.15.0 shape_1.4.6.1 magrittr_2.0.3
[5] ggbeeswarm_0.7.2 TH.data_1.1-2 farver_2.1.1 nloptr_2.0.3
[9] GlobalOptions_0.1.2 zlibbioc_1.48.0 vctrs_0.6.5 minqa_1.2.6
[13] DelayedMatrixStats_1.24.0 RCurl_1.98-1.14 rstatix_0.7.2 S4Arrays_1.2.0
[17] plotrix_3.8-4 BiocNeighbors_1.20.2 broom_1.0.5 cellranger_1.1.0
[21] SparseArray_1.2.4 plyr_1.8.9 sandwich_3.1-0 zoo_1.8-12
[25] igraph_2.0.2 lifecycle_1.0.4 iterators_1.0.14 pkgconfig_2.0.3
[29] rsvd_1.0.5 Matrix_1.6-5 R6_2.5.1 GenomeInfoDbData_1.2.11
[33] clue_0.3-65 digest_0.6.34 colorspace_2.1-0 ggnewscale_0.4.10
[37] irlba_2.3.5.1 beachmat_2.18.1 cytolib_2.14.1 fansi_1.0.6
[41] colorRamps_2.3.1 nnls_1.5 polyclip_1.10-6 abind_1.4-5
[45] compiler_4.3.2 withr_3.0.0 doParallel_1.0.17 ConsensusClusterPlus_1.66.0 [49] backports_1.4.1 BiocParallel_1.36.0 viridis_0.6.5 carData_3.0-5
[53] ggforce_0.4.2 ggsignif_0.6.4 MASS_7.3-60.0.1 drc_3.0-1
[57] DelayedArray_0.28.0 rjson_0.2.21 FlowSOM_2.10.0 gtools_3.9.5
[61] tools_4.3.2 vipor_0.4.7 beeswarm_0.4.0 zip_2.3.1
[65] glue_1.7.0 nlme_3.1-164 grid_4.3.2 Rtsne_0.17
[69] cluster_2.1.6 reshape2_1.4.4 generics_0.1.3 gtable_0.3.4
[73] tidyr_1.3.1 data.table_1.15.0 ScaledMatrix_1.10.0 BiocSingular_1.18.0
[77] car_3.1-2 utf8_1.2.4 XVector_0.42.0 ggrepel_0.9.5
[81] foreach_1.5.2 pillar_1.9.0 stringr_1.5.1 limma_3.58.1
[85] circlize_0.4.16 splines_4.3.2 dplyr_1.1.4 tweenr_2.0.3
[89] lattice_0.22-5 survival_3.5-8 RProtoBufLib_2.14.0 tidyselect_1.2.0
[93] ComplexHeatmap_2.18.0 locfit_1.5-9.8 gridExtra_2.3 edgeR_4.0.16
[97] statmod_1.5.0 stringi_1.8.3 boot_1.3-30 codetools_0.2-19
[101] tibble_3.2.1 cli_3.6.2 munsell_0.5.0 Rcpp_1.0.12
[105] png_0.1-8 XML_3.99-0.16.1 parallel_4.3.2 sparseMatrixStats_1.14.0
[109] bitops_1.0-7 lme4_1.1-35.1 viridisLite_0.4.2 mvtnorm_1.2-4
[113] scales_1.3.0 ggridges_0.5.6 purrr_1.0.2 crayon_1.5.2
[117] GetoptLong_1.0.5 rlang_1.1.3 multcomp_1.4-25

SamGG commented 6 months ago

Hi,

If I carefully read the vignette of the differential expression testing, the 2nd argument is a table, not the diffcyt object itself.

# extract result tables
tbl_DA <- rowData(res_DA$res)
plotDiffHeatmap(sce, tbl_DA, all = TRUE, fdr = 0.05)

@HelenaLC could you confirm and update your previous answer?

HelenaLC commented 6 months ago

Confirming! The (very) old daFrame-based framework had the whole object as input. It should only be the rowData now. Thanks @SamGG!