ACCLAB / DABEST-python

Data Analysis with Bootstrapped ESTimation
https://acclab.github.io/DABEST-python/
Apache License 2.0
339 stars 47 forks source link

Mini meta delta #124

Closed LI-Yixuan closed 2 years ago

LI-Yixuan commented 3 years ago
LI-Yixuan commented 3 years ago

Here is an example of the plots:

import numpy as np
import pandas as pd
from scipy.stats import norm # Used in generation of populations.
import dabest
import matplotlib.pyplot as plt

N=20
seed=9999
import numpy as np
import pandas as pd
from scipy.stats import norm # Used in generation of populations.

np.random.seed(9999) # Fix the seed so the results are replicable.
# pop_size = 10000 # Size of each population.

# Create samples
c1 = norm.rvs(loc=3, scale=0.4, size=N)
c2 = norm.rvs(loc=3.5, scale=0.75, size=N)
c3 = norm.rvs(loc=3.25, scale=0.4, size=N)

t1 = norm.rvs(loc=3.5, scale=0.5, size=N)
t2 = norm.rvs(loc=2.5, scale=0.6, size=N)
t3 = norm.rvs(loc=3, scale=0.75, size=N)

# Add an `id` column for paired data plotting. 
id_col = pd.Series(range(1, N+1))

# Combine samples and gender into a DataFrame.
df = pd.DataFrame({'Control 1' : c1, 'Test 1' : t1,
                    'Control 2' : c2,     'Test 2' : t2,
                       'Control 3' : c3,     'Test 3' : t3,
                       'ID'  : id_col
                      })

unpaired = dabest.load(df, 
                       idx=(("Control 1", "Test 1"), ("Control 2", "Test 2"), ("Control 3", "Test 3")),
                       mini_meta=True)

baseline = dabest.load(df, id_col = "ID",
                       idx=(("Control 1", "Test 1"), ("Control 2", "Test 2"), ("Control 3", "Test 3")),
                       paired = "baseline", mini_meta=True)

baseline.mean_diff.plot()

index

unpaired.mean_diff.plot()

ss

LI-Yixuan commented 3 years ago

Here is an example to get the numeric results:

unpaired.mean_diff

图片

unpaired.mean_diff.mini_meta_delta

图片

unpaired.mean_diff.mini_meta_delta.to_dict() # to get all the attribute of the mini_meta_delta

图片 图片

Some explanation of the attributes of mini_meta_delta class: difference: the weighted delta calculated based on the raw data group_var: the pooled group variances of each experiment group calculated based on the control groups of the raw data bootstraps: the deltas of each experiment group calculated based on the bootstrapped data bootstraps_weighted_delta: the weighted deltas calculated based on the bootstrapped data permutations: the deltas of each experiment group calculated based on the permutation data permutations_var: the pooled group variances of each experiment group calculated based on permutation data permutations_weighted_delta: the weighted deltas calculated based on the permutation data