Vitek-Lab / MSstats

R package - MSstats
74 stars 46 forks source link

Issue found with the log(FC) values in GroupComparision function #39

Closed davco6 closed 3 years ago

davco6 commented 4 years ago

Hello,

Thank you for developing this great tool for proteomics.

I have found an issue regarding the GroupComparison.R function. Since with the same dataset (but different upstream analysis) I got sometimes log2(FC) and some log10(FC) output, but in either case the upstream analysis with DataProcess.R were done using the default logTrans=2 attribute.

This behavior is due to the code written in the lines 302-310 in GroupComparison.R

    if (abs(log2(temp[1, "INTENSITY"]) - temp[1, "ABUNDANCE"]) < 
        abs(log10(temp[1, "INTENSITY"]) - temp[1, "ABUNDANCE"])) {
        colnames(out.all)[3] <- "log2FC"
    }

    if (abs(log2(temp[1, "INTENSITY"]) - temp[1, "ABUNDANCE"]) >
        abs(log10(temp[1, "INTENSITY"]) - temp[1, "ABUNDANCE"])) {
        colnames(out.all)[3] <- "log10FC"
    }

This part of the code is changing only the header of the columns, but without taking into account the actual log transformation done in DataProcess.R.

In order to solve this issue I propose: first add a new attribute in GroupComparison.R to flag if the intensity values are on log2 or log10 (similar one you can find in the DataProcess.R, as a logTrans ), second remove the code in lines 302-310 and insert instead:

    if (logTrans==2) {
        colnames(out.all)[3] <- "log2FC"
    }
    else {
        colnames(out.all)[3] <- "log10FC"
    }

Regards, David