This document has last been compiled on 2021-12-14 21:28:35.

Bringing in the effect sizes

We bring in the per-timepoint estimates of effect size from results/BT642Year1/DE_timepoint.

Time Interval Effect Size Summaries

Using the estimates of log-fold change at different time points, we will also calculate cumulative measures of log-fold change over wider periods of time.

The basic measure of log fold-change is the cumulative mean of the absolute log-fold change, with a sign (postive/negative) being imposed based on the sign of the mean of the log-fold change (i.e. without the absolute values):

\[sign(\frac{1}{N}\sum_{i=1}^{N}lfc_i)\times\frac{1}{N}\sum_{i=1}^{N}|lfc_i|.\] \(N\) is the number of the time points of our time period of interest (e.g. drought time points, water recovery time points, etc).

The column above (_lfc) is used for the log-fold change value between the drought condition and the control for a particular timepoint.

Note that the code also calculates this same summary value using the test statistic (_stat), basically a t-statistic.

In addition to all timepoints, the time periods that are considered are summarized over intervals (defined in sharedDataCommands.R). Below is a summary of the time periods for which effects are calculated. This summary is the maximum possible timepoints that could be included – if a particular timepoint is missing (e.g. missing due to not being sampled that year or samples failing ) that is not necessarily indicated below.

