Acti v it y of z ebrafish and melatonin C ASE STU D IE S IN - - PowerPoint PPT Presentation

acti v it y of z ebrafish and melatonin
SMART_READER_LITE
LIVE PREVIEW

Acti v it y of z ebrafish and melatonin C ASE STU D IE S IN - - PowerPoint PPT Presentation

Acti v it y of z ebrafish and melatonin C ASE STU D IE S IN STATISTIC AL TH IN K IN G J u stin Bois Lect u rer , Caltech CASE STUDIES IN STATISTICAL THINKING Case st u dies in statistical thinking Hone and e x tend y o u r statistical thinking


slide-1
SLIDE 1

Activity of zebrafish and melatonin

C ASE STU D IE S IN STATISTIC AL TH IN K IN G

Justin Bois

Lecturer, Caltech

slide-2
SLIDE 2

CASE STUDIES IN STATISTICAL THINKING

slide-3
SLIDE 3

CASE STUDIES IN STATISTICAL THINKING

Case studies in statistical thinking

Hone and extend your statistical thinking skills Work with real data sets Review of Statistical Thinking I and II

slide-4
SLIDE 4

CASE STUDIES IN STATISTICAL THINKING

Warming up with zebrafish

Movie courtesy of David Prober, Caltech

1

slide-5
SLIDE 5

CASE STUDIES IN STATISTICAL THINKING

Nomenclature

Mutant: Has the mutation on both chromosomes Wild type: Does not have the mutation

slide-6
SLIDE 6

CASE STUDIES IN STATISTICAL THINKING

Activity of fish, day and night

Data courtesy of Avni Gandhi, Grigorios Oikonomou, and David Prober, Caltech

1

slide-7
SLIDE 7

CASE STUDIES IN STATISTICAL THINKING

Active bouts: a metric for wakefulness

Active bout: A period of time where a sh is consistently active Active bout length: Number of consecutive minutes with activity

slide-8
SLIDE 8

CASE STUDIES IN STATISTICAL THINKING

Probability distributions and stories

Probability distribution: A mathematical description of

  • utcomes

A probability distribution has a story

slide-9
SLIDE 9

CASE STUDIES IN STATISTICAL THINKING

Distributions from Statistical Thinking I

Uniform Binomial Poisson Normal Exponential

slide-10
SLIDE 10

CASE STUDIES IN STATISTICAL THINKING

The Exponential distribution

Poisson process: The timing of the next event is completely independent of when the previous event happened Story of the Exponential distribution: The waiting time between arrivals of a Poisson process is Exponentially distributed

slide-11
SLIDE 11

CASE STUDIES IN STATISTICAL THINKING

The Exponential CDF

x, y = ecdf(nuclear_incident_times) _ = plt.plot(x, y, marker='.', linestyle='none')

Data source: Wheatley, Sovacool, and Sornee, Nuclear Events Database

1

slide-12
SLIDE 12

CASE STUDIES IN STATISTICAL THINKING

The Exponential CDF

x, y = ecdf(nuclear_incident_times) _ = plt.plot(x, y, marker='.', linestyle='none')

Data source: Wheatley, Sovacool, and Sornee, Nuclear Events Database

1

slide-13
SLIDE 13

CASE STUDIES IN STATISTICAL THINKING

import dc_stat_think as dcst dcst.pearson_r? Signature: dcst.pearson_r(data_1, data_2) Docstring: Compute the Pearson correlation coefficient between two samples. Parameters

  • data_1 : array_like

One-dimensional array of data. data_2 : array_like One-dimensional array of data. Returns

  • utput : float

The Pearson correlation coefficient between `data_1` and `data_2`. File: usr/local/lib/python3.5/site-packages/ dc_stat_think-0.1.4-py3.6.egg/dc_stat_think/dc_stat_think.py Type: function

slide-14
SLIDE 14

CASE STUDIES IN STATISTICAL THINKING

Using the dc_stat_think module

x, y = dcst.ecdf(nuclear_incident_times) % pip install dc_stat_think

slide-15
SLIDE 15

Let's practice!

C ASE STU D IE S IN STATISTIC AL TH IN K IN G

slide-16
SLIDE 16

Bootstrap confidence intervals

C ASE STU D IE S IN STATISTIC AL TH IN K IN G

Justin Bois

Lecturer, Caltech

slide-17
SLIDE 17

CASE STUDIES IN STATISTICAL THINKING

EDA is the first step

"Exploratory data analysis can never be the whole story, but nothing else can serve as a foundation stone, as the rst step."

  • -John Tukey
