saezlab / MetaProViz

R-package to perform metabolomics pre-processing, differential metabolite analysis, metabolite clustering and custom visualisations.
https://saezlab.github.io/MetaProViz/
GNU General Public License v3.0
9 stars 0 forks source link

Log2FC for CoRe data #5

Closed ChristinaSchmidt1 closed 1 year ago

ChristinaSchmidt1 commented 1 year ago

Opposed to intracellular metabolomics with CoRe, we will have negative and positive values for the features. If we now calculate the Log2FC this can cause issues:

Since you can not perform Log2 on negative values (in R it may work since in the function they use abs(value)) since we will underestimate the FoldChange itself if we built it between a negative and a positive value The solution is that if we have a negative and a positive value we need to calculate the fold change of, we need to transform both values prior to the caluclation maintaining the distance (C1 versus C2): if(Condition 1 <0 & Cond2 >0){ C1 value =C1+(-C1)+1 C2 value =C2+(-C1)+1 } else if(| (Condition 2<0 & Cond1>0){ C1 value =C1+(-C2)+1 C2 value =C2+(-C2)+1 } } else{ as it is }

Meaning If e.g. C1= -5 and C2=20, we will get C1=1 and C2=26, in both cases a distance of 25 between C1 and C2. Yet the FoldChange C1/C2 in case 1 is -0.25 and in case 2 is 0.038, giving #NUM! for Log2(-0.25) and -4.7 if we do the adaptation.

The other way around C1= 5 and C2=-20, we will get C1=26 and C2=1 in both cases a distance of 25 between C1 and C2. Yet the FoldChange C1/C2 in case 1 is -0.25 and in case 2 is 26 giving #NUM! for Log2(-0.25) and +4.7 if we do the adaptation.

BUT: As you mentioned in todays meeting the resulting FC and hence Log2FC is impacted by how much we add (+1 or +100,...), so we will need to understand first how to deal with this before we implement this.

ChristinaSchmidt1 commented 1 year ago

Given we have quite big values in metabolomics and also quite broad ranges of those between metabolites. At the moment I am exploring if using the absolute value for the negative value and than adapting the positive value in the same way would be an option. E.g. -20 = abs(-20) = 20, in which case 5 =45. So the disantce from -20 to 5 is the same as from 20 to 45.

ChristinaSchmidt1 commented 1 year ago

I have implemented the changes for the core and now we can deal with the negative values taking into account the size range,

I havent dealt with 0 yet, so at the moment both in core and intra, we will have NA for the values if one of the two conditions are 0. I have some strategies in mind I will try the next days.

ChristinaSchmidt1 commented 1 year ago

I will close this issue as the CoRe Log2FC calculation has been fixed.