This document has last been compiled on 2021-12-14 21:29:20.

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.   :-4.05692    Min.   :-7.01656        Min.   :-2.36734        
##  1st Qu.:-0.40124    1st Qu.:-0.51697        1st Qu.:-0.25495        
##  Median : 0.10268    Median : 0.14858        Median :-0.10586        
##  Mean   :-0.02226    Mean   :-0.03248        Mean   : 0.01977        
##  3rd Qu.: 0.38114    3rd Qu.: 0.50834        3rd Qu.: 0.29251        
##  Max.   : 4.58114    Max.   : 6.88280        Max.   : 3.17514        
##  Preflowering.EarlyDroughtTps Preflowering.LateDroughtTps
##  Min.   :-5.54893             Min.   :-8.48419           
##  1st Qu.:-0.40809             1st Qu.:-0.59711           
##  Median : 0.08132             Median : 0.16266           
##  Mean   :-0.04711             Mean   :-0.01993           
##  3rd Qu.: 0.37245             3rd Qu.: 0.64444           
##  Max.   : 4.27746             Max.   :10.44359           
##  Preflowering.EarlyRecoveryTps Preflowering.LateRecoveryTps
##  Min.   :-4.52421              Min.   :-2.18482            
##  1st Qu.:-0.32977              1st Qu.:-0.24306            
##  Median :-0.02848              Median :-0.10277            
##  Mean   : 0.04394              Mean   : 0.01034            
##  3rd Qu.: 0.32921              3rd Qu.: 0.26423            
##  Max.   : 8.09417              Max.   : 3.01822            
##  Postflowering.AllTps Postflowering.DroughtTps Postflowering.EarlyDroughtTps
##  Min.   :-5.4507      Min.   :-5.4507          Min.   :-5.8952              
##  1st Qu.:-0.4243      1st Qu.:-0.4243          1st Qu.:-0.4176              
##  Median :-0.1487      Median :-0.1487          Median :-0.1185              
##  Mean   :-0.1056      Mean   :-0.1056          Mean   :-0.1260              
##  3rd Qu.: 0.2807      3rd Qu.: 0.2807          3rd Qu.: 0.2514              
##  Max.   : 8.4231      Max.   : 8.4231          Max.   : 6.9808              
##  Postflowering.LateDroughtTps
##  Min.   :-5.82236            
##  1st Qu.:-0.41816            
##  Median :-0.12860            
##  Mean   :-0.09769            
##  3rd Qu.: 0.28035            
##  Max.   : 9.00007

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.145 0.084 0.025 0.009
Preflowering.DroughtTps 0.288 0.197 0.090 0.045
Preflowering.RecoveryTps 0.056 0.028 0.006 0.002
Preflowering.EarlyDroughtTps 0.162 0.100 0.039 0.016
Preflowering.LateDroughtTps 0.392 0.297 0.157 0.091
Preflowering.EarlyRecoveryTps 0.172 0.117 0.053 0.025
Preflowering.LateRecoveryTps 0.045 0.023 0.004 0.001
Postflowering.AllTps 0.163 0.109 0.045 0.021
Postflowering.DroughtTps 0.163 0.109 0.045 0.021
Postflowering.EarlyDroughtTps 0.174 0.119 0.052 0.025
Postflowering.LateDroughtTps 0.168 0.114 0.048 0.023

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.   :-3.2108             Min.   :-4.05692      Min.   :-1.5219             
##  1st Qu.:-0.1825             1st Qu.:-0.40124      1st Qu.: 0.1522             
##  Median : 0.3109             Median : 0.10268      Median : 0.3065             
##  Mean   : 0.4014             Mean   :-0.02226      Mean   : 0.4210             
##  3rd Qu.: 0.7722             3rd Qu.: 0.38114      3rd Qu.: 0.5715             
##  Max.   :10.4436             Max.   : 4.58114      Max.   : 9.0001             
##  Postflowering.MaxOfTps
##  Min.   :-4.90159      
##  1st Qu.:-0.39321      
##  Median :-0.14161      
##  Mean   :-0.09454      
##  3rd Qu.: 0.26485      
##  Max.   : 7.48629

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.2641661    0.18215724      0.07717737
## Preflowering.MaxOfTps              0.1450731    0.08417038      0.02462386
## Postflowering.MaxOfIntervals       0.1474889    0.09747828      0.03933037
## Postflowering.MaxOfTps             0.1371053    0.08832380      0.03454122
##                              % abs(lfc)> 2
## Preflowering.MaxOfIntervals    0.038906548
## Preflowering.MaxOfTps          0.008518754
## Postflowering.MaxOfIntervals   0.019071837
## Postflowering.MaxOfTps         0.015554143

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.267561814
## 2                                           -1.504138472
## 3                                           -0.294787495
## 4                                            0.041175164
## 5                                           -0.134611926
## 6                                            0.005258692
##   Group_BT642_Preflowering.28-Group_BT642_Control.28_lfc
## 1                                              0.1200759
## 2                                             -1.1899172
## 3                                              0.1309807
## 4                                              0.3652592
## 5                                              0.1414112
## 6                                              0.7346877
##   Group_BT642_Preflowering.35-Group_BT642_Control.35_lfc
## 1                                            -0.22837952
## 2                                            -2.12176667
## 3                                             0.09343724
## 4                                             0.34627350
## 5                                             0.25925718
## 6                                             0.50025576
##   Group_BT642_Preflowering.42-Group_BT642_Control.42_lfc
## 1                                            -0.09947957
## 2                                            -2.32355992
## 3                                            -0.03025091
## 4                                             0.55124349
## 5                                             0.43574905
## 6                                             0.81308655
## New Results:
##                       Gene Preflowering.DroughtDiff.Day021.BT642_lfc
## 1 SbiBTX642.01G000200.v1.1                              -0.267561814
## 2 SbiBTX642.01G000400.v1.1                              -1.504138472
## 3 SbiBTX642.01G000500.v1.1                              -0.294787495
## 4 SbiBTX642.01G000600.v1.1                               0.041175164
## 5 SbiBTX642.01G000900.v1.1                              -0.134611926
## 6 SbiBTX642.01G001000.v1.1                               0.005258692
##   Preflowering.DroughtDiff.Day028.BT642_lfc
## 1                                 0.1200759
## 2                                -1.1899172
## 3                                 0.1309807
## 4                                 0.3652592
## 5                                 0.1414112
## 6                                 0.7346877
##   Preflowering.DroughtDiff.Day035.BT642_lfc
## 1                               -0.22837952
## 2                               -2.12176667
## 3                                0.09343724
## 4                                0.34627350
## 5                                0.25925718
## 6                                0.50025576
##   Preflowering.DroughtDiff.Day042.BT642_lfc
## 1                               -0.09947957
## 2                               -2.32355992
## 3                               -0.03025091
## 4                                0.55124349
## 5                                0.43574905
## 6                                0.81308655

Saving Results

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