HelenaLC / CATALYST

Cytometry dATa anALYsis Tools
66 stars 31 forks source link

Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array extent #96

Closed leeanapeters closed 4 years ago

leeanapeters commented 4 years ago

Hi Helena,

I have been able to replicate most of the analysis in the CytofWorkflow, which has been very helpful, but I am receiving an error when attempting to perform the differential analysis portion of the workflow: Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array extent

I get this error with the catalyst wrapper and the individual diffcyt functions.

My flowset is comprised of 22 fcs files (screenshot of environment attached), and experiment info and md parameters seem to match as I was able to get all the way through clustering.

Is this an error in my preparation of the design and contrast matrices prior to running the diffcyt function, or should I be specifying dimnames?

Thanks in advance!!

Leeana

sessionInfo() R version 3.6.0 (2019-04-26) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS High Sierra 10.13.4

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages: [1] pheatmap_1.0.12 tsne_0.1-3 scater_1.14.6
[4] SingleCellExperiment_1.8.0 SummarizedExperiment_1.16.1 DelayedArray_0.12.2
[7] BiocParallel_1.20.1 matrixStats_0.56.0 Biobase_2.46.0
[10] GenomicRanges_1.38.0 GenomeInfoDb_1.22.1 IRanges_2.20.2
[13] S4Vectors_0.24.3 BiocGenerics_0.32.0 Rtsne_0.15
[16] readxl_1.3.1 plyr_1.8.6 openCyto_1.24.0
[19] MetaCyto_1.8.0 lattice_0.20-40 gtools_3.8.2
[22] glue_1.3.2 ggsignif_0.6.0 ggsci_2.9
[25] ggridges_0.5.2 ggrepel_0.8.2 ggpval_0.2.3
[28] ggpubr_0.2.5 magrittr_1.5 ggcyto_1.14.1
[31] flowWorkspace_3.34.1 ncdfFlow_2.32.0 BH_1.72.0-3
[34] RcppArmadillo_0.9.850.1.0 ggbeeswarm_0.6.0 ggplot2_3.3.0
[37] flowUtils_1.50.0 FlowSOM_1.18.0 igraph_1.2.5
[40] flowCore_1.52.1 flowClust_3.24.0 fastcluster_1.1.25
[43] edgeR_3.28.1 limma_3.42.2 dplyr_0.8.5
[46] diffcyt_1.6.4 devtools_2.2.2 usethis_1.5.1
[49] cowplot_1.0.0 ComplexHeatmap_2.2.0 ConsensusClusterPlus_1.50.0 [52] cluster_2.1.0 CATALYST_1.10.3 beeswarm_0.2.3

loaded via a namespace (and not attached): [1] R.methodsS3_1.8.0 tidyr_1.0.2 irlba_2.3.3
[4] multcomp_1.4-12 R.utils_2.9.2 data.table_1.12.8
[7] RCurl_1.98-1.1 callr_3.4.3 TH.data_1.0-10
[10] httpuv_1.5.2 assertthat_0.2.1 viridis_0.5.1
[13] hms_0.5.3 promises_1.1.0 DEoptimR_1.0-8
[16] fansi_0.4.1 Rgraphviz_2.30.0 htmlwidgets_1.5.1
[19] purrr_0.3.3 ellipsis_0.3.0 ks_1.11.7
[22] backports_1.1.5 RcppParallel_5.0.0 vctrs_0.2.4
[25] remotes_2.1.1 abind_1.4-5 withr_2.1.2
[28] robustbase_0.93-6 prettyunits_1.1.1 mclust_5.4.5
[31] mnormt_1.5-6 lazyeval_0.2.2 crayon_1.3.4
[34] drc_3.0-1 ellipse_0.4.1 pkgconfig_2.0.3
[37] nlme_3.1-145 vipor_0.4.5 pkgload_1.0.2
[40] rlang_0.4.5 lifecycle_0.2.0 sandwich_2.5-1
[43] rsvd_1.0.3 cellranger_1.1.0 rprojroot_1.3-2
[46] graph_1.64.0 Matrix_1.2-18 carData_3.0-3
[49] boot_1.3-24 zoo_1.8-7 base64enc_0.1-3
[52] GlobalOptions_0.1.1 processx_3.4.2 png_0.1-7
[55] viridisLite_0.3.0 rjson_0.2.20 bitops_1.0-6
[58] shinydashboard_0.7.1 R.oo_1.23.0 KernSmooth_2.23-16
[61] DelayedMatrixStats_1.8.0 shape_1.4.4 stringr_1.4.0
[64] jpeg_0.1-8.1 scales_1.1.0 memoise_1.1.0
[67] hexbin_1.28.1 zlibbioc_1.32.0 compiler_3.6.0
[70] RColorBrewer_1.1-2 plotrix_3.7-7 clue_0.3-57
[73] lme4_1.1-21 rrcov_1.5-2 cli_2.0.2
[76] XVector_0.26.0 ps_1.3.2 MASS_7.3-51.5
[79] tidyselect_1.0.0 stringi_1.4.6 forcats_0.5.0
[82] shinyBS_0.61 yaml_2.2.1 BiocSingular_1.2.2
[85] locfit_1.5-9.4 latticeExtra_0.6-29 tools_3.6.0
[88] rio_0.5.16 CytoML_1.12.1 circlize_0.4.8
[91] rstudioapi_0.11 foreign_0.8-76 gridExtra_2.3
[94] BiocManager_1.30.10 digest_0.6.25 shiny_1.4.0.2
[97] Rcpp_1.0.4 metafor_2.4-0 car_3.0-7
[100] later_1.0.0 fda_2.4.8.1 httr_1.4.1
[103] IDPmisc_1.1.20 flowStats_3.44.0 colorspace_1.4-1
[106] XML_3.99-0.3 fs_1.4.0 splines_3.6.0
[109] RBGL_1.62.1 plotly_4.9.2.1 sessioninfo_1.1.1
[112] xtable_1.8-4 jsonlite_1.6.1 nloptr_1.2.2.1
[115] corpcor_1.6.9 testthat_2.3.2 R6_2.4.1
[118] RUnit_0.4.32 pillar_1.4.3 htmltools_0.4.0
[121] mime_0.9 nnls_1.4 fastmap_1.0.1
[124] minqa_1.2.4 DT_0.13 BiocNeighbors_1.4.2
[127] codetools_0.2-16 utf8_1.1.4 pkgbuild_1.0.6
[130] pcaPP_1.9-73 mvtnorm_1.1-0 tibble_3.0.0
[133] flowViz_1.50.0 curl_4.3 zip_2.0.4
[136] shinyjs_1.1 openxlsx_4.1.4 survival_3.1-11
[139] desc_1.2.0 munsell_0.5.0 GetoptLong_0.1.8
[142] GenomeInfoDbData_1.2.2 haven_2.2.0 reshape2_1.4.3
[145] gtable_0.3.0
Screen Shot 2020-04-07 at 10 48 51 PM

