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

Bringing in the effect sizes

We bring in the per-timepoint estimates of effect size from results/RT430Year1/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:

## RT430:
##  Preflowering.AllTps Preflowering.DroughtTps Preflowering.RecoveryTps
##  Min.   :-2.27331    Min.   :-2.50211        Min.   :-2.31196        
##  1st Qu.:-0.26736    1st Qu.:-0.25376        1st Qu.:-0.26699        
##  Median : 0.12278    Median : 0.13576        Median :-0.12803        
##  Mean   : 0.01439    Mean   : 0.04416        Mean   :-0.02043        
##  3rd Qu.: 0.30045    3rd Qu.: 0.32470        3rd Qu.: 0.25880        
##  Max.   : 3.09563    Max.   : 5.05862        Max.   : 3.01929        
##  Preflowering.EarlyDroughtTps Preflowering.LateDroughtTps
##  Min.   :-2.15567             Min.   :-3.83773           
##  1st Qu.:-0.23423             1st Qu.:-0.24889           
##  Median : 0.06235             Median : 0.13960           
##  Mean   : 0.01924             Mean   : 0.06378           
##  3rd Qu.: 0.26441             3rd Qu.: 0.37085           
##  Max.   : 3.65673             Max.   : 6.83733           
##  Preflowering.EarlyRecoveryTps Preflowering.LateRecoveryTps
##  Min.   :-5.162568             Min.   :-2.30006            
##  1st Qu.:-0.214840             1st Qu.:-0.27185            
##  Median :-0.018195             Median :-0.12659            
##  Mean   :-0.004369             Mean   :-0.02239            
##  3rd Qu.: 0.206395             3rd Qu.: 0.25730            
##  Max.   : 5.028739             Max.   : 2.86813            
##  Postflowering.AllTps Postflowering.DroughtTps Postflowering.EarlyDroughtTps
##  Min.   :-6.02712     Min.   :-6.02712         Min.   :-5.19138             
##  1st Qu.:-0.33849     1st Qu.:-0.33849         1st Qu.:-0.31631             
##  Median : 0.15410     Median : 0.15410         Median : 0.10623             
##  Mean   : 0.03761     Mean   : 0.03761         Mean   : 0.03137             
##  3rd Qu.: 0.40497     3rd Qu.: 0.40497         3rd Qu.: 0.36566             
##  Max.   : 7.39281     Max.   : 7.39281         Max.   : 7.93718             
##  Postflowering.LateDroughtTps
##  Min.   :-6.36142            
##  1st Qu.:-0.33977            
##  Median : 0.15040            
##  Mean   : 0.03992            
##  3rd Qu.: 0.42152            
##  Max.   : 7.30609

And the percentage of genes past certain quantiles:

Proportion absolute lfc greater in RT430:

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:

## RT430:
##  Preflowering.MaxOfIntervals Preflowering.MaxOfTps Postflowering.MaxOfIntervals
##  Min.   :-2.2948             Min.   :-2.27331      Min.   :-1.4633             
##  1st Qu.:-0.1580             1st Qu.:-0.26736      1st Qu.: 0.2019             
##  Median : 0.2349             Median : 0.12278      Median : 0.3747             
##  Mean   : 0.2333             Mean   : 0.01439      Mean   : 0.5090             
##  3rd Qu.: 0.4833             3rd Qu.: 0.30045      3rd Qu.: 0.6566             
##  Max.   : 6.8373             Max.   : 3.09563      Max.   : 7.9372             
##  Postflowering.MaxOfTps
##  Min.   :-5.32109      
##  1st Qu.:-0.31659      
##  Median : 0.14431      
##  Mean   : 0.03425      
##  3rd Qu.: 0.37324      
##  Max.   : 6.52488

And the percentage of genes past certain quantiles:

## Proportion absolute lfc greater in RT430:
##                              % abs(lfc)> 0.8 % abs(lfc)> 1 % abs(lfc)> 1.5
## Preflowering.MaxOfIntervals       0.10479246    0.06143676     0.020900165
## Preflowering.MaxOfTps             0.04184894    0.01793526     0.002867697
## Postflowering.MaxOfIntervals      0.18392145    0.12267911     0.053416934
## Postflowering.MaxOfTps            0.15218237    0.10114708     0.041265675
##                              % abs(lfc)> 2
## Preflowering.MaxOfIntervals   0.0088947215
## Preflowering.MaxOfTps         0.0007776806
## Postflowering.MaxOfIntervals  0.0257606688
## Postflowering.MaxOfTps        0.0174492077

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 SbiRTX430.01G000100.v2.1
## 2 SbiRTX430.01G000400.v2.1
## 3 SbiRTX430.01G000500.v2.1
## 4 SbiRTX430.01G000600.v2.1
## 5 SbiRTX430.01G000700.v2.1
## 6 SbiRTX430.01G000800.v2.1
##   Group_RT430_Preflowering.21-Group_RT430_Control.21_lfc
## 1                                            0.002702611
## 2                                           -0.130199555
## 3                                           -0.115708183
## 4                                           -0.201466792
## 5                                            0.080686168
## 6                                           -0.416653960
##   Group_RT430_Preflowering.28-Group_RT430_Control.28_lfc
## 1                                            -0.17014893
## 2                                            -0.08157379
## 3                                             0.71014822
## 4                                            -0.09233357
## 5                                            -0.06750295
## 6                                            -0.14693060
##   Group_RT430_Preflowering.35-Group_RT430_Control.35_lfc
## 1                                            -0.39787291
## 2                                            -0.14957304
## 3                                             0.59020287
## 4                                            -0.04681155
## 5                                            -0.13962573
## 6                                            -0.06249736
##   Group_RT430_Preflowering.42-Group_RT430_Control.42_lfc
## 1                                           -0.364381698
## 2                                           -0.041330386
## 3                                            0.493428514
## 4                                            0.418867410
## 5                                           -0.005431416
## 6                                           -0.640634403
## New Results:
##                       Gene Preflowering.DroughtDiff.Day021.RT430_lfc
## 1 SbiRTX430.01G000100.v2.1                               0.002702611
## 2 SbiRTX430.01G000400.v2.1                              -0.130199555
## 3 SbiRTX430.01G000500.v2.1                              -0.115708183
## 4 SbiRTX430.01G000600.v2.1                              -0.201466792
## 5 SbiRTX430.01G000700.v2.1                               0.080686168
## 6 SbiRTX430.01G000800.v2.1                              -0.416653960
##   Preflowering.DroughtDiff.Day028.RT430_lfc
## 1                               -0.17014893
## 2                               -0.08157379
## 3                                0.71014822
## 4                               -0.09233357
## 5                               -0.06750295
## 6                               -0.14693060
##   Preflowering.DroughtDiff.Day035.RT430_lfc
## 1                               -0.39787291
## 2                               -0.14957304
## 3                                0.59020287
## 4                               -0.04681155
## 5                               -0.13962573
## 6                               -0.06249736
##   Preflowering.DroughtDiff.Day042.RT430_lfc
## 1                              -0.364381698
## 2                              -0.041330386
## 3                               0.493428514
## 4                               0.418867410
## 5                              -0.005431416
## 6                              -0.640634403

Saving Results

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