This document has last been compiled on 2021-12-14 23:03:04.

Bringing in the effect sizes

We bring in the per-timepoint estimates of effect size from results/BT642Year2/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,58,59,61,63,70,77,84,91,105,119
## 2                                  21,28,35,42,49,56
## 3                    58,59,61,63,70,77,84,91,105,119
## 4                                           21,28,35
## 5                                           42,49,56
## 6                                        58,59,61,63
## 7                                    70,77,84,91,105
## 8                          65,68,70,77,84,91,105,119
## 9                          65,68,70,77,84,91,105,119
## 10                                       65,68,70,77
## 11                                         84,91,105
##                                     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  58  59  61  63  70  77  84  91 105 119
## 
## Calculating Preflowering.DroughtDiff.DroughtTps with timepoints:
## [1] 21 28 35 42 49 56
## 
## Calculating Preflowering.DroughtDiff.RecoveryTps with timepoints:
##  [1]  58  59  61  63  70  77  84  91 105 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] 58 59 61 63
## 
## Calculating Preflowering.DroughtDiff.LateRecoveryTps with timepoints:
## [1]  70  77  84  91 105
## 
## Calculating Postflowering.DroughtDiff.AllTps with timepoints:
## [1]  65  68  70  77  84  91 105 119
## 
## Calculating Postflowering.DroughtDiff.DroughtTps with timepoints:
## [1]  65  68  70  77  84  91 105 119
## 
## Calculating Postflowering.DroughtDiff.EarlyDroughtTps with timepoints:
## [1] 65 68 70 77
## 
## Calculating Postflowering.DroughtDiff.LateDroughtTps with timepoints:
## [1]  84  91 105
## 
## Calculating Preflowering.DroughtDiff.AllTps with timepoints:
##  [1]  21  28  35  42  49  56  58  59  61  63  70  77  84  91 105 119
## 
## Calculating Preflowering.DroughtDiff.DroughtTps with timepoints:
## [1] 21 28 35 42 49 56
## 
## Calculating Preflowering.DroughtDiff.RecoveryTps with timepoints:
##  [1]  58  59  61  63  70  77  84  91 105 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] 58 59 61 63
## 
## Calculating Preflowering.DroughtDiff.LateRecoveryTps with timepoints:
## [1]  70  77  84  91 105
## 
## Calculating Postflowering.DroughtDiff.AllTps with timepoints:
## [1]  65  68  70  77  84  91 105 119
## 
## Calculating Postflowering.DroughtDiff.DroughtTps with timepoints:
## [1]  65  68  70  77  84  91 105 119
## 
## Calculating Postflowering.DroughtDiff.EarlyDroughtTps with timepoints:
## [1] 65 68 70 77
## 
## Calculating Postflowering.DroughtDiff.LateDroughtTps with timepoints:
## [1]  84  91 105

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

