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
- Thanks @sangyu for making changes in delta-delta documentation and corresponding API signatures.
- Add line breaks for visual effect on tutorial pages.
- Add notes for median difference in the documentation
where :math:`\\overline{x}` is the mean for the group :math:`x`.
454
+
454
455
"""
455
456
returnself.__mean_diff
456
457
@@ -459,7 +460,8 @@ def mean_diff(self):
459
460
defmedian_diff(self):
460
461
"""
461
462
Returns an :py:class:`EffectSizeDataFrame` for the median difference, its confidence interval, and relevant statistics, for all comparisons as indicated via the `idx` and `paired` argument in `dabest.load()`.
Using median difference as the statistic in bootstrapping may result in a biased estimate and cause problems with BCa confidence intervals. Consider using mean difference instead.
498
+
499
+
When plotting, consider using percentile confidence intervals instead of BCa confidence intervals by specifying `ci_type = 'percentile'` in .plot().
500
+
501
+
For detailed information, please refer to `Issue 129 <https://github.com/ACCLAB/DABEST-python/issues/129>`_.
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.
876
+
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
+49-28Lines changed: 49 additions & 28 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,17 +60,33 @@ 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
-
Simulate a dataset
66
-
------------------
65
+
Load Libraries
66
+
--------------
67
67
68
68
.. code-block:: python3
69
69
:linenos:
70
70
71
71
72
72
import numpy as np
73
73
import pandas as pd
74
+
import dabest
75
+
76
+
print("We're using DABEST v{}".format(dabest.__version__))
77
+
78
+
79
+
.. parsed-literal::
80
+
81
+
We're using DABEST v2023.02.14
82
+
83
+
84
+
Simulate a dataset
85
+
------------------
86
+
87
+
.. code-block:: python3
88
+
:linenos:
89
+
74
90
from scipy.stats import norm # Used in generation of populations.
75
91
76
92
np.random.seed(seed) # Fix the seed so the results are replicable.
@@ -83,18 +99,18 @@ Simulate a dataset
83
99
y[N:2*N] = y[N:2*N]+1
84
100
y[2*N:3*N] = y[2*N:3*N]-0.5
85
101
86
-
# Add drug column
102
+
# Add a `Treatment` column
87
103
t1 = np.repeat('Placebo', N*2).tolist()
88
104
t2 = np.repeat('Drug', N*2).tolist()
89
105
treatment = t1 + t2
90
106
91
-
# Add a `rep` column as the first variable for the 2 replicates of experiments done
107
+
# Add a `Rep` column as the first variable for the 2 replicates of experiments done
92
108
rep = []
93
109
for i in range(N*2):
94
110
rep.append('Rep1')
95
111
rep.append('Rep2')
96
112
97
-
# Add a `genotype` column as the second variable
113
+
# Add a `Genotype` column as the second variable
98
114
wt = np.repeat('W', N).tolist()
99
115
mt = np.repeat('M', N).tolist()
100
116
wt2 = np.repeat('W', N).tolist()
@@ -112,7 +128,7 @@ Simulate a dataset
112
128
df_delta2 = pd.DataFrame({'ID' : id_col,
113
129
'Rep' : rep,
114
130
'Genotype' : genotype,
115
-
'Drug': treatment,
131
+
'Treatment': treatment,
116
132
'Y' : y
117
133
})
118
134
@@ -206,8 +222,7 @@ for slopegraphs. We use the ``experiment`` input to specify grouping of the data
206
222
.. code-block:: python3
207
223
:linenos:
208
224
209
-
unpaired_delta2 = dabest.load(data = df_delta2, x = ["Genotype", "Genotype"], y = "Y", delta2 = True,
210
-
experiment = "Drug")
225
+
unpaired_delta2 = dabest.load(data = df_delta2, x = ["Genotype", "Genotype"], y = "Y", delta2 = True, experiment = "Treatment")
211
226
212
227
The above function creates the following object:
213
228
@@ -279,26 +294,31 @@ administered, the mutant phenotype is around 1.23 [95%CI 0.948, 1.52]. This diff
279
294
and ``Drug`` group are plotted at the right bottom with a separate y-axis from other bootstrap plots.
280
295
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
296
297
+
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
318
300
319
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.
320
+
Specifying Grouping for Comparisons
321
+
-----------------------------------
302
322
303
323
304
324
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 +354,29 @@ We produce the following plot:
334
354
335
355
.. image:: _images/tutorial_108_0.png
336
356
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.
338
-
339
-
.. math::
357
+
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.
375
+
.. math::
358
376
377
+
\Delta_{\Delta} = \Delta_{2} - \Delta_{1}
378
+
379
+
where :math:`\overline{X}` is the sample mean, :math:`\Delta` is the mean difference.
Copy file name to clipboardExpand all lines: docs/source/proportion-plot.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -411,7 +411,7 @@ Repeated measures is also supported in paired proportional plot, by changing the
411
411
412
412
.. image:: _images/sankey_4.png
413
413
414
-
From the above two images, we can see that the on both the observed value plot and delta plot, the pairs compared are different in terms of the paired settings.
414
+
From the above two images, we can see that the on both the observed value plot and delta plot, the pairs compared are different in terms of the paired settings. And for detailed information about repeated measures, please refer to :doc:`repeatedmeasures` .
415
415
416
416
If you want to specify the order of the groups, you can use the ``idx`` parameter in the ``.load()`` method.
0 commit comments