##                            Description.Preflowering.DroughtDiff.AllTps
## 1  All timepoints from Preflowering design that different from control
## 2  All timepoints from Preflowering design that different from control
## 3  All timepoints from Preflowering design that different from control
## 4  All timepoints from Preflowering design that different from control
## 5  All timepoints from Preflowering design that different from control
## 6  All timepoints from Preflowering design that different from control
## 7  All timepoints from Preflowering design that different from control
## 8  All timepoints from Preflowering design that different from control
## 9  All timepoints from Preflowering design that different from control
## 10 All timepoints from Preflowering design that different from control
## 11 All timepoints from Preflowering design that different from control
##    Description.Preflowering.DroughtDiff.DroughtTps
## 1               Preflowering design, under drought
## 2               Preflowering design, under drought
## 3               Preflowering design, under drought
## 4               Preflowering design, under drought
## 5               Preflowering design, under drought
## 6               Preflowering design, under drought
## 7               Preflowering design, under drought
## 8               Preflowering design, under drought
## 9               Preflowering design, under drought
## 10              Preflowering design, under drought
## 11              Preflowering design, under drought
##    Description.Preflowering.DroughtDiff.RecoveryTps
## 1                     Preflowering design, recovery
## 2                     Preflowering design, recovery
## 3                     Preflowering design, recovery
## 4                     Preflowering design, recovery
## 5                     Preflowering design, recovery
## 6                     Preflowering design, recovery
## 7                     Preflowering design, recovery
## 8                     Preflowering design, recovery
## 9                     Preflowering design, recovery
## 10                    Preflowering design, recovery
## 11                    Preflowering design, recovery
##    Description.Preflowering.DroughtDiff.EarlyDroughtTps
## 1              Preflowering design, under early drought
## 2              Preflowering design, under early drought
## 3              Preflowering design, under early drought
## 4              Preflowering design, under early drought
## 5              Preflowering design, under early drought
## 6              Preflowering design, under early drought
## 7              Preflowering design, under early drought
## 8              Preflowering design, under early drought
## 9              Preflowering design, under early drought
## 10             Preflowering design, under early drought
## 11             Preflowering design, under early drought
##    Description.Preflowering.DroughtDiff.LateDroughtTps
## 1              Preflowering design, under late drought
## 2              Preflowering design, under late drought
## 3              Preflowering design, under late drought
## 4              Preflowering design, under late drought
## 5              Preflowering design, under late drought
## 6              Preflowering design, under late drought
## 7              Preflowering design, under late drought
## 8              Preflowering design, under late drought
## 9              Preflowering design, under late drought
## 10             Preflowering design, under late drought
## 11             Preflowering design, under late drought
##    Description.Preflowering.DroughtDiff.EarlyRecoveryTps
## 1              Preflowering design, under early recovery
## 2              Preflowering design, under early recovery
## 3              Preflowering design, under early recovery
## 4              Preflowering design, under early recovery
## 5              Preflowering design, under early recovery
## 6              Preflowering design, under early recovery
## 7              Preflowering design, under early recovery
## 8              Preflowering design, under early recovery
## 9              Preflowering design, under early recovery
## 10             Preflowering design, under early recovery
## 11             Preflowering design, under early recovery
##    Description.Preflowering.DroughtDiff.LateRecoveryTps
## 1              Preflowering design, under late recovery
## 2              Preflowering design, under late recovery
## 3              Preflowering design, under late recovery
## 4              Preflowering design, under late recovery
## 5              Preflowering design, under late recovery
## 6              Preflowering design, under late recovery
## 7              Preflowering design, under late recovery
## 8              Preflowering design, under late recovery
## 9              Preflowering design, under late recovery
## 10             Preflowering design, under late recovery
## 11             Preflowering design, under late recovery
##                            Description.Postflowering.DroughtDiff.AllTps
## 1  All timepoints from Postflowering design that different from control
## 2  All timepoints from Postflowering design that different from control
## 3  All timepoints from Postflowering design that different from control
## 4  All timepoints from Postflowering design that different from control
## 5  All timepoints from Postflowering design that different from control
## 6  All timepoints from Postflowering design that different from control
## 7  All timepoints from Postflowering design that different from control
## 8  All timepoints from Postflowering design that different from control
## 9  All timepoints from Postflowering design that different from control
## 10 All timepoints from Postflowering design that different from control
## 11 All timepoints from Postflowering design that different from control
##    Description.Postflowering.DroughtDiff.DroughtTps
## 1               Postflowering design, under drought
## 2               Postflowering design, under drought
## 3               Postflowering design, under drought
## 4               Postflowering design, under drought
## 5               Postflowering design, under drought
## 6               Postflowering design, under drought
## 7               Postflowering design, under drought
## 8               Postflowering design, under drought
## 9               Postflowering design, under drought
## 10              Postflowering design, under drought
## 11              Postflowering design, under drought
##    Description.Postflowering.DroughtDiff.EarlyDroughtTps
## 1                    Postflowering design, early drought
## 2                    Postflowering design, early drought
## 3                    Postflowering design, early drought
## 4                    Postflowering design, early drought
## 5                    Postflowering design, early drought
## 6                    Postflowering design, early drought
## 7                    Postflowering design, early drought
## 8                    Postflowering design, early drought
## 9                    Postflowering design, early drought
## 10                   Postflowering design, early drought
## 11                   Postflowering design, early drought
##    Description.Postflowering.DroughtDiff.LateDroughtTps
## 1                    Postflowering design, late drought
## 2                    Postflowering design, late drought
## 3                    Postflowering design, late drought
## 4                    Postflowering design, late drought
## 5                    Postflowering design, late drought
## 6                    Postflowering design, late drought
## 7                    Postflowering design, late drought
## 8                    Postflowering design, late drought
## 9                    Postflowering design, late drought
## 10                   Postflowering design, late drought
## 11                   Postflowering design, late drought
##                                         TimePoints
## 1  21,28,35,42,49,56,63,70,77,84,91,98,105,112,119
## 2                                21,28,35,42,49,56
## 3                    63,70,77,84,91,98,105,112,119
## 4                                         21,28,35
## 5                                         42,49,56
## 6                                               63
## 7                       70,77,84,91,98,105,112,119
## 8                       70,77,84,91,98,105,112,119
## 9                       70,77,84,91,98,105,112,119
## 10                                           70,77
## 11                            84,91,98,105,112,119
##                                     columnName
## 1            Preflowering.DroughtDiff.AllTps.X
## 2        Preflowering.DroughtDiff.DroughtTps.X
## 3       Preflowering.DroughtDiff.RecoveryTps.X
## 4   Preflowering.DroughtDiff.EarlyDroughtTps.X
## 5    Preflowering.DroughtDiff.LateDroughtTps.X
## 6  Preflowering.DroughtDiff.EarlyRecoveryTps.X
## 7   Preflowering.DroughtDiff.LateRecoveryTps.X
## 8           Postflowering.DroughtDiff.AllTps.X
## 9       Postflowering.DroughtDiff.DroughtTps.X
## 10 Postflowering.DroughtDiff.EarlyDroughtTps.X
## 11  Postflowering.DroughtDiff.LateDroughtTps.X

