You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dabest/_classes.py
+20-10Lines changed: 20 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -857,23 +857,31 @@ def _all_plot_groups(self):
857
857
858
858
classDeltaDelta(object):
859
859
"""
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.
860
+
A class to compute and store the delta-delta statistics for experiments with a 2-by-2 arrangement where two independent variables, A and B, each have two categorical values, 1 and 2. The data is divided into two pairs of two groups, and a primary deltais first calculated as the mean difference between each of the pairs:
Copy file name to clipboardExpand all lines: docs/source/deltadelta.rst
+31-26Lines changed: 31 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ Effectively, we have 4 groups of subjects for comparison.
35
35
<thead>
36
36
<trstyle="text-align: right;">
37
37
<th></th>
38
-
<th>Wildtype</th>
38
+
<th>Wild type</th>
39
39
<th>Mutant</th>
40
40
</tr>
41
41
</thead>
@@ -60,7 +60,7 @@ Effectively, we have 4 groups of subjects for comparison.
60
60
</div>
61
61
62
62
63
-
There are 2 ``Treatment`` conditions, ``Placebo`` (control group) and ``Drug`` (test group). There are 2 ``Genotype``s: ``W`` (wildtype population) and ``M`` (mutant population). In addition, each experiment was done twice (``Rep1`` and ``Rep2``). We shall do a few analyses to visualise these differences in a simulated dataset.
63
+
There are 2 ``Treatment`` conditions, ``Placebo`` (control group) and ``Drug`` (test group). There are 2 ``Genotype``\s: ``W`` (wild type population) and ``M`` (mutant population). In addition, each experiment was done twice (``Rep1`` and ``Rep2``). We shall do a few analyses to visualise these differences in a simulated dataset.
64
64
65
65
Simulate a dataset
66
66
------------------
@@ -83,18 +83,18 @@ Simulate a dataset
83
83
y[N:2*N] = y[N:2*N]+1
84
84
y[2*N:3*N] = y[2*N:3*N]-0.5
85
85
86
-
# Add drug column
86
+
# Add a `Treatment` column
87
87
t1 = np.repeat('Placebo', N*2).tolist()
88
88
t2 = np.repeat('Drug', N*2).tolist()
89
89
treatment = t1 + t2
90
90
91
-
# Add a `rep` column as the first variable for the 2 replicates of experiments done
91
+
# Add a `Rep` column as the first variable for the 2 replicates of experiments done
92
92
rep = []
93
93
for i in range(N*2):
94
94
rep.append('Rep1')
95
95
rep.append('Rep2')
96
96
97
-
# Add a `genotype` column as the second variable
97
+
# Add a `Genotype` column as the second variable
98
98
wt = np.repeat('W', N).tolist()
99
99
mt = np.repeat('M', N).tolist()
100
100
wt2 = np.repeat('W', N).tolist()
@@ -112,7 +112,7 @@ Simulate a dataset
112
112
df_delta2 = pd.DataFrame({'ID' : id_col,
113
113
'Rep' : rep,
114
114
'Genotype' : genotype,
115
-
'Drug': treatment,
115
+
'Treatment': treatment,
116
116
'Y' : y
117
117
})
118
118
@@ -206,8 +206,7 @@ for slopegraphs. We use the ``experiment`` input to specify grouping of the data
206
206
.. code-block:: python3
207
207
:linenos:
208
208
209
-
unpaired_delta2 = dabest.load(data = df_delta2, x = ["Genotype", "Genotype"], y = "Y", delta2 = True,
210
-
experiment = "Drug")
209
+
unpaired_delta2 = dabest.load(data = df_delta2, x = ["Genotype", "Genotype"], y = "Y", delta2 = True, experiment = "Treatment")
211
210
212
211
The above function creates the following object:
213
212
@@ -279,26 +278,31 @@ administered, the mutant phenotype is around 1.23 [95%CI 0.948, 1.52]. This diff
279
278
and ``Drug`` group are plotted at the right bottom with a separate y-axis from other bootstrap plots.
280
279
This effect size, at about -0.903 [95%CI -1.26, -0.535], is the net effect size of the drug treatment. That is to say that treatment with drug A reduced disease phenotype by 0.903.
281
280
281
+
Mean difference between mutants and wild types given the placebo treatment is:
where :math:`\overline{X}` is the sample mean, :math:`\Delta` is the mean difference.
299
302
300
303
301
-
where :math:`\overline{X}` is the sample mean, :math:`\hat{\theta}` is the mean difference, :math:`s` is the variance and :math:`n` is the sample size.
304
+
Specifying Grouping for Comparisons
305
+
-----------------------------------
302
306
303
307
304
308
In the example above, we used the convention of "test - control' but you can manipulate the orders of experiment groups as well as the horizontal axis variable by setting ``experiment_label`` and ``x1_level``.
@@ -334,28 +338,29 @@ We produce the following plot:
334
338
335
339
.. image:: _images/tutorial_108_0.png
336
340
337
-
We see that the drug had a non-specific effect of -0.321 [95%CI -0.498, -0.131] on wildtype subjects even when they were not sick, and it had a bigger effect of -1.22 [95%CI -1.52, -0.906] in mutant subjects. In this visualisation, we can see the delta-delta value of -0.903 [95%CI -1.21, -0.587] as the net effect of the drug accounting for non-specific actions in healthy individuals.
341
+
We see that the drug had a non-specific effect of -0.321 [95%CI -0.498, -0.131] on wild type subjects even when they were not sick, and it had a bigger effect of -1.22 [95%CI -1.52, -0.906] in mutant subjects. In this visualisation, we can see the delta-delta value of -0.903 [95%CI -1.21, -0.587] as the net effect of the drug accounting for non-specific actions in healthy individuals.
where :math:`\overline{X}` is the sample mean, :math:`\hat{\theta}` is the mean difference, :math:`s` is the variance and :math:`n` is the sample size.
359
+
.. math::
358
360
361
+
\Delta_{\Delta} = \Delta_{2} - \Delta_{1}
362
+
363
+
where :math:`\overline{X}` is the sample mean, :math:`\Delta` is the mean difference.
0 commit comments