Thanks for helping/suggesting fixes ! I want to merge 8~10 Seurat objects or ChromatinAssay objects using the merge function and am running into a 'subscript out of bounds' issue.Error in all.counts[[2:length(x = all.counts)]] : subscript out of bounds
library(ggplot2) library(patchwork) set.seed(1234) library(EnsDb.Hsapiens.v86) library(GenomicRanges) if (!requireNamespace("devtools", quietly = TRUE)) if (!requireNamespace("remotes", quietly = TRUE)) install.packages("remotes") remotes::install_github(repo = 'satijalab/seurat', ref = 'develop') remotes::install_github(repo = 'timoast/signac', ref = 'develop') #### read in peak sets TO CREATE A COMMON PEAK SET pbmclist <- list(1410,1413,1422,1425,1428,1437,1440,1443) peaks.pbmclist <- list() for(i in 1:length(pbmclist)){ peaks.pbmclist[[i]] <- read.table( file = paste0("location/pbmc_human/",pbmclist[[i]],"_peaks.bed"), col.names = c("chr", "start", "end") ) } names(peaks.pbmclist) <- pbmclist # convert to genomic ranges gr.pbmclist <- list() for(i in 1:length(pbmclist)){ gr.pbmclist[[i]] <- makeGRangesFromDataFrame(peaks.pbmclist[[i]]) } # Create a unified set of peaks to quantify in each dataset for(i in 1:length(pbmclist)){ combined.peaks <- reduce(x = c(gr.pbmclist[[i]])) } # Filter out bad peaks based on length peakwidths <- width(combined.peaks) combined.peaks <- combined.peaks[peakwidths < 10000 & peakwidths > 20] combined.peaks #### CREATE A FRAG OBJ #### # load metadata md.pbmclist <- list() for(i in 1:length(pbmclist)){ md.pbmclist[[i]] <- read.table( file = paste0("location/pbmc_human/",pbmclist[[i]],"_singlecell.csv"), stringsAsFactors = FALSE, sep = ",", header = TRUE, row.names = 1 )[-1, ] # remove the first row } # perform an initial filtering of low count cells for(i in 1:length(pbmclist)){ md.pbmclist[[i]] <- md.pbmclist[[i]][md.pbmclist[[i]]$passed_filters > 500, ] } # create fragment objects frags.pbmclist <- list() for(i in 1:length(pbmclist)){ frags.pbmclist[[i]] <- CreateFragmentObject( path = paste0("location/pbmc_human/",pbmclist[[i]],"_fragments.tsv.gz"), cells = rownames(md.pbmclist[[i]]) ) } #Quantify peaks in each dataset peakcounts.pbmclist <- list() for(i in 1:length(pbmclist)){ peakcounts.pbmclist[[i]] <- FeatureMatrix( fragments = frags.pbmclist[[i]], features = combined.peaks, cells = rownames(md.pbmclist[[i]]) ) } #### CREATE and MERGE Signac object #### pbmclist_assay <- list() pbmclist_seuratobject <- list() for(i in 1:length(pbmclist)){ pbmclist_assay[[i]] <- CreateChromatinAssay(peakcounts.pbmclist[[i]], fragments = frags.pbmclist[[i]]) pbmclist_seuratobject[[i]] <- CreateSeuratObject(pbmclist_assay[[i]], assay = "ATAC") } # add dataset identifier for(i in 1:length(pbmclist)){ pbmclist_seuratobject[[i]]$dataset <- paste0('p',pbmclist[[i]]) } names(pbmclist_assay) <- pbmclist names(pbmclist_seuratobject) <- pbmclist # attempting to merge only 3 of the full 8 samples: combined <- merge( x = pbmclist_seuratobject[[1]], y = c(pbmclist_seuratobject[[2]],pbmclist_seuratobject[[3]]), add.cell.ids = c("1410", "1413", "1422") ) # merging only 2 works # combined <- merge( # x = pbmclist_seuratobject[[1]], # y = pbmclist_seuratobject[[2]], # add.cell.ids = c("1410", "1413") # )
sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 11.3.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/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 stats graphics grDevices utils datasets methods
[9] base
other attached packages:
[1] Signac_1.4.0 SeuratObject_4.0.2 GenomicRanges_1.42.0 GenomeInfoDb_1.26.7
[5] IRanges_2.24.1 S4Vectors_0.28.1 BiocGenerics_0.36.1
loaded via a namespace (and not attached):
[1] fastmatch_1.1-3 plyr_1.8.6 igraph_1.2.6
[4] lazyeval_0.2.2 splines_4.0.4 BiocParallel_1.24.1
[7] listenv_0.8.0 SnowballC_0.7.0 scattermore_0.7
[10] usethis_2.0.1 ggplot2_3.3.5 digest_0.6.28
[13] htmltools_0.5.2 fansi_0.5.0 magrittr_2.0.1
[16] memoise_2.0.0 tensor_1.5 cluster_2.1.2
[19] ROCR_1.0-11 remotes_2.4.0 globals_0.14.0
[22] Biostrings_2.58.0 matrixStats_0.61.0 docopt_0.7.1
[25] spatstat.sparse_2.0-0 prettyunits_1.1.1 colorspace_2.0-2
[28] ggrepel_0.9.1 dplyr_1.0.7 sparsesvd_0.2
[31] callr_3.7.0 crayon_1.4.1 RCurl_1.98-1.5
[34] jsonlite_1.7.2 spatstat.data_2.1-0 survival_3.2-13
[37] zoo_1.8-9 glue_1.4.2 polyclip_1.10-0
[40] gtable_0.3.0 zlibbioc_1.36.0 XVector_0.30.0
[43] leiden_0.3.9 pkgbuild_1.2.0 future.apply_1.8.1
[46] abind_1.4-5 scales_1.1.1 DBI_1.1.1
[49] miniUI_0.1.1.1 Rcpp_1.0.7 viridisLite_0.4.0
[52] xtable_1.8-4 reticulate_1.22 spatstat.core_2.3-0
[55] htmlwidgets_1.5.4 httr_1.4.2 RColorBrewer_1.1-2
[58] ellipsis_0.3.2 Seurat_4.0.4.9000 ica_1.0-2
[61] farver_2.1.0 pkgconfig_2.0.3 ggseqlogo_0.1
[64] uwot_0.1.10 deldir_0.2-10 utf8_1.2.2
[67] tidyselect_1.1.1 rlang_0.4.11 reshape2_1.4.4
[70] later_1.3.0 munsell_0.5.0 tools_4.0.4
[73] cachem_1.0.6 cli_3.0.1 generics_0.1.0
[76] devtools_2.4.2 ggridges_0.5.3 stringr_1.4.0
[79] fastmap_1.1.0 goftest_1.2-2 processx_3.5.2
[82] fs_1.5.0 fitdistrplus_1.1-5 purrr_0.3.4
[85] RANN_2.6.1 pbapply_1.5-0 future_1.22.1
[88] nlme_3.1-153 mime_0.11 slam_0.1-48
[91] RcppRoll_0.3.0 compiler_4.0.4 rstudioapi_0.13
[94] plotly_4.9.4.1 curl_4.3.2 png_0.1-7
[97] testthat_3.0.4 spatstat.utils_2.2-0 tweenr_1.0.2
[100] tibble_3.1.4 stringi_1.7.4 ps_1.6.0
[103] desc_1.3.0 lattice_0.20-45 Matrix_1.3-4
[106] vctrs_0.3.8 pillar_1.6.3 lifecycle_1.0.1
[109] spatstat.geom_2.2-2 lmtest_0.9-38 RcppAnnoy_0.0.19
[112] data.table_1.14.2 cowplot_1.1.1 bitops_1.0-7
[115] irlba_2.3.3 httpuv_1.6.3 patchwork_1.1.1
[118] R6_2.5.1 promises_1.2.0.1 lsa_0.73.2
[121] KernSmooth_2.23-20 gridExtra_2.3 parallelly_1.28.1
[124] sessioninfo_1.1.1 codetools_0.2-18 MASS_7.3-54
[127] assertthat_0.2.1 pkgload_1.2.2 rprojroot_2.0.2
[130] withr_2.4.2 qlcMatrix_0.9.7 sctransform_0.3.2
[133] Rsamtools_2.6.0 GenomeInfoDbData_1.2.4 mgcv_1.8-37
[136] grid_4.0.4 rpart_4.1-15 tidyr_1.1.4
[139] Rtsne_0.15 ggforce_0.3.3 shiny_1.7.0
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4