Hi aluesley1,
Firstly, you should not be modifying the colnames of your filtered objects, which means not executing the following lines:
colnames(MatchedTPdataFilt) <- (1:113)
colnames(MatchedNTdataFilt) <- (1:113)
So, from the save() command that you run, your code should be (nothing changed here, apart from not changing the colnames):
# selection of normal samples "NT"
samplesMatchedNT <- TCGAquery_SampleTypes(barcode = colnames(AllMatcheddataFilt),
typesample = c("NT"))
MatchedNTdataFilt <- AllMatcheddataFilt[,samplesMatchedNT]
MatchedNTdataFilt <- MatchedNTdataFilt[, order(colnames(MatchedNTdataFilt))]
# selection of tumor samples "TP"
samplesMatchedTP <- TCGAquery_SampleTypes(barcode = colnames(AllMatcheddataFilt),
typesample = c("TP"))
MatchedTPdataFilt <- AllMatcheddataFilt[,samplesMatchedTP]
MatchedTPdataFilt <- MatchedTPdataFilt[, order(colnames(MatchedTPdataFilt))]
After investigating what was going wrong after that, I found a possible oversight in the TCGAanalyze_DEA() function that only appears when paired=TRUE. I modified this function and was able to run the command. The new function is located here: https://github.com/kevinblighe/BiostarsMisc/blob/master/TCGAanalyze_DEA_Fix_aluesley1.R (only line 31 was edited)
When you download it and load it into R with source("TCGAanalyze_DEA_Fix_aluesley1.R"), you can then run your command:
dataDEGsMatched.paired <- TCGAanalyze_DEA_Fix_aluesley1(mat1 = MatchedTPdataFilt,
mat2 = MatchedNTdataFilt,
Cond1type = "Tumor",
Cond2type = "Normal",
fdr.cut = 0.01,
logFC.cut = 1.5,
method = "glmLRT",
paired = TRUE)
Disclaimer: This was modified for this specific example, so, don't use the modified function for other data.
-------------------------------------------
After having gone through the TCGAbiolinks code, I realised that it's not doing a proper paired analysis. All that it does is filter your dataset so that your 2 conditions have the same matched T-N (based on the shortened TCGA barcode), and then it just compares them with the standard test and same design formula as per the paired=FALSE. This is not a proper analysis because it's not adjusting for the within-patient effects that exist across a matched T-N pair.
Here's the proof:
dataDEGsMatched.unpaired <- TCGAanalyze_DEA_Fix_aluesley1(mat1 = MatchedTPdataFilt,
mat2 = MatchedNTdataFilt,
Cond1type = "Tumor",
Cond2type = "Normal",
fdr.cut = 0.01,
logFC.cut = 1.5,
method = "glmLRT",
paired = FALSE)
head(dataDEGsMatched.paired)
logFC logCPM LR PValue FDR
A2ML1 -4.400922 3.092592 113.93648 1.345505e-26 7.448902e-26
AADAC 4.113193 1.559164 82.50130 1.056005e-19 4.100799e-19
ABAT -1.684259 5.996629 98.78378 2.816324e-23 1.312682e-22
ABCA10 3.628860 3.106490 339.55028 7.994882e-76 3.910199e-74
head(dataDEGsMatched.unpaired)
logFC logCPM LR PValue FDR
A2ML1 -4.400922 3.092592 113.93648 1.345505e-26 7.448902e-26
AADAC 4.113193 1.559164 82.50130 1.056005e-19 4.100799e-19
ABAT -1.684259 5.996629 98.78378 2.816324e-23 1.312682e-22
ABCA10 3.628860 3.106490 339.55028 7.994882e-76 3.910199e-74
...produces the exact same stats. So, when using this DEA function of TCGAbiolinks, simply filtering your own dataset to have matched samples prior to running the DEA and using paired=FALSE is the exact same as using the paired=TRUE parameter.
For breast cancer, I believe it was indeed 112 or 113 for matched breast T-N .
Kevin
Hello again, can you show how you create the MatchedTPdataFilt and MatchedNTdataFilt objects? I just want to re-create the error on my own system. Is it somewhat a continuation of the issue in your other question ( A: Matched Paired Tumour-Normal DEA of BRCA using data downloaded using TCGAbiolink )?
Hello! Yes it is a continuation from that. I used a workflow for TCGAbiolinks to process the matched data. I have used it before for unmatched normal-tumour samples and it has worked.
Here is what I have used -
Okay, I have managed to reproduce the exact same error.... now let me see if I can solve it.
Posted an answer below