## BT642:
##  Preflowering.AllTps Preflowering.DroughtTps Preflowering.RecoveryTps
##  Min.   :-3.59861    Min.   :-4.47221        Min.   :-3.01621        
##  1st Qu.:-0.28854    1st Qu.:-0.37191        1st Qu.:-0.24741        
##  Median : 0.14173    Median : 0.11409        Median :-0.07312        
##  Mean   : 0.03395    Mean   :-0.01314        Mean   : 0.04371        
##  3rd Qu.: 0.35746    3rd Qu.: 0.36172        3rd Qu.: 0.32004        
##  Max.   : 4.40608    Max.   : 5.99398        Max.   : 3.66345        
##  Preflowering.EarlyDroughtTps Preflowering.LateDroughtTps
##  Min.   :-4.30017             Min.   :-6.04684           
##  1st Qu.:-0.28800             1st Qu.:-0.41904           
##  Median : 0.12101             Median : 0.06461           
##  Mean   : 0.01679             Mean   :-0.03668           
##  3rd Qu.: 0.33785             3rd Qu.: 0.38434           
##  Max.   : 4.37305             Max.   : 8.09346           
##  Preflowering.EarlyRecoveryTps Preflowering.LateRecoveryTps
##  Min.   :-4.64996              Min.   :-1.82140            
##  1st Qu.:-0.30692              1st Qu.:-0.19319            
##  Median : 0.09008              Median :-0.05848            
##  Mean   : 0.04987              Mean   : 0.05683            
##  3rd Qu.: 0.34720              3rd Qu.: 0.27792            
##  Max.   : 4.65205              Max.   : 3.29044            
##  Postflowering.AllTps Postflowering.DroughtTps Postflowering.EarlyDroughtTps
##  Min.   :-4.6909      Min.   :-4.6909          Min.   :-4.00270             
##  1st Qu.:-0.3475      1st Qu.:-0.3475          1st Qu.:-0.33179             
##  Median :-0.1096      Median :-0.1096          Median :-0.09605             
##  Mean   :-0.0818      Mean   :-0.0818          Mean   :-0.06740             
##  3rd Qu.: 0.2506      3rd Qu.: 0.2506          3rd Qu.: 0.25600             
##  Max.   : 6.1626      Max.   : 6.1626          Max.   : 4.79740             
##  Postflowering.LateDroughtTps
##  Min.   :-5.60846            
##  1st Qu.:-0.35031            
##  Median :-0.08746            
##  Mean   :-0.09684            
##  3rd Qu.: 0.22607            
##  Max.   : 7.98292

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.126 0.074 0.021 0.006
Preflowering.DroughtTps 0.177 0.119 0.050 0.022
Preflowering.RecoveryTps 0.104 0.058 0.015 0.004
Preflowering.EarlyDroughtTps 0.132 0.082 0.027 0.009
Preflowering.LateDroughtTps 0.227 0.163 0.079 0.041
Preflowering.EarlyRecoveryTps 0.179 0.125 0.053 0.021
Preflowering.LateRecoveryTps 0.048 0.021 0.004 0.001
Postflowering.AllTps 0.106 0.064 0.022 0.008
Postflowering.DroughtTps 0.106 0.064 0.022 0.008
Postflowering.EarlyDroughtTps 0.100 0.058 0.017 0.006
Postflowering.LateDroughtTps 0.129 0.084 0.034 0.016

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.6552             Min.   :-3.58860      Min.   :-1.1638             
##  1st Qu.:-0.1282             1st Qu.:-0.28752      1st Qu.: 0.1467             
##  Median : 0.2832             Median : 0.14290      Median : 0.2779             
##  Mean   : 0.3507             Mean   : 0.03333      Mean   : 0.3602             
##  3rd Qu.: 0.6064             3rd Qu.: 0.34973      3rd Qu.: 0.4911             
##  Max.   : 8.0935             Max.   : 4.24146      Max.   : 7.9829             
##  Postflowering.MaxOfTps
##  Min.   :-4.32386      
##  1st Qu.:-0.32509      
##  Median :-0.10650      
##  Mean   :-0.07537      
##  3rd Qu.: 0.23603      
##  Max.   : 5.58627

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.18627697    0.12644255      0.05665663
## Preflowering.MaxOfTps             0.11724369    0.06794614      0.01810503
## Postflowering.MaxOfIntervals      0.10210738    0.05895635      0.02015387
## Postflowering.MaxOfTps            0.08659475    0.05113731      0.01626526
##                              % abs(lfc)> 2
## Preflowering.MaxOfIntervals    0.027512962
## Preflowering.MaxOfTps          0.004975748
## Postflowering.MaxOfIntervals   0.007860846
## Postflowering.MaxOfTps         0.005602944

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.14-Group_BT642_Control.14_lfc
## 1                                            -0.13732235
## 2                                            -0.09038904
## 3                                            -0.22072677
## 4                                            -0.10571662
## 5                                             0.50965939
## 6                                             0.22132309
##   Group_BT642_Preflowering.21-Group_BT642_Control.21_lfc
## 1                                             0.18902425
## 2                                            -1.22033150
## 3                                            -0.02397383
## 4                                             0.37420886
## 5                                            -0.24759644
## 6                                            -0.06232791
##   Group_BT642_Preflowering.28-Group_BT642_Control.28_lfc
## 1                                             0.13395870
## 2                                            -1.45509068
## 3                                            -0.07616416
## 4                                             0.35302490
## 5                                            -0.09941595
## 6                                             0.11742406
##   Group_BT642_Preflowering.35-Group_BT642_Control.35_lfc
## 1                                            -0.18508024
## 2                                            -1.41919196
## 3                                            -0.04632292
## 4                                             0.33215802
## 5                                            -0.01372225
## 6                                             0.28895113
## New Results:
##                       Gene Preflowering.DroughtDiff.Day014.BT642_lfc
## 1 SbiBTX642.01G000200.v1.1                               -0.13732235
## 2 SbiBTX642.01G000400.v1.1                               -0.09038904
## 3 SbiBTX642.01G000500.v1.1                               -0.22072677
## 4 SbiBTX642.01G000600.v1.1                               -0.10571662
## 5 SbiBTX642.01G000900.v1.1                                0.50965939
## 6 SbiBTX642.01G001000.v1.1                                0.22132309
##   Preflowering.DroughtDiff.Day021.BT642_lfc
## 1                                0.18902425
## 2                               -1.22033150
## 3                               -0.02397383
## 4                                0.37420886
## 5                               -0.24759644
## 6                               -0.06232791
##   Preflowering.DroughtDiff.Day028.BT642_lfc
## 1                                0.13395870
## 2                               -1.45509068
## 3                               -0.07616416
## 4                                0.35302490
## 5                               -0.09941595
## 6                                0.11742406
##   Preflowering.DroughtDiff.Day035.BT642_lfc
## 1                               -0.18508024
## 2                               -1.41919196
## 3                               -0.04632292
## 4                                0.33215802
## 5                               -0.01372225
## 6                                0.28895113

Saving Results

## Saving effect size of root to results/BT642Year2/data