|
5 | 5 | "id": "cf1612f8", |
6 | 6 | "metadata": {}, |
7 | 7 | "source": [ |
8 | | - "# Delta - Delta\n", |
| 8 | + "# Delta-Delta\n", |
9 | 9 | "\n", |
10 | 10 | "> Explanation of how to calculate delta-delta using DABEST.\n", |
11 | 11 | "\n", |
|
17 | 17 | "id": "cfdb7e31", |
18 | 18 | "metadata": {}, |
19 | 19 | "source": [ |
20 | | - "Since version 2023.02.14, DABEST also supports the calculation of delta-delta, an experimental function that enables the comparison between two bootstrapped effect sizes computed from two independent categorical variables. \n", |
| 20 | + "Since version 2023.02.14, DABEST also supports the calculation of delta-delta, an experimental function that facilitates the comparison between two bootstrapped effect sizes computed from two independent categorical variables. \n", |
21 | 21 | "\n", |
22 | | - "Many experimental designs investigate the effects of two interacting independent variables on a dependent variable. The delta-delta effect size lets us distill the net effect of the two variables. To illustrate this, let's explore the following problem. \n", |
| 22 | + "Many experimental designs investigate the effects of two interacting independent variables on a dependent variable. The delta-delta effect size enables us distill the net effect of the two variables. To illustrate this, let's explore the following problem. \n", |
23 | 23 | "\n", |
24 | | - "Consider an experiment where we test the efficacy of a drug named ``Drug`` on a disease-causing mutation ``M`` based on disease metric ``Y``. The greater value ``Y`` has the more severe the disease phenotype is. Phenotype ``Y`` has been shown to be caused by a gain of function mutation ``M``, so we expect a difference between wild type (``W``) subjects and mutant subjects (``M``). Now, we want to know whether this effect is ameliorated by the administration of ``Drug`` treatment. We also administer a placebo as a control. In theory, we only expect ``Drug`` to have an effect on the ``M`` group, although in practice many drugs have non-specific effects on healthy populations too.\n", |
| 24 | + "Consider an experiment where we test the efficacy of a drug named ``Drug`` on a disease-causing mutation ``M`` based on disease metric ``Y``. The greater the value ``Y`` has, the more severe the disease phenotype is. Phenotype ``Y`` has been shown to be caused by a gain-of-function mutation ``M``, so we expect a difference between wild type (``W``) subjects and mutant subjects (``M``). Now, we want to know whether this effect is ameliorated by the administration of ``Drug`` treatment. We also administer a placebo as a control. In theory, we only expect ``Drug`` to have an effect on the ``M`` group, although in practice, many drugs have non-specific effects on healthy populations too.\n", |
25 | 25 | "\n", |
26 | 26 | "Effectively, we have four groups of subjects for comparison." |
27 | 27 | ] |
|
243 | 243 | "id": "f4315e6f", |
244 | 244 | "metadata": {}, |
245 | 245 | "source": [ |
246 | | - "To make a delta-delta plot, you need to simply set ``delta2 = True`` in the \n", |
247 | | - "``dabest.load()`` function. However, here ``x`` needs to be declared as a list\n", |
248 | | - "consisting of 2 elements rather than 1 in most of the cases. The first element\n", |
249 | | - "in ``x`` will be the variable plotted along the horizontal axis, and the second\n", |
250 | | - "one will determine the colour of dots for scattered plots or the colour of lines\n", |
251 | | - "for slopegraphs. We use the ``experiment`` input to specify grouping of the data.\n" |
| 246 | + "To create a delta-delta plot, you simply need to set ``delta2=True`` in the \n", |
| 247 | + "``dabest.load()`` function. However, in this case,``x`` needs to be declared as a list consisting of 2 elements, unlike most cases where it is a single element. The first element in ``x`` will represent the variable plotted along the horizontal axis, and the second one will determine the color of dots for scattered plots or the color of lines for slope graphs. We use the ``experiment`` input to specify the grouping of the data." |
252 | 248 | ] |
253 | 249 | }, |
254 | 250 | { |
|
386 | 382 | "and ``Drug`` group are plotted at the right bottom with a separate y-axis from other bootstrap plots. \n", |
387 | 383 | "This effect size, at about -0.903 [95%CI -1.28, -0.513], is the net effect size of the drug treatment. That is to say that treatment with drug A reduced disease phenotype by 0.903.\n", |
388 | 384 | "\n", |
389 | | - "Mean difference between mutants and wild types given the placebo treatment is:\n", |
| 385 | + "The mean difference between mutants and wild types given the placebo treatment is:\n", |
390 | 386 | "\n", |
391 | 387 | "$\\Delta_{1} = \\overline{X}_{P, M} - \\overline{X}_{P, W}$\n", |
392 | 388 | "\n", |
393 | | - "Mean difference between mutants and wild types given the drug treatment is:\n", |
| 389 | + "The mean difference between mutants and wild types given the drug treatment is:\n", |
394 | 390 | "\n", |
395 | 391 | "\n", |
396 | 392 | "$\\Delta_{2} = \\overline{X}_{D, M} - \\overline{X}_{D, W}$\n", |
|
418 | 414 | "id": "58c98331", |
419 | 415 | "metadata": {}, |
420 | 416 | "source": [ |
421 | | - "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``.\n" |
| 417 | + "In the example above, we used the convention of *test - control* but you can manipulate the orders of the experiment groups as well as the horizontal axis variable by setting the paremeters ``experiment_label`` and ``x1_level``.\n" |
422 | 418 | ] |
423 | 419 | }, |
424 | 420 | { |
|
461 | 457 | "id": "fdc663cb", |
462 | 458 | "metadata": {}, |
463 | 459 | "source": [ |
464 | | - "The delta - delta function also supports paired data, which is useful for us to visualise the data in an alternate way. Assuming that the placebo and drug treatment were done on the same subjects, our data is paired between the treatment conditions. We can specify this by using ``Treatment`` as ``x`` and ``Genotype`` as ``experiment``, and we further specify that ``id_col`` is ``ID``, linking data from the same subject with each other. Since we have done two replicates of the experiments, we can also colour the slope lines according to ``Rep``. \n" |
| 460 | + "The delta-delta function also supports paired data, providing a useful alternative visualization of the data. Assuming that the placebo and drug treatment were administered to the same subjects, our data is paired between the treatment conditions. We can specify this by using ``Treatment`` as ``x`` and ``Genotype`` as ``experiment``, and we further specify that ``id_col`` is ``ID``, linking data from the same subject with each other. Since we have conducted two replicates of the experiments, we can also colour the slope lines according to ``Rep``. " |
465 | 461 | ] |
466 | 462 | }, |
467 | 463 | { |
|
502 | 498 | "id": "3b07192c", |
503 | 499 | "metadata": {}, |
504 | 500 | "source": [ |
505 | | - "Mean difference between drug and placebo treatments in wild type subjects is:\n", |
| 501 | + "The mean difference between drug and placebo treatments in wild type subjects is:\n", |
506 | 502 | "\n", |
507 | 503 | "$$\\Delta_{1} = \\overline{X}_{D, W} - \\overline{X}_{P, W}$$\n", |
508 | 504 | "\n", |
509 | | - "Mean difference between drug and placebo treatments in mutant subjects is:\n", |
| 505 | + "The mean difference between drug and placebo treatments in mutant subjects is:\n", |
510 | 506 | "\n", |
511 | 507 | "$$\\Delta_{2} = \\overline{X}_{D, M} - \\overline{X}_{P, M}$$\n", |
512 | 508 | "\n", |
|
530 | 526 | "id": "1429f772", |
531 | 527 | "metadata": {}, |
532 | 528 | "source": [ |
533 | | - "Standardized mean difference statistics like Cohen's d and Hedges' g quantify effect sizes in terms of the sample variance. We devised a metric, Deltas' g, to standardize delta-delta effects. This metric then can allow the comparison between measurements of different dimensions.\n", |
| 529 | + "Standardized mean difference statistics like Cohen's d and Hedges' g quantify effect sizes in terms of the sample variance. We have introduced a metric, *Deltas' g*, to standardize delta-delta effects. This metric enables the comparison between measurements of different dimensions.\n", |
534 | 530 | "\n", |
535 | 531 | "The standard deviation of the delta-delta value is calculated from a pooled variance of the 4 samples:\n", |
536 | 532 | "\n", |
537 | | - "\n", |
538 | 533 | "$$s_{\\Delta_{\\Delta}} = \\sqrt{\\frac{(n_{D, W}-1)s_{D, W}^2+(n_{P, W}-1)s_{P, W}^2+(n_{D, M}-1)s_{D, M}^2+(n_{P, M}-1)s_{P, M}^2}{(n_{D, W} - 1) + (n_{P, W} - 1) + (n_{D, M} - 1) + (n_{P, M} - 1)}}$$\n", |
539 | 534 | "\n", |
540 | 535 | "where $s$ is the standard deviation and $n$ is the sample size.\n", |
|
583 | 578 | } |
584 | 579 | ], |
585 | 580 | "source": [ |
586 | | - "unpaired_delta2.delta_g\n", |
587 | | - "\n" |
| 581 | + "unpaired_delta2.delta_g" |
588 | 582 | ] |
589 | 583 | }, |
590 | 584 | { |
591 | 585 | "cell_type": "markdown", |
592 | 586 | "id": "e53154bb", |
593 | 587 | "metadata": {}, |
594 | 588 | "source": [ |
595 | | - "We see that the standardised delta-delta value of -2.11 standard deviations [95%CI -2.98, -1.2] as the net effect of the drug accounting for non-specific actions in healthy individuals. \n" |
| 589 | + "We see the standardised delta-delta value of -2.11 standard deviations [95%CI -2.98, -1.2] as the net effect of the drug accounting for non-specific actions in healthy individuals. " |
596 | 590 | ] |
597 | 591 | }, |
598 | 592 | { |
|
613 | 607 | } |
614 | 608 | ], |
615 | 609 | "source": [ |
616 | | - "unpaired_delta2.delta_g.plot();" |
| 610 | + "unpaired_delta2.delta_g.plot();\n" |
617 | 611 | ] |
618 | 612 | }, |
619 | 613 | { |
|
721 | 715 | "id": "4ed26036", |
722 | 716 | "metadata": {}, |
723 | 717 | "source": [ |
724 | | - "You can find all outputs of the delta - delta calculation by assessing the attribute named ``delta_delta`` of the \n", |
725 | | - "effect size object." |
| 718 | + "You can find all outputs of the delta-delta calculation by assessing the attribute named ``delta_delta`` of the effect size object." |
726 | 719 | ] |
727 | 720 | }, |
728 | 721 | { |
|
771 | 764 | "id": "3ba800cc", |
772 | 765 | "metadata": {}, |
773 | 766 | "source": [ |
774 | | - "``delta_delta`` has its own attributes, containing various information of delta - delta.\n", |
| 767 | + "The ``delta_delta`` object has its own attributes, containing various information of delta - delta.\n", |
775 | 768 | "\n", |
776 | 769 | " - ``difference``: the mean bootstrapped differences between the 2 groups of bootstrapped mean differences \n", |
777 | 770 | " - ``bootstraps``: the 2 groups of bootstrapped mean differences \n", |
|
780 | 773 | " - ``permutations_var``: the pooled group variances of two groups of bootstrapped mean differences calculated based on permutation data\n", |
781 | 774 | " - ``permutations_delta_delta``: the delta-delta calculated based on the permutation data\n", |
782 | 775 | "\n", |
783 | | - "``delta_delta.to_dict()`` will return to you all the attributes in a dictionary format." |
| 776 | + "``delta_delta.to_dict()`` will return all the attributes in a dictionary format." |
784 | 777 | ] |
785 | 778 | }, |
786 | 779 | { |
|
0 commit comments