12.4 Adding a Peak Matrix

We can now save our original projHeme4 using the saveArchRProject() function. This ArchRProject contains the MACS2-derived merged peak set. Here, we set load = TRUE to make sure that the projHeme4 object tracks with the project that we just saved.

projHeme4 <- saveArchRProject(ArchRProj = projHeme4, outputDirectory = "Save-ProjHeme4", load = TRUE)
## Copying ArchRProject to new outputDirectory : /corces/home/rcorces/scripts/github/ArchR_Website_Testing/bookdown/Save-ProjHeme4
## Copying Arrow Files...
## Copying Arrow Files (1 of 3)
## Copying Arrow Files (2 of 3)
## Copying Arrow Files (3 of 3)
## Getting ImputeWeights
## No imputeWeights found, returning NULL
## Copying Other Files...
## Copying Other Files (1 of 7): Embeddings
## Copying Other Files (2 of 7): GroupCoverages
## Copying Other Files (3 of 7): IterativeLSI
## Copying Other Files (4 of 7): IterativeLSI2
## Copying Other Files (5 of 7): PeakCalls
## Copying Other Files (6 of 7): Plots
## Copying Other Files (7 of 7): RNAIntegration
## Saving ArchRProject...
## Loading ArchRProject...
## Successfully loaded ArchRProject!
## 
##                                                    / |
##                                                  /    \
##             .                                  /      |.
##             \\\                              /        |.
##               \\\                          /           `|.
##                 \\\                      /              |.
##                   \                    /                |\
##                   \\#####\           /                  ||
##                 ==###########>      /                   ||
##                  \\##==......\    /                     ||
##             ______ =       =|__ /__                     ||      \\\
##         ,--' ,----`-,__ ___/'  --,-`-===================##========>
##        \               '        ##_______ _____ ,--,__,=##,__   ///
##         ,    __==    ___,-,__,--'#'  ==='      `-'    | ##,-/
##         -,____,---'       \\####\\________________,--\\_##,/
##            ___      .______        ______  __    __  .______      
##           /   \     |   _  \      /      ||  |  |  | |   _  \     
##          /  ^  \    |  |_)  |    |  ,----'|  |__|  | |  |_)  |    
##         /  /_\  \   |      /     |  |     |   __   | |      /     
##        /  _____  \  |  |\  \\___ |  `----.|  |  |  | |  |\  \\___.
##       /__/     \__\ | _| `._____| \______||__|  |__| | _| `._____|
## 

To prepare for downstream analyses, we can create a new ArchRProject called projHeme5 and add a new matrix to it containing insertion counts within our new merged peak set.

projHeme5 <- addPeakMatrix(projHeme4)
## ArchR logging to : ArchRLogs/ArchR-addPeakMatrix-371b0123794a8-Date-2022-12-23_Time-07-34-10.log
## If there is an issue, please report to github with logFile!
## 2022-12-23 07:34:11 : Batch Execution w/ safelapply!, 0 mins elapsed.
## ArchR logging successful to : ArchRLogs/ArchR-addPeakMatrix-371b0123794a8-Date-2022-12-23_Time-07-34-10.log

One important salient point in the above operation is that the R object projHeme5 is actually still pointing to the directory corresponding to projHeme4. Hopefully this illustrates the nuance of saving and loading ArchR projects and the difference between the R ArchRProject object and the objects saved on disk. The output directory for projHeme5 will not be set until we save this object using saveArchRProject() and set the outputDirectory. Until then, anything that we do to projHeme5 will update the contents in the “Save-ProjHeme4” directory.

getOutputDirectory(ArchRProj = projHeme5)
## [1] "/corces/home/rcorces/scripts/github/ArchR_Website_Testing/bookdown/Save-ProjHeme4"

Within projHeme5, we can now see that a new matrix has been added called “PeakMatrix”. This is another reserved-name matrix similar to GeneScoreMatrix and TileMatrix. As mentioned previously, each ArchRProject object can only have one peak set and one PeakMatrix. You can, of course, create an unlimited number of custom feature matrices of different names but PeakMatrix is reserved for the matrix of insertion counts derived from the peak set stored in the ArchRProject.

getAvailableMatrices(projHeme5)
## [1] "GeneIntegrationMatrix" "GeneScoreMatrix"       "PeakMatrix"           
## [4] "TileMatrix"