19.1 Exporting fragment-level data
Before we start exporting data, lets save projHeme5
to its own directory.
projHeme5 <- saveArchRProject(ArchRProj = projHeme5, outputDirectory = "Save-ProjHeme5", load = TRUE)
## Copying ArchRProject to new outputDirectory : /workspace/ArchR/ArchR_Website_Testing/bookdown/Save-ProjHeme5
## Copying Arrow Files...
## Copying Arrow Files (1 of 3)
## Copying Arrow Files (2 of 3)
## Copying Arrow Files (3 of 3)
## Getting ImputeWeights
## Dropping ImputeWeights...
## Copying Other Files...
## Copying Other Files (1 of 12): Annotations
## Copying Other Files (2 of 12): Background-Peaks.rds
## Copying Other Files (3 of 12): Embeddings
## Copying Other Files (4 of 12): GroupCoverages
## Copying Other Files (5 of 12): IterativeLSI
## Copying Other Files (6 of 12): IterativeLSI2
## Copying Other Files (7 of 12): IterativeLSI3
## Copying Other Files (8 of 12): Monocole3
## Copying Other Files (9 of 12): Peak2GeneLinks
## Copying Other Files (10 of 12): PeakCalls
## Copying Other Files (11 of 12): Plots
## Copying Other Files (12 of 12): RNAIntegration
## Saving ArchRProject...
## Loading ArchRProject...
## Successfully loaded ArchRProject!
##
## / |
## / \
## . / |.
## \\\ / |.
## \\\ / `|.
## \\\ / |.
## \ / |\
## \\#####\ / ||
## ==###########> / ||
## \\##==......\ / ||
## ______ = =|__ /__ || \\\
## ,--' ,----`-,__ ___/' --,-`-===================##========>
## \ ' ##_______ _____ ,--,__,=##,__ ///
## , __== ___,-,__,--'#' ===' `-' | ##,-/
## -,____,---' \\####\\________________,--\\_##,/
## ___ .______ ______ __ __ .______
## / \ | _ \ / || | | | | _ \
## / ^ \ | |_) | | ,----'| |__| | | |_) |
## / /_\ \ | / | | | __ | | /
## / _____ \ | |\ \\___ | `----.| | | | | |\ \\___.
## /__/ \__\ | _| `._____| \______||__| |__| | _| `._____|
##
To enable optimal flexibility, ArchR allows you to export fragments from your ArchRProject
or ArrowFiles at any time using the getFragmentsFromArrow()
, getFragmentsFromProject()
, and getGroupFragments()
functions. For the getFragmentsFromArrow()
and getFragmentsFromProject()
functions, you must provide the cellNames
for the cells you wish to extract. For example, you might extract the fragments from a particular cluster from your entire project like this:
frags <- getFragmentsFromProject(
ArchRProj = projHeme5,
cellNames = getCellNames(ArchRProj = projHeme5)[which(projHeme5@cellColData$Clusters2 == "Mono")]
)
## ArchR logging to : ArchRLogs/ArchR-getFragmentsFromProject-93afeb579-Date-2025-02-06_Time-03-08-30.449711.log
## If there is an issue, please report to github with logFile!
## Reading ArrowFile 1 of 3
## Reading ArrowFile 2 of 3
## Reading ArrowFile 3 of 3
Inspecting the frags
object here, shows it to be a list and each of the elements of frags
is a GRanges
object corresponding to one of the original Arrow Files:
We can just unlist this object to get a GRanges
object where each entry represents an individual fragment:
unlist(frags)
## GRanges object with 9320877 ranges and 1 metadata column:
## seqnames ranges strand | RG
## <Rle> <IRanges> <Rle> | <Rle>
## scATAC_BMMC_R1 chr1 842515-842901 * | scATAC_BMMC_R1#CCCAC..
## scATAC_BMMC_R1 chr1 931221-931355 * | scATAC_BMMC_R1#CCCAC..
## scATAC_BMMC_R1 chr1 939387-939615 * | scATAC_BMMC_R1#CCCAC..
## scATAC_BMMC_R1 chr1 985376-985401 * | scATAC_BMMC_R1#CCCAC..
## scATAC_BMMC_R1 chr1 988510-988541 * | scATAC_BMMC_R1#CCCAC..
## ... ... ... ... . ...
## scATAC_PBMC_R1 chrY 22737645-22737827 * | scATAC_PBMC_R1#AATGG..
## scATAC_PBMC_R1 chrY 15443307-15443509 * | scATAC_PBMC_R1#GGTGC..
## scATAC_PBMC_R1 chrY 14604751-14604917 * | scATAC_PBMC_R1#CGATG..
## scATAC_PBMC_R1 chrY 5609640-5609780 * | scATAC_PBMC_R1#TATGT..
## scATAC_PBMC_R1 chrY 22737684-22737775 * | scATAC_PBMC_R1#TATGT..
## -------
## seqinfo: 24 sequences from an unspecified genome; no seqlengths
Similarly, getGroupFragments()
provides a shortcut to doing fragment export based on cell groupings defined in cellColData
. However, this function creates fragment files on disk, rather than storing them as a GRanges
object.
Inspecting the frags
object returned as the output of getGroupFragments()
, we get the file paths to the fragment files on disk.
frags
## [1] "/workspace/ArchR/ArchR_Website_Testing/bookdown/Save-ProjHeme5/GroupFragments/Clusters2.B.tsv.gz"
## [2] "/workspace/ArchR/ArchR_Website_Testing/bookdown/Save-ProjHeme5/GroupFragments/Clusters2.CD4.M.tsv.gz"
## [3] "/workspace/ArchR/ArchR_Website_Testing/bookdown/Save-ProjHeme5/GroupFragments/Clusters2.CD4.N.tsv.gz"
## [4] "/workspace/ArchR/ArchR_Website_Testing/bookdown/Save-ProjHeme5/GroupFragments/Clusters2.CLP.tsv.gz"
## [5] "/workspace/ArchR/ArchR_Website_Testing/bookdown/Save-ProjHeme5/GroupFragments/Clusters2.Erythroid.tsv.gz"
## [6] "/workspace/ArchR/ArchR_Website_Testing/bookdown/Save-ProjHeme5/GroupFragments/Clusters2.GMP.tsv.gz"
## [7] "/workspace/ArchR/ArchR_Website_Testing/bookdown/Save-ProjHeme5/GroupFragments/Clusters2.Mono.tsv.gz"
## [8] "/workspace/ArchR/ArchR_Website_Testing/bookdown/Save-ProjHeme5/GroupFragments/Clusters2.NK.tsv.gz"
## [9] "/workspace/ArchR/ArchR_Website_Testing/bookdown/Save-ProjHeme5/GroupFragments/Clusters2.pDC.tsv.gz"
## [10] "/workspace/ArchR/ArchR_Website_Testing/bookdown/Save-ProjHeme5/GroupFragments/Clusters2.PreB.tsv.gz"
## [11] "/workspace/ArchR/ArchR_Website_Testing/bookdown/Save-ProjHeme5/GroupFragments/Clusters2.Progenitor.tsv.gz"