immunogenomics / harmony

Fast, sensitive and accurate integration of single-cell data with Harmony
https://portals.broadinstitute.org/harmony/
Other
526 stars 100 forks source link

Error in RunHarmony: argument 3 matches multiple formal arguments #227

Closed katimbach closed 10 months ago

katimbach commented 10 months ago

Hi all,

Thank you for this amazing package! I have been using it for several years now and it works very well. However, I recently transitioned to a new HPC environment and for some reason I am having problems in running harmony on my dataset. Briefly, I have a dataset of ~1M cells that are both my samples and samples from a public reference that I have combined. I run SCT individually on each sample before merging and running PCA etc (where "orig.ident" is the metadata column corresponding to patient IDs, with 46 patients total):

GEX.list<- c(objs, Vazquez)
rm(objs, Vazquez)
gc()

var.features <- SelectIntegrationFeatures(object.list = GEX.list, nfeatures = 3000)

merged<- Reduce(merge,GEX.list)

VariableFeatures(merged)<- var.features

merged<- RunPCA(merged, verbose =F)
merged<- RunUMAP(merged, reduction= "pca", dims=1:30)

merged<- FindNeighbors(merged, dims= 1:30)
merged<- FindClusters(merged, verbose= F, cluster.name= "merge_clusters")

save(merged, file= "./Robjs/RNA/Ours_PrimaryOVVazquez_GEX_SCTv2_merged.Robj")

# load("./Robjs/RNA/Ours_PrimaryOVVazquez_GEX_SCTv2_merged.Robj")

library(harmony)
GEX.prim.int.hm <- RunHarmony(
  object = merged,
  group.by.vars = 'orig.ident',
  reduction = 'pca',
  assay.use = 'SCT',
  project.dim = FALSE
)

However, each time it results in the following error.

Error in RunHarmony.Seurat(object = merged, group.by.vars = "orig.ident",  : 
  argument 3 matches multiple formal arguments
Calls: RunHarmony
Execution halted

I confirmed that the PCA is present in the reductions, and that it corresponds to the SCT assay:

>merged@reductions
$pca
A dimensional reduction object with key PC_ 
 Number of dimensions: 50 
 Number of cells: 1009674 
 Projected dimensional reduction calculated:  FALSE 
 Jackstraw run: FALSE 
 Computed using assay: SCT 

Any help in how to solve this would be greatly appreciated! I've been stuck on it for a while now with no avail. Below is the session info:

R version 4.3.2 (2023-10-31)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /mnt/beegfs/kimbach/.conda/envs/singlecell/lib/libopenblasp-r0.3.25.so;  LAPACK version 3.11.0

locale:
[1] C

time zone: Europe/Madrid
tzcode source: system (glibc)

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

other attached packages:
[1] harmony_1.1.0      Rcpp_1.0.11        Seurat_5.0.0       SeuratObject_5.0.1
[5] sp_2.1-1          

loaded via a namespace (and not attached):
  [1] deldir_2.0-2           pbapply_1.7-2          gridExtra_2.3         
  [4] rlang_1.1.2            magrittr_2.0.3         RcppAnnoy_0.0.21      
  [7] matrixStats_1.1.0      ggridges_0.5.4         compiler_4.3.2        
 [10] spatstat.geom_3.2-7    png_0.1-8              vctrs_0.6.4           
 [13] reshape2_1.4.4         stringr_1.5.1          pkgconfig_2.0.3       
 [16] fastmap_1.1.1          ellipsis_0.3.2         utf8_1.2.4            
 [19] promises_1.2.1         purrr_1.0.2            jsonlite_1.8.7        
 [22] goftest_1.2-3          later_1.3.1            spatstat.utils_3.0-4  
 [25] irlba_2.3.5.1          parallel_4.3.2         cluster_2.1.4         
 [28] R6_2.5.1               ica_1.0-3              stringi_1.8.2         
 [31] RColorBrewer_1.1-3     spatstat.data_3.0-3    reticulate_1.34.0     
 [34] parallelly_1.36.0      lmtest_0.9-40          scattermore_1.2       
 [37] tensor_1.5             future.apply_1.11.0    zoo_1.8-12            
 [40] sctransform_0.4.1      httpuv_1.6.12          Matrix_1.6-3          
 [43] splines_4.3.2          igraph_1.5.1           tidyselect_1.2.0      
 [46] abind_1.4-5            spatstat.random_3.2-1  codetools_0.2-19      
 [49] miniUI_0.1.1.1         spatstat.explore_3.2-5 listenv_0.9.0         
 [52] lattice_0.22-5         tibble_3.2.1           plyr_1.8.9            
 [55] shiny_1.8.0            ROCR_1.0-11            Rtsne_0.16            
 [58] future_1.33.0          fastDummies_1.7.3      survival_3.5-7        
 [61] polyclip_1.10-6        fitdistrplus_1.1-11    pillar_1.9.0          
 [64] KernSmooth_2.23-22     plotly_4.10.3          generics_0.1.3        
 [67] RcppHNSW_0.5.0         ggplot2_3.4.4          munsell_0.5.0         
 [70] scales_1.2.1           globals_0.16.2         xtable_1.8-4          
 [73] glue_1.6.2             lazyeval_0.2.2         tools_4.3.2           
 [76] data.table_1.14.8      RSpectra_0.16-1        RANN_2.6.1            
 [79] leiden_0.4.3.1         dotCall64_1.1-0        cowplot_1.1.1         
 [82] grid_4.3.2             tidyr_1.3.0            colorspace_2.1-0      
 [85] nlme_3.1-163           patchwork_1.1.3        cli_3.6.1             
 [88] spatstat.sparse_3.0-3  spam_2.10-0            fansi_1.0.5           
 [91] viridisLite_0.4.2      dplyr_1.1.4            uwot_0.1.16           
 [94] gtable_0.3.4           digest_0.6.33          progressr_0.14.0      
 [97] ggrepel_0.9.4          htmlwidgets_1.6.3      htmltools_0.5.7       
[100] lifecycle_1.0.4        httr_1.4.7             mime_0.12             
[103] MASS_7.3-60  
pati-ni commented 10 months ago

Hi @katimbach ,

thanks for the detailed report.

Actually, you may have been affected by changes in the API and there are several arguments that start with reduction (reduction.use and reduction.save). To fix this, you need to be explicit about which one you are choosing. In this case, I think replacing reduction="PCA with reduction.use="pca" would solve the issue.

Also, I would recommend upgrading to v1.2 because there are fixes and performance enhancements

katimbach commented 10 months ago

Thank you so much! I upgraded and changed the parameter to reduction.use and this did the trick!