slide-18
SLIDE 18

CASE STUDIES IN STATISTICAL THINKING

Active bout length ECDFs

Data courtesy of Avni Gandhi, Grigorios Oikonomou, and David Prober, Caltech

1

slide-19
SLIDE 19

CASE STUDIES IN STATISTICAL THINKING

Optimal parameter value

Optimal parameter value: The value of the parameter of a probability distribution that best describes the data Optimal parameter for the Exponential distribution: Computed from the mean of the data

slide-20
SLIDE 20

CASE STUDIES IN STATISTICAL THINKING np.mean(nuclear_incident_times) 87.140350877192986 Data source: Wheatley, Sovacool, and Sornee, Nuclear Events Database

1

slide-21
SLIDE 21

CASE STUDIES IN STATISTICAL THINKING

Bootstrap sample

A resampled array of the data

# Resample nuclear_incident_times with replacement bs_sample = np.random.choice( nuclear_incident_times, replace=True, size=len(inter_times) )

slide-22
SLIDE 22

CASE STUDIES IN STATISTICAL THINKING

Bootstrap replicates

Data source: Wheatley, Sovacool, and Sornee, Nuclear Events Database

1

slide-23
SLIDE 23

CASE STUDIES IN STATISTICAL THINKING

Bootstrap replicates

Data source: Wheatley, Sovacool, and Sornee, Nuclear Events Database

1

slide-24
SLIDE 24

CASE STUDIES IN STATISTICAL THINKING

Bootstrap replicates

Data source: Wheatley, Sovacool, and Sornee, Nuclear Events Database

1

slide-25
SLIDE 25

CASE STUDIES IN STATISTICAL THINKING

Bootstrap replicates

Data source: Wheatley, Sovacool, and Sornee, Nuclear Events Database

1

slide-26
SLIDE 26

CASE STUDIES IN STATISTICAL THINKING

Bootstrap replicates

Bootstrap replicate: A statistic computed from a bootstrap sample

slide-27
SLIDE 27

CASE STUDIES IN STATISTICAL THINKING

dcst.draw_bs_reps()

Function to draw bootstrap replicates from a data set

# Draw 10000 replicates of the mean from # nuclear_incident_times bs_reps = dcst.draw_bs_reps( nuclear_incident_times, np.mean, size=10000 )

slide-28
SLIDE 28

CASE STUDIES IN STATISTICAL THINKING

The bootstrap confidence interval

Data source: Wheatley, Sovacool, and Sornee, Nuclear Events Database

1

slide-29
SLIDE 29

CASE STUDIES IN STATISTICAL THINKING

The bootstrap confidence interval

If we repeated measurements over and over again, p% of the

  • bserved values would lie within the p% condence interval
slide-30
SLIDE 30

CASE STUDIES IN STATISTICAL THINKING

The bootstrap confidence interval

np.percentile(bs_reps, [2.5, 97.5]) array([ 73.31505848, 102.39181287])

slide-31
SLIDE 31

Let's practice!

C ASE STU D IE S IN STATISTIC AL TH IN K IN G

slide-32
SLIDE 32

Hypothesis tests

C ASE STU D IE S IN STATISTIC AL TH IN K IN G

Justin Bois

Lecturer, Caltech

slide-33
SLIDE 33

CASE STUDIES IN STATISTICAL THINKING

Effects of mutation on activity

Data courtesy of Avni Gandhi, Grigogios Oikonomou, and David Prober, Caltech

1

slide-34
SLIDE 34

CASE STUDIES IN STATISTICAL THINKING

Genotype definitions

Wild type: No mutations Heterozygote: Mutation on one of two chromosomes Mutant: Mutation on both chromosomes

slide-35
SLIDE 35

CASE STUDIES IN STATISTICAL THINKING

Effects of mutation on activity

Data courtesy of Avni Gandhi, Grigogios Oikonomou, and David Prober, Caltech

1

slide-36
SLIDE 36

CASE STUDIES IN STATISTICAL THINKING

Effects of mutation on activity

Data courtesy of Avni Gandhi, Grigogios Oikonomou, and David Prober, Caltech

1

slide-37
SLIDE 37

CASE STUDIES IN STATISTICAL THINKING

Hypothesis test

Assessment of how reasonable the observed data are assuming a hypothesis is true

slide-38
SLIDE 38

CASE STUDIES IN STATISTICAL THINKING

p-value

The probability of obtaining a value of your test statistic that is at least as extreme as what was observed, under the assumption the null hypothesis is true

slide-39
SLIDE 39