markrobinsonuzh commented 4 years ago

@leeanapeters it's hard to tell without more details. Can you please give the following:

leeanapeters commented 4 years ago

Thanks for the reply, here is the command that results in the error:

out_DA <- diffcyt( d_input = fs, experiment_info = experiment_info, marker_info = marker_info, design = design, contrast = contrast, analysis_type = "DA", seed_clustering = 123 )

As well as the traceback: 3: colnames<-(*tmp*, value = marker_info[, "marker_name"]) 2: prepareData(d_input, experiment_info, marker_info, cols_to_include, subsampling, n_sub, seed_sub) 1: diffcyt(d_input = fs, experiment_info = experiment_info, marker_info = marker_info, design = design, contrast = contrast, analysis_type = "DA", seed_clustering = 123) I've attached excel files of the design and contrast matrices. I do not have matched comparisons as in the example (n=10 in the T1D group, n=12 in the No T1D), could this be the problem? nrow(contrast) == ncol(design) is TRUE

Please let me know what other info you might need, and thanks for the help!

contrast.xlsx design.xlsx

leeanapeters commented 4 years ago

I have also tried changing the notation of my patient IDs (initially I had a total of 22 as I continuously numbered them between conditions) by numbering to 12 for my reference condition (no T1D) and 10 for my case condition (T1D)

Here is the data frame Screen Shot 2020-04-10 at 1 42 36 PM

markrobinsonuzh commented 4 years ago

@leeanapeters I see at least 2 potential problems and a third comment:

  1. The error seems to be caused by this line:
    colnames(d_combined) <- marker_info[, "marker_name"]

    .. so my guess is you do not have that column in your marker_info object. It's probably worth consulting the example analyses (diffcyt vignette, cytofWorkflow or otherwise) or documentation. For example, ?diffcyt mentions that you need this column:

marker_info: ‘data.frame’, ‘DataFrame’, or ‘tbl_df’ of marker
          information for each column of data. This should contain
          columns named ‘marker_name’ and ‘marker_class’. The columns
          contain: (i) marker names (and any other column names); and
          (ii) a factor indicating the marker class for each column
          (with entries ‘"type"’, ‘"state"’, or ‘"none"’). See
          ‘prepareData’. (Not required when providing a ‘CATALYST’
          ‘daFrame’ for ‘d_input’.)
  1. I'm not sure that is really the design matrix you want to be using. You have 23 data points and are estimating 23 parameters, which means you won't get an error estimate and the downstream analysis will probably fail, even if the problem above is addressed. Because you are using DA-edgeR by default and your experiment isn't paired, you probably don't want to include a patient_id in the design matrix. (something like design <- model.matrix(~group_id) might work. In any case, I don't completely understand your experiment, so you may want to consult with a local statistician to get your design matrix right.

  2. BTW, this seems to be more of a diffcyt or cytofWorkflow question than a CATALYST question, so it's probably better to continue at one of these locations:

https://github.com/lmweber/diffcyt/issues (if diffcyt question) https://github.com/markrobinsonuzh/cytofWorkflow (if cytofWorkflow)