I have an experimental design as follows:
Patient | Disease | Treatment |
1 | Unaffected | Treated |
1 | Unaffected | Untreated |
2 | Unaffected | Treated |
2 | Unaffected | Untreated |
3 | Unaffected | Treated |
3 | Unaffected | Untreated |
4 | Affected | Treated |
4 | Affected | Untreated |
5 | Affected | Treated |
5 | Affected | Untreated |
6 | Affected | Treated |
6 | Affected | Untreated |
We'd like to test:
1) Untreated, Affected vs. Unaffected
2) Unaffected-only, Treated vs. Untreated
3) Affected-only, Treated vs. Untreated
We are trying to use SVA to also control for cell composition and the include the SV's in the model.
mod <- model.matrix(~0+Treatment:Disease, data=pd) mod0 <- model.matrix(~1, data=pd) svobj <- sva(M, mod, mod0) design <- model.matrix(data=pd, ~0+Treatment:Disease+svobj$sv) colnames(design) <- c(paste0('SV',seq(ncol(svobj$sv))),'Untreat_Unaff','Treat_Unaff','Untreat_Aff','Treat_Aff') contrast.matrix <- makeContrasts('Treat_Aff-Untreat_Aff', 'Treat_Unaff-Untreat_Unaff', 'Untreat_Aff-Untreat_Unaff', levels=design)
Then we'd like to account for pairing of patient samples without and with treatment using duplicateCorrelation().
dupCor <- duplicateCorrelation(M, design, block=factor(pd$Patient))
But we get this error:
Warning message in atanh(pmax(-1, rho)): "NaNs produced"
It works when I don't add the SV's to the model so just confused as to what's going on.
design <- model.matrix(data=pd, ~0+Treatment:Disease)
Is there something I'm not understanding about the design matrix, problem there causing this problem? Not at all confident we've set this up correctly.