Note that Postflowering.DroughtDiff.AllTps and Postflowering.DroughtDiff.DroughtTps are equivalent, by definition. We include both so that they mirror the Preflowering results

These effects will be calculated and added to the effects per timepoint (i.e. results of moanin calculations minus p-value) and saved to a separate file from the moanin results. The column names of these effects are as in the above table, only with X replaced with information that indicates the genotype and whether calculated on stat or lfc. (Note that we calculate the stat summary because it is used in extracting genotype differences.)

Calculating Effect size summaries

## Calculating Preflowering.DroughtDiff.AllTps with timepoints:
##  [1]  21  28  35  42  49  56  63  70  77  84  91  98 105 112 119
## 
## Calculating Preflowering.DroughtDiff.DroughtTps with timepoints:
## [1] 21 28 35 42 49 56
## 
## Calculating Preflowering.DroughtDiff.RecoveryTps with timepoints:
## [1]  63  70  77  84  91  98 105 112 119
## 
## Calculating Preflowering.DroughtDiff.EarlyDroughtTps with timepoints:
## [1] 21 28 35
## 
## Calculating Preflowering.DroughtDiff.LateDroughtTps with timepoints:
## [1] 42 49 56
## 
## Calculating Preflowering.DroughtDiff.EarlyRecoveryTps with timepoints:
## [1] 63
## 
## Calculating Preflowering.DroughtDiff.LateRecoveryTps with timepoints:
## [1]  70  77  84  91  98 105 112 119
## 
## Calculating Postflowering.DroughtDiff.AllTps with timepoints:
## [1]  70  77  84  91  98 105 112 119
## 
## Calculating Postflowering.DroughtDiff.DroughtTps with timepoints:
## [1]  70  77  84  91  98 105 112 119
## 
## Calculating Postflowering.DroughtDiff.EarlyDroughtTps with timepoints:
## [1] 70 77
## 
## Calculating Postflowering.DroughtDiff.LateDroughtTps with timepoints:
## [1]  84  91  98 105 112 119
## 
## Calculating Preflowering.DroughtDiff.AllTps with timepoints:
##  [1]  21  28  35  42  49  56  63  70  77  84  91  98 105 112 119
## 
## Calculating Preflowering.DroughtDiff.DroughtTps with timepoints:
## [1] 21 28 35 42 49 56
## 
## Calculating Preflowering.DroughtDiff.RecoveryTps with timepoints:
## [1]  63  70  77  84  91  98 105 112 119
## 
## Calculating Preflowering.DroughtDiff.EarlyDroughtTps with timepoints:
## [1] 21 28 35
## 
## Calculating Preflowering.DroughtDiff.LateDroughtTps with timepoints:
## [1] 42 49 56
## 
## Calculating Preflowering.DroughtDiff.EarlyRecoveryTps with timepoints:
## [1] 63
## 
## Calculating Preflowering.DroughtDiff.LateRecoveryTps with timepoints:
## [1]  70  77  84  91  98 105 112 119
## 
## Calculating Postflowering.DroughtDiff.AllTps with timepoints:
## [1]  70  77  84  91  98 105 112 119
## 
## Calculating Postflowering.DroughtDiff.DroughtTps with timepoints:
## [1]  70  77  84  91  98 105 112 119
## 
## Calculating Postflowering.DroughtDiff.EarlyDroughtTps with timepoints:
## [1] 70 77
## 
## Calculating Postflowering.DroughtDiff.LateDroughtTps with timepoints:
## [1]  84  91  98 105 112 119

We give a quick summary of the log-foldchange of these results:

