Difference between revisions of "Rate of drop analysis"

From Bridges Lab Protocols
Jump to: navigation, search
(Created page with "==Purpose== To assess the initial response to insulin administration, you can calculate the slope of the line for the early timepoints in your insulin tolerance test. To do th...")
 
 
(4 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
1. First, filter your ITT data to contain only the observations from where animals are in the initial drop of the experiment. This is usually 30-45 minutes, but you should assess this for each ITT yourself.
 
1. First, filter your ITT data to contain only the observations from where animals are in the initial drop of the experiment. This is usually 30-45 minutes, but you should assess this for each ITT yourself.
 
      
 
      
2. You then need to construct a linear model for your data. It should include 1 covariate for every experimental variable (eg, time, genotype, sex, diet, injection). You should also include an interaction variable for time and the variable of interest. This will be the crucial value that you interpret different slopes of the initial drop from.  
+
2. You then need to construct a model for your data. It should include 1 covariate for every experimental variable (eg, time, genotype, sex, diet, injection). You should also include an interaction variable for time and the variable of interest. This will be the crucial value that you interpret different slopes of the initial drop from.  
  
 
3. After creating the model, you will need to assess the significance of that model. Do this using the anova command in R. This will give you the covariate p values.
 
3. After creating the model, you will need to assess the significance of that model. Do this using the anova command in R. This will give you the covariate p values.
  
4. Next, to find the beta estimates, you will need to run the coefficient command in R. This will tell you the actual changes in glucose (mg/dL) for each covariate. The beta coefficient of interest is the one corresponding to the interaction variable you coded in step 2.  
+
4. Next, to find the beta estimates, you will need to run the coefficient command in R. This will tell you the actual changes in glucose (mg/dL) for each covariate. The beta coefficient of interest is the one corresponding to the interaction variable you coded in step 2.
+
 
 
==Sample R Code==
 
==Sample R Code==
new.data.set <-original.data.set%>%
+
models<-ITT.raw.data%>%
filter(time=="0"| time == "30"| time =="45")
+
  filter(time<60)%>%
 +
  group_by(ID, sex, treatment)%>%
 +
  mutate(l.glucose = log(glucose))%>%
 +
  do(fitted.model= lm(l.glucose~ time, data =.))%>%
 +
  mutate(rate =coef(fitted.model)["time"],
 +
          max = coef(fitted.model)["(Intercept)"],
 +
        rsq = summary(fitted.model)$r.squared)%>%
 +
  mutate(max.exp = exp(max))%>%
 +
  mutate( slope= max.exp*rate)
 +
 
  
drop.data.lm <- lm (data = new.data.set, formula = ( glucose ~ time + treatment + time:treatment)
+
summary.models<-models%>%
 +
  group_by(sex,treatment)%>%
 +
summarise_at(.var ="slope", .funs = funs(mean, se))
  
anova(drop.data.lm)
+
ggplot(summary.models, aes(treatment, mean, fill = treatment))+
 +
  geom_col(aes(fill = treatment))+
 +
  facet_grid(.~sex)+
 +
  geom_errorbar(aes(ymin = mean-se, ymax = mean + se), width = 0.3)+
 +
  scale_fill_manual(values = color.scheme)+
 +
  labs(title = "Rate of Drop, ITT",y="mg/dL per minute")
  
coefficients(drop.data.lm)
+
rate.aov<-aov(slope ~ sex + treatment, data = models)
 +
anova(rate.aov)%>%kable

Latest revision as of 13:54, 1 September 2022

Purpose

To assess the initial response to insulin administration, you can calculate the slope of the line for the early timepoints in your insulin tolerance test. To do this, complete the following steps:

Methods

1. First, filter your ITT data to contain only the observations from where animals are in the initial drop of the experiment. This is usually 30-45 minutes, but you should assess this for each ITT yourself.

2. You then need to construct a model for your data. It should include 1 covariate for every experimental variable (eg, time, genotype, sex, diet, injection). You should also include an interaction variable for time and the variable of interest. This will be the crucial value that you interpret different slopes of the initial drop from.

3. After creating the model, you will need to assess the significance of that model. Do this using the anova command in R. This will give you the covariate p values.

4. Next, to find the beta estimates, you will need to run the coefficient command in R. This will tell you the actual changes in glucose (mg/dL) for each covariate. The beta coefficient of interest is the one corresponding to the interaction variable you coded in step 2.

Sample R Code

models<-ITT.raw.data%>%

 filter(time<60)%>%
 group_by(ID, sex, treatment)%>%
 mutate(l.glucose = log(glucose))%>%
 do(fitted.model= lm(l.glucose~ time, data =.))%>%
 mutate(rate =coef(fitted.model)["time"],
         max = coef(fitted.model)["(Intercept)"],
        rsq = summary(fitted.model)$r.squared)%>%
 mutate(max.exp = exp(max))%>%
 mutate( slope= max.exp*rate)


summary.models<-models%>%

 group_by(sex,treatment)%>%

summarise_at(.var ="slope", .funs = funs(mean, se))

ggplot(summary.models, aes(treatment, mean, fill = treatment))+

 geom_col(aes(fill = treatment))+
 facet_grid(.~sex)+
 geom_errorbar(aes(ymin = mean-se, ymax = mean + se), width = 0.3)+
 scale_fill_manual(values = color.scheme)+
 labs(title = "Rate of Drop, ITT",y="mg/dL per minute")

rate.aov<-aov(slope ~ sex + treatment, data = models) anova(rate.aov)%>%kable