GreenleafLab / ArchR

ArchR : Analysis of Regulatory Chromatin in R (www.ArchRProject.com)
MIT License
384 stars 137 forks source link

possible way/input matrices to run ChromVAR motif correlation/synergy functions #524

Closed willey2020 closed 3 years ago

willey2020 commented 3 years ago

Hello! Appreciate this great package!

Describe the problem that your feature request would address. I would like to run ChromVAR's motif synergy function and motif correlation functions (getAnnotationCorrelation/getAnnotationSynergy) and check the possible relationship between motifs across cells, However, I am not sure how to utilize the appropriate matrices in ArchR project to input them into ChromVAR.

Describe the solution you'd like Within ArchR, Is there any way to use the motif data inside ArchR project and input into ChromVAR functions, for example like what showed in ChromVAR manual: "getAnnotationCorrelation(counts_filtered, motif_ix[,c(83,24,20)])"

Describe alternatives you've considered Or is there any way to extract any necessary matrices out, and then import them into ChromVAR to run these functions.

Thank you very much for your support and great package!

jgranja24 commented 3 years ago

Hi @willey2020, yeah the alternative seems more plausible to just export the necessary matrices. Let me give it a shot with the test data.

willey2020 commented 3 years ago

Thank you so much Jeff !!

jgranja24 commented 3 years ago

Hi @willey2020, here is an example to run chromVAR applications in ArchR's ecosystem.

library(ArchR)
library(chromVAR)

#Read in ArchR Test Project
proj <- getTestProject()
proj
# class: ArchRProject 
# outputDirectory: /Users/jeffreygranja/Desktop/PBMCSmall 
# samples(1): PBMCSmall
# sampleColData names(1): ArrowFiles
# cellColData names(18): Sample TSSEnrichment ... ReadsInPeaks FRIP
# numberOfCells(1): 2217
# medianTSS(1): 12.277
# medianFrags(1): 593

#Get Peak Matrix
sePeak <- getMatrixFromProject(proj, "PeakMatrix")
names(assays(sePeak)) <- "counts" #Change for chromVAR

#Sanity Check
all(paste0(getPeakSet(proj)) == paste0(rowRanges(sePeak)))

#Set Bias
rowData(sePeak)$bias <- getPeakSet(proj)$GC

#Get Annotation Matrix
matches <- getMatches(proj)

#Sanity Check
all(paste0(rowRanges(sePeak)) == paste0(rowRanges(matches)))

#Synergy
getAnnotationSynergy(sePeak, matches[,c(83,24,20)])
#               MNT_20     HES7_83  HIF1A_24
# MNT_20    0.00000000 -0.06529487 0.5343535
# HES7_83  -0.06529487  0.00000000 0.1229296
# HIF1A_24  0.53435348  0.12292959 0.0000000

#Correlatoin
getAnnotationCorrelation(sePeak, matches[,c(83,24,20)])
#               MNT_20     HES7_83    HIF1A_24
# MNT_20    1.00000000 -0.06278633 -0.01736904
# HES7_83  -0.06278633  1.00000000 -0.05873168
# HIF1A_24 -0.01736904 -0.05873168  1.00000000

Hope this helps!

Jeff

willey2020 commented 3 years ago

Thank you so much Jeff! @jgranja24 I will give it a run! Thank you again for this great package!