## BT642:
##  Preflowering.AllTps Preflowering.DroughtTps Preflowering.RecoveryTps
##  Min.   :-2.54031    Min.   :-3.19886        Min.   :-2.81958        
##  1st Qu.:-0.24130    1st Qu.:-0.30025        1st Qu.:-0.20793        
##  Median : 0.16114    Median : 0.12223        Median : 0.11680        
##  Mean   : 0.04613    Mean   : 0.01992        Mean   : 0.03259        
##  3rd Qu.: 0.31122    3rd Qu.: 0.32826        3rd Qu.: 0.27108        
##  Max.   : 4.04012    Max.   : 7.43195        Max.   : 3.37144        
##  Preflowering.EarlyDroughtTps Preflowering.LateDroughtTps
##  Min.   :-2.46043             Min.   :-4.53766           
##  1st Qu.:-0.27012             1st Qu.:-0.29109           
##  Median : 0.06254             Median : 0.12817           
##  Mean   : 0.01837             Mean   : 0.03395           
##  3rd Qu.: 0.29364             3rd Qu.: 0.36360           
##  Max.   : 5.58198             Max.   : 9.28192           
##  Preflowering.EarlyRecoveryTps Preflowering.LateRecoveryTps
##  Min.   :-4.47642              Min.   :-3.09232            
##  1st Qu.:-0.25371              1st Qu.:-0.19632            
##  Median :-0.01313              Median : 0.11886            
##  Mean   : 0.04013              Mean   : 0.03184            
##  3rd Qu.: 0.26070              3rd Qu.: 0.25706            
##  Max.   : 8.17318              Max.   : 2.86386            
##  Postflowering.AllTps Postflowering.DroughtTps Postflowering.EarlyDroughtTps
##  Min.   :-3.6662      Min.   :-3.6662          Min.   :-3.51894             
##  1st Qu.:-0.2563      1st Qu.:-0.2563          1st Qu.:-0.19977             
##  Median : 0.1526      Median : 0.1526          Median : 0.06656             
##  Mean   : 0.0415      Mean   : 0.0415          Mean   : 0.02740             
##  3rd Qu.: 0.3307      3rd Qu.: 0.3307          3rd Qu.: 0.24119             
##  Max.   : 4.6112      Max.   : 4.6112          Max.   : 5.38534             
##  Postflowering.LateDroughtTps
##  Min.   :-3.96373            
##  1st Qu.:-0.26681            
##  Median : 0.16356            
##  Mean   : 0.04686            
##  3rd Qu.: 0.36119            
##  Max.   : 4.42581

And the percentage of genes past certain quantiles:

Proportion absolute lfc greater in BT642:

% abs(lfc)> 0.8 % abs(lfc)> 1 % abs(lfc)> 1.5 % abs(lfc)> 2
Preflowering.AllTps 0.065 0.032 0.006 0.002
Preflowering.DroughtTps 0.116 0.070 0.025 0.009
Preflowering.RecoveryTps 0.042 0.021 0.004 0.001
Preflowering.EarlyDroughtTps 0.079 0.043 0.011 0.004
Preflowering.LateDroughtTps 0.159 0.109 0.048 0.023
Preflowering.EarlyRecoveryTps 0.135 0.092 0.040 0.019
Preflowering.LateRecoveryTps 0.035 0.018 0.004 0.001
Postflowering.AllTps 0.093 0.055 0.018 0.007
Postflowering.DroughtTps 0.093 0.055 0.018 0.007
Postflowering.EarlyDroughtTps 0.086 0.054 0.019 0.008
Postflowering.LateDroughtTps 0.104 0.061 0.021 0.007

Max Summaries

We will create another global summary that is the max of log-fold changes either across

  1. All timepoints
  2. The summary of the timepoints

We consider both of these when we use results from only RT430 or BT642 or when we take the max across both genotypes.

We give a quick summary of the log-foldchange of these results:

## BT642:
##  Preflowering.MaxOfIntervals Preflowering.MaxOfTps Postflowering.MaxOfIntervals
##  Min.   :-2.8505             Min.   :-2.54031      Min.   :-1.3072             
##  1st Qu.:-0.1692             1st Qu.:-0.24130      1st Qu.: 0.1549             
##  Median : 0.2441             Median : 0.16114      Median : 0.2859             
##  Mean   : 0.2894             Mean   : 0.04613      Mean   : 0.3579             
##  3rd Qu.: 0.5376             3rd Qu.: 0.31122      3rd Qu.: 0.4845             
##  Max.   : 9.2819             Max.   : 4.04012      Max.   : 5.3853             
##  Postflowering.MaxOfTps
##  Min.   :-3.21561      
##  1st Qu.:-0.25495      
##  Median : 0.14519      
##  Mean   : 0.03612      
##  3rd Qu.: 0.30985      
##  Max.   : 4.15867

And the percentage of genes past certain quantiles:

## Proportion absolute lfc greater in BT642:
##                              % abs(lfc)> 0.8 % abs(lfc)> 1 % abs(lfc)> 1.5
## Preflowering.MaxOfIntervals       0.15422745    0.10432894     0.047490913
## Preflowering.MaxOfTps             0.06500496    0.03214842     0.006136997
## Postflowering.MaxOfIntervals      0.09351839    0.05480810     0.019166313
## Postflowering.MaxOfTps            0.07694850    0.04357268     0.012321201
##                              % abs(lfc)> 2
## Preflowering.MaxOfIntervals    0.025256102
## Preflowering.MaxOfTps          0.001746684
## Postflowering.MaxOfIntervals   0.007600434
## Postflowering.MaxOfTps         0.004248690

We do a quick pairs plot to compare these values

Merge and Add Global Splines Results

We also will merge in the global splines summary of effect. This should be equal to the DroughtDiff.AllTps in the above, but it is somewhat different. It’s not clear the source of the differences, but these are calculated from the function in the package moanin.

We draw some basic pairs plots to compare them:

Save individual timepoints

The final effects file also contains the individual timepoints results (of stat and lfc). We are going to clean up the column names and add that to our results. The columns will now be of the form Preflowering.DroughtDiff.Tp.14_lfc where they were previously of the form Group_BT642_Preflowering.14-Group_BT642_Control.14_stat

## Old Results:
##                       Gene
## 1 SbiBTX642.01G000200.v1.1
## 2 SbiBTX642.01G000400.v1.1
## 3 SbiBTX642.01G000500.v1.1
## 4 SbiBTX642.01G000600.v1.1
## 5 SbiBTX642.01G000900.v1.1
## 6 SbiBTX642.01G001000.v1.1
##   Group_BT642_Preflowering.21-Group_BT642_Control.21_lfc
## 1                                            -0.29252544
## 2                                            -0.38953399
## 3                                            -0.33991469
## 4                                            -0.71076026
## 5                                            -0.03202144
## 6                                            -0.10404199
##   Group_BT642_Preflowering.28-Group_BT642_Control.28_lfc
## 1                                          -0.0008505584
## 2                                          -0.1332127352
## 3                                           0.2326486856
## 4                                          -0.0703141819
## 5                                           0.5748316901
## 6                                           0.4443493292
##   Group_BT642_Preflowering.35-Group_BT642_Control.35_lfc
## 1                                             -0.1712599
## 2                                             -0.2902600
## 3                                             -0.1820348
## 4                                             -0.2352668
## 5                                              0.5828230
## 6                                              0.1755099
##   Group_BT642_Preflowering.42-Group_BT642_Control.42_lfc
## 1                                            -0.05493845
## 2                                             0.02436610
## 3                                            -0.03868713
## 4                                            -0.45653764
## 5                                             0.70658462
## 6                                             0.42970430
## New Results:
##                       Gene Preflowering.DroughtDiff.Day021.BT642_lfc
## 1 SbiBTX642.01G000200.v1.1                               -0.29252544
## 2 SbiBTX642.01G000400.v1.1                               -0.38953399
## 3 SbiBTX642.01G000500.v1.1                               -0.33991469
## 4 SbiBTX642.01G000600.v1.1                               -0.71076026
## 5 SbiBTX642.01G000900.v1.1                               -0.03202144
## 6 SbiBTX642.01G001000.v1.1                               -0.10404199
##   Preflowering.DroughtDiff.Day028.BT642_lfc
## 1                             -0.0008505584
## 2                             -0.1332127352
## 3                              0.2326486856
## 4                             -0.0703141819
## 5                              0.5748316901
## 6                              0.4443493292
##   Preflowering.DroughtDiff.Day035.BT642_lfc
## 1                                -0.1712599
## 2                                -0.2902600
## 3                                -0.1820348
## 4                                -0.2352668
## 5                                 0.5828230
## 6                                 0.1755099
##   Preflowering.DroughtDiff.Day042.BT642_lfc
## 1                               -0.05493845
## 2                                0.02436610
## 3                               -0.03868713
## 4                               -0.45653764
## 5                                0.70658462
## 6                                0.42970430

Saving Results

## Saving effect size of leaf to results/BT642Year1/data