This document has last been compiled on 2021-12-14 23:02:18.

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.   :-1.95135    Min.   :-3.16097        Min.   :-1.80069        
##  1st Qu.:-0.22028    1st Qu.:-0.21449        1st Qu.:-0.21573        
##  Median : 0.12737    Median : 0.10842        Median : 0.09644        
##  Mean   : 0.02621    Mean   : 0.02011        Mean   : 0.02391        
##  3rd Qu.: 0.26998    3rd Qu.: 0.25420        3rd Qu.: 0.26510        
##  Max.   : 3.34303    Max.   : 3.93511        Max.   : 4.10458        
##  Preflowering.EarlyDroughtTps Preflowering.LateDroughtTps
##  Min.   :-1.85560             Min.   :-5.36178           
##  1st Qu.:-0.15399             1st Qu.:-0.24574           
##  Median : 0.08486             Median : 0.09840           
##  Mean   : 0.02191             Mean   : 0.02017           
##  3rd Qu.: 0.20872             3rd Qu.: 0.29395           
##  Max.   : 2.80471             Max.   : 6.00853           
##  Preflowering.EarlyRecoveryTps Preflowering.LateRecoveryTps
##  Min.   :-2.44527              Min.   :-2.33530            
##  1st Qu.:-0.22800              1st Qu.:-0.19763            
##  Median : 0.07992              Median : 0.08207            
##  Mean   : 0.03906              Mean   : 0.01348            
##  3rd Qu.: 0.29726              3rd Qu.: 0.22193            
##  Max.   : 6.38625              Max.   : 2.27924            
##  Postflowering.AllTps Postflowering.DroughtTps Postflowering.EarlyDroughtTps
##  Min.   :-2.43647     Min.   :-2.43647         Min.   :-2.12140             
##  1st Qu.:-0.22518     1st Qu.:-0.22518         1st Qu.:-0.22653             
##  Median : 0.11797     Median : 0.11797         Median : 0.07260             
##  Mean   : 0.01971     Mean   : 0.01971         Mean   : 0.00479             
##  3rd Qu.: 0.25560     3rd Qu.: 0.25560         3rd Qu.: 0.22856             
##  Max.   : 2.69125     Max.   : 2.69125         Max.   : 2.07060             
##  Postflowering.LateDroughtTps
##  Min.   :-3.40467            
##  1st Qu.:-0.20471            
##  Median : 0.09637            
##  Mean   : 0.02536            
##  3rd Qu.: 0.26326            
##  Max.   : 4.56674

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.039 0.016 0.003 0.001
Preflowering.DroughtTps 0.065 0.037 0.010 0.004
Preflowering.RecoveryTps 0.035 0.015 0.001 0.000
Preflowering.EarlyDroughtTps 0.027 0.012 0.002 0.000
Preflowering.LateDroughtTps 0.123 0.080 0.031 0.013
Preflowering.EarlyRecoveryTps 0.071 0.039 0.008 0.002
Preflowering.LateRecoveryTps 0.025 0.011 0.001 0.000
Postflowering.AllTps 0.046 0.020 0.003 0.000
Postflowering.DroughtTps 0.046 0.020 0.003 0.000
Postflowering.EarlyDroughtTps 0.044 0.023 0.003 0.000
Postflowering.LateDroughtTps 0.068 0.039 0.012 0.004

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.0051             Min.   :-1.91741      Min.   :-1.2958             
##  1st Qu.:-0.1283             1st Qu.:-0.23232      1st Qu.: 0.1185             
##  Median : 0.2114             Median : 0.13078      Median : 0.2234             
##  Mean   : 0.2210             Mean   : 0.02515      Mean   : 0.2600             
##  3rd Qu.: 0.4329             3rd Qu.: 0.26848      3rd Qu.: 0.3800             
##  Max.   : 6.3863             Max.   : 3.29291      Max.   : 4.5667             
##  Postflowering.MaxOfTps
##  Min.   :-2.18020      
##  1st Qu.:-0.21415      
##  Median : 0.11478      
##  Mean   : 0.01903      
##  3rd Qu.: 0.24033      
##  Max.   : 2.40315

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.08813850    0.05130517     0.018529372
## Preflowering.MaxOfTps             0.03732925    0.01559894     0.001983680
## Postflowering.MaxOfIntervals      0.05536270    0.02966503     0.007709301
## Postflowering.MaxOfTps            0.03354222    0.01343492     0.001577927
##                              % abs(lfc)> 2
## Preflowering.MaxOfIntervals   0.0089265588
## Preflowering.MaxOfTps         0.0004508363
## Postflowering.MaxOfIntervals  0.0023443488
## Postflowering.MaxOfTps        0.0001352509

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.32922021
## 2                                            -0.13809515
## 3                                             0.06978366
## 4                                            -0.10575986
## 5                                             0.51066268
## 6                                            -0.38090674
##   Group_BT642_Preflowering.21-Group_BT642_Control.21_lfc
## 1                                            -0.03194629
## 2                                            -0.05153193
## 3                                             0.09017570
## 4                                             0.19528515
## 5                                            -0.05285240
## 6                                             0.17528786
##   Group_BT642_Preflowering.28-Group_BT642_Control.28_lfc
## 1                                             0.12276457
## 2                                             0.02282030
## 3                                             0.30448831
## 4                                             0.05886799
## 5                                            -0.43267686
## 6                                             0.42426820
##   Group_BT642_Preflowering.35-Group_BT642_Control.35_lfc
## 1                                             0.13824141
## 2                                             0.08323607
## 3                                             0.20036085
## 4                                            -0.20263296
## 5                                             0.31501471
## 6                                             0.39168501
## New Results:
##                       Gene Preflowering.DroughtDiff.Day014.BT642_lfc
## 1 SbiBTX642.01G000200.v1.1                                0.32922021
## 2 SbiBTX642.01G000400.v1.1                               -0.13809515
## 3 SbiBTX642.01G000500.v1.1                                0.06978366
## 4 SbiBTX642.01G000600.v1.1                               -0.10575986
## 5 SbiBTX642.01G000900.v1.1                                0.51066268
## 6 SbiBTX642.01G001000.v1.1                               -0.38090674
##   Preflowering.DroughtDiff.Day021.BT642_lfc
## 1                               -0.03194629
## 2                               -0.05153193
## 3                                0.09017570
## 4                                0.19528515
## 5                               -0.05285240
## 6                                0.17528786
##   Preflowering.DroughtDiff.Day028.BT642_lfc
## 1                                0.12276457
## 2                                0.02282030
## 3                                0.30448831
## 4                                0.05886799
## 5                               -0.43267686
## 6                                0.42426820
##   Preflowering.DroughtDiff.Day035.BT642_lfc
## 1                                0.13824141
## 2                                0.08323607
## 3                                0.20036085
## 4                               -0.20263296
## 5                                0.31501471
## 6                                0.39168501

Saving Results

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