DavisLaboratory / standR

Spatial transcriptomics analyses and decoding in R
https://davislaboratory.github.io/standR/
Other
18 stars 4 forks source link

Duplicate correlation and how to use it #41

Open hookoop opened 1 month ago

hookoop commented 1 month ago

Hey,

I was wondering if you could provide some lines of code for how to do DuplicateCorrelation twice.
This would be useful to include in the tutorial also since most likely many users will be having several AOIs from the same patient, which effectively count as technical replicates.

Best, Helka

ningbioinfo commented 2 weeks ago

Hi @hookoop , the code of using dupcor is some thing like this:

say y is the dgeList object.

v <- voom(y, design)
dupcor <- duplicateCorrelation(v, design, block=y$samples$PATIENTS_ID) # first round
v = voom(v, design, block=y$samples$PATIENTS_ID, correlation =dupcor$consensus)
dupcor <- duplicateCorrelation(v, design, block=y$samples$PATIENTS_ID) # second round

fit <- lmFit(v, design,  block=y$samples$PATIENTS_ID, correlation =dupcor$consensus)
contrasts.fit(...)
eBayes(...)

This first round of estimate may not fully account for the variability in the data or may not capture the true correlation accurately. Hence doing a second round might improve the case, you might see the the correlation beging changed just tiny bit not a lot. You can also do multiple rounds, but at the end the correlation will be the same after multiple rounds. I recall in the book of limma/edgeR that it was suggested that we do at least two rounds to get a good estimate.

I might incorperate this into the tutorial later..