Skip to content

Commit 0d37155

Browse files
committed
Delta-Delta Tests and Docs
1. added doc string to class DeltaDelta and corrected typos 2. changed delta-delta tests and utils.py to mutant-drug configuration 3. generated test images for delta-delta tests 4. added tutorial page deltadelta.rst to include calculations and example plots 5. modified index.rst to include deltadelta 6. modified api.rst to include deltadelta 7. updated tutorial images for deltadelta
1 parent 3faa92d commit 0d37155

24 files changed

+536
-36
lines changed

dabest/_classes.py

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,65 @@ def _all_plot_groups(self):
857857

858858
class DeltaDelta(object):
859859
"""
860-
A class to compute and store the delta-delta statistics.
860+
A class to compute and store the delta-delta statistics. In a 2-by-2 arrangement where two independent variables, A and B, each have two categorical values, two primary deltas are first calculated with one independent variable and a delta-delta effect size is calculated as a difference between the two primary deltas.
861+
862+
.. math::
863+
864+
\\hat{\\theta}_{B1} = \\overline{X}_{A2, B1} - \\overline{X}_{A1, B1}
865+
866+
\\hat{\\theta}_{B2} = \\overline{X}_{A2, B2} - \\overline{X}_{A1, B2}
867+
868+
.. math::
869+
870+
\\hat{\\theta}_{\\theta} = \\hat{\\theta}_{B2} - \\hat{\\theta}_{B1}
871+
872+
and:
873+
874+
.. math::
875+
876+
s_{\\theta} = \\frac{(n_{A2, B1}-1)s_{A2, B1}^2+(n_{A1, B1}-1)s_{A1, B1}^2+(n_{A2, B2}-1)s_{A2, B2}^2+(n_{A1, B2}-1)s_{A1, B2}^2}{(n_{A2, B1} - 1) + (n_{A1, B1} - 1) + (n_{A2, B2} - 1) + (n_{A1, B2} - 1)}
877+
878+
Example
879+
-------
880+
>>> import numpy as np
881+
>>> import pandas as pd
882+
>>> from scipy.stats import norm # Used in generation of populations.
883+
>>> np.random.seed(9999) # Fix the seed so the results are replicable.
884+
>>> from scipy.stats import norm # Used in generation of populations.
885+
>>> N = 20
886+
>>> # Create samples
887+
>>> y = norm.rvs(loc=3, scale=0.4, size=N*4)
888+
>>> y[N:2*N] = y[N:2*N]+1
889+
>>> y[2*N:3*N] = y[2*N:3*N]-0.5
890+
>>> # Add drug column
891+
>>> t1 = np.repeat('Placebo', N*2).tolist()
892+
>>> t2 = np.repeat('Drug', N*2).tolist()
893+
>>> treatment = t1 + t2
894+
>>> # Add a `rep` column as the first variable for the 2 replicates of experiments done
895+
>>> rep = []
896+
>>> for i in range(N*2):
897+
>>> rep.append('Rep1')
898+
>>> rep.append('Rep2')
899+
>>> # Add a `genotype` column as the second variable
900+
>>> wt = np.repeat('W', N).tolist()
901+
>>> mt = np.repeat('M', N).tolist()
902+
>>> wt2 = np.repeat('W', N).tolist()
903+
>>> mt2 = np.repeat('M', N).tolist()
904+
>>> genotype = wt + mt + wt2 + mt2
905+
>>> # Add an `id` column for paired data plotting.
906+
>>> id = list(range(0, N*2))
907+
>>> id_col = id + id
908+
>>> # Combine all columns into a DataFrame.
909+
>>> df_delta2 = pd.DataFrame({'ID' : id_col,
910+
>>> 'Rep' : rep,
911+
>>> 'Genotype' : genotype,
912+
>>> 'Drug': treatment,
913+
>>> 'Y' : y
914+
>>> })
915+
916+
917+
918+
861919
"""
862920

863921
def __init__(self, effectsizedataframe, permutation_count,
@@ -1014,8 +1072,8 @@ def __repr__(self, header=True, sigfig=3):
10141072
bs2 = "the confidence interval is bias-corrected and accelerated."
10151073
bs = bs1 + bs2
10161074

1017-
pval_def1 = "Any p-value reported is the probability of observing the" + \
1018-
"effect size (or greater),\nassuming the null hypothesis of" + \
1075+
pval_def1 = "Any p-value reported is the probability of observing the " + \
1076+
"effect size (or greater),\nassuming the null hypothesis of " + \
10191077
"zero difference is true."
10201078
pval_def2 = "\nFor each p-value, 5000 reshuffles of the " + \
10211079
"control and test labels were performed."
5.28 KB
Loading
6.06 KB
Loading
6.06 KB
Loading
6.69 KB
Loading
6.07 KB
Loading
50.6 KB
Loading
4.09 KB
Loading
6.22 KB
Loading
6.95 KB
Loading

0 commit comments

Comments
 (0)