CASE STUDIES IN STATISTICAL THINKING

Test statistic

A single number that can be computed from observed data and from data you simulate under the null hypothesis Serves as a basis of comparison

slide-40
SLIDE 40

CASE STUDIES IN STATISTICAL THINKING

p-value

The probability of obtaining a value of your test statistic that is at least as extreme as what was observed, under the assumption the null hypothesis is true Requires clear specication of: Null hypothesis that can be simulated Test statistic that can be calculated from observed and simulated data Denition of at least as extreme as

slide-41
SLIDE 41

CASE STUDIES IN STATISTICAL THINKING

Pipeline for hypothesis testing

Clearly state the null hypothesis Dene your test statistic Generate many sets of simulated data assuming the null hypothesis is true Compute the test statistic for each simulated data set The p-value is the fraction of your simulated data sets for which the test statistic is at least as extreme as for the real data

slide-42
SLIDE 42

CASE STUDIES IN STATISTICAL THINKING

Specifying the test

Null hypothesis: the active bout lengths of wild type and heterozygotic sh are identically distributed Test statistic: Dierence in mean active bout length between heterozygotes and wild type At least as extreme as: Test statistic is greater than or equal to what was observed

slide-43
SLIDE 43

CASE STUDIES IN STATISTICAL THINKING

Permutation test

For each replicate: Scramble labels of data points Compute test statistic

perm_reps = dcst.draw_perm_reps( data_a, data_b, dcst.diff_of_means, size=10000 )

p-value is the fraction of replicates at least as extreme as what was observed

p_val = np.sum(perm_reps >= diff_means_obs) / len(perm_reps)

slide-44
SLIDE 44

Let's practice!

C ASE STU D IE S IN STATISTIC AL TH IN K IN G

slide-45
SLIDE 45

Linear regressions and pairs bootstrap

C ASE STU D IE S IN STATISTIC AL TH IN K IN G

Justin Bois

Lecturer, Caltech

slide-46
SLIDE 46

CASE STUDIES IN STATISTICAL THINKING

Bacterial growth

Images courtesy of Jin Park and Michael Elowitz, Caltech

1

slide-47
SLIDE 47

CASE STUDIES IN STATISTICAL THINKING

Bacterial growth

slide-48
SLIDE 48

CASE STUDIES IN STATISTICAL THINKING

_ = plt.semilogy(t, bac_area, marker='.', linestyle='none') _ = plt.xlabel('time (hr)') _ = plt.ylabel('area (sq. µm)') plt.show()

slide-49
SLIDE 49

CASE STUDIES IN STATISTICAL THINKING

Linear regression with np.polyfit()

slope, intercept = np.polyfit(t, bac_area, 1) t_theor = np.array([0, 14]) bac_area_theor = slope * t_theor + intercept _ = plt.plot(t, bac_area, marker='.', linestyle='none') _ = plt.plot(t_theor, bac_area_theor) _ = plt.xlabel('time (hr)') _ = plt.ylabel('area (sq. µm)') plt.show()

slide-50
SLIDE 50

CASE STUDIES IN STATISTICAL THINKING

Regression of bacterial growth

slide-51
SLIDE 51

CASE STUDIES IN STATISTICAL THINKING

Semilog-linear regression with np.polyfit()

slope, intercept = np.polyfit(t, np.log(bac_area), 1) t_theor = np.array([0, 14]) bac_area_theor = np.exp(slope * t_theor + intercept) _ = plt.semilogy(t, bac_area, marker='.', linestyle='none') _ = plt.semilogy(t_theor, bac_area_theor) _ = plt.xlabel('time (hr)') _ = plt.ylabel('area (sq. µm)') plt.show()

slide-52
SLIDE 52

CASE STUDIES IN STATISTICAL THINKING

Regression of bacterial growth

slide-53
SLIDE 53

CASE STUDIES IN STATISTICAL THINKING

Pairs bootstrap

Resample data in pairs Compute slope and intercept from resampled data Each slope and intercept is a bootstrap replicate Compute condence intervals from percentiles of bootstrap replicates

slide-54
SLIDE 54

CASE STUDIES IN STATISTICAL THINKING

Pairs bootstrap

# Draw 10000 pairs bootstrap reps slope_reps, int_reps = dcst.draw_bs_pairs_linreg( x_data, y_data, size=10000 ) # Compute 95% confidence interval of slope slope_conf_int = np.percentile(slope_reps, [2.5, 97.5])

slide-55
SLIDE 55

Let's practice!

C ASE STU D IE S IN STATISTIC AL TH IN K IN G