Last updated: 2022-09-23

Checks: 6 1

Knit directory: Immunue_Cell_Study/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown is untracked by Git. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20220920) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 716cb2a. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.Rhistory

Untracked files:
    Untracked:  analysis/12month_analysis_GEE.Rmd
    Untracked:  analysis/6week_analysis_GEE.Rmd

Unstaged changes:
    Modified:   analysis/12month_analysis.Rmd
    Modified:   analysis/6week_analysis.Rmd
    Modified:   analysis/glm without modeling correlation.Rmd
    Modified:   analysis/index.Rmd
    Modified:   analysis/marginal_model_complete.Rmd
    Deleted:    analysis/marginal_model_with_independence.Rmd

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.


clean the data

library(gee)
source("./code/datacleaning.r")
index=which(longidata$time==12)

Regression analysis

Microbes associated with Bcell

Click me
options(warn = 2)
m=ncol(longidata)-2
n=nrow(longidata)
name=colnames(longidata)[-c(1,2)]
microbe=c()                            
rrbcell=data.frame()
for (k in 1:m) {
  y1=longidata[index,k+2]
  y2=apply(longidata[index,-c(1,2,k+2)],1,sum)
  fm=try({gee(cbind(y1,y2)~bcell + bbymale + enrollment_age + imrbthwghtg_all +gestage_all+evercigpreg+alpha+deliver ,id=subject6w, data=longibcell[index,],family="binomial",corstr="independence")},silent = T)
  if (inherits(fm,"try-error")){
    next()
  }else{
    fm=gee(cbind(y1,y2)~bcell + bbymale + enrollment_age + imrbthwghtg_all +gestage_all+evercigpreg+alpha+deliver ,id=subject6w, data=longibcell[index,],family="binomial",corstr="independence")   
   a=summary(fm)
   r1=a$coefficients[2,1]
   r2=2*(1-pnorm(abs(a$coefficients[2,5])))
   r3= c(r1-1.96*a$coefficients[2,4],r1+ 1.96*a$coefficients[2,4])
   rr=c(r1,r2,r3)
   microbe=c(microbe,name[k])
    rrbcell=rbind(rrbcell,rr)
     }

}
colnames(rrbcell)=c("coef","pvalue","lower","upper")
fdr=p.adjust(rrbcell[,2],method = "BH")
rrbcell=data.frame(microbe,rrbcell,fdr)
rrbcell=rrbcell[order(rrbcell[,3]),]
rrbcellfdr=rrbcell[which(rrbcell[,6]<0.3),]
                microbe       coef       pvalue       lower       upper
2          Anaerostipes  0.1297091 0.0007157138  0.05457072  0.20484753
12 Escherichia/Shigella -0.1928308 0.0206614514 -0.35615391 -0.02950768
          fdr
2  0.01502999
12 0.21694524

Microbes associated with CD4

Click me
options(warn = 2)
m=ncol(longidata)-2
n=nrow(longidata)
name=colnames(longidata)[-c(1,2)]
microbe=c()                            
rrbcell=data.frame()
for (k in 1:m) {
  y1=longidata[index,k+2]
  y2=apply(longidata[index,-c(1,2,k+2)],1,sum)
  fm=try({gee(cbind(y1,y2)~cd4t + bbymale + enrollment_age + imrbthwghtg_all +gestage_all+evercigpreg+alpha+deliver ,id=subject6w, data=longicd4t[index,],family="binomial",corstr="independence")},silent = T)
  if (inherits(fm,"try-error")){
    print(k)
    next()
  }else{
    fm=gee(cbind(y1,y2)~cd4t + bbymale + enrollment_age + imrbthwghtg_all +gestage_all+evercigpreg+alpha+deliver ,id=subject6w, data=longicd4t[index],family="binomial",corstr="independence")   
   a=summary(fm)
   r1=a$coefficients[2,1]
   r2=2*(1-pnorm(abs(a$coefficients[2,5])))
   r3= c(r1-1.96*a$coefficients[2,4],r1+ 1.96*a$coefficients[2,4])
   rr=c(r1,r2,r3)
   microbe=c(microbe,name[k])
    rrbcell=rbind(rrbcell,rr)
     }

}
For CD4, GEE method does not yield any significant results.

Microbes associated with CD8

Click me
options(warn = 2)
m=ncol(longidata)-2
n=nrow(longidata)
name=colnames(longidata)[-c(1,2)]
microbe=c()                            
rrbcell=data.frame()
for (k in 1:m) {
  y1=longidata[index,k+2]
  y2=apply(longidata[index,-c(1,2,k+2)],1,sum)
  fm=try({gee(cbind(y1,y2)~cd8t + bbymale + enrollment_age + imrbthwghtg_all +gestage_all+evercigpreg+alpha+deliver ,id=subject6w, data=longicd8t[index,],family="binomial",corstr="independence")},silent = T)
  if (inherits(fm,"try-error")){
    print(k)
    next()
  }else{
    fm=gee(cbind(y1,y2)~cd8t + bbymale + enrollment_age + imrbthwghtg_all +gestage_all+evercigpreg+alpha+deliver ,id=subject6w, data=longicd8t[index,],family="binomial",corstr="independence")   
   a=summary(fm)
   r1=a$coefficients[2,1]
   r2=2*(1-pnorm(abs(a$coefficients[2,5])))
   r3= c(r1-1.96*a$coefficients[2,4],r1+ 1.96*a$coefficients[2,4])
   rr=c(r1,r2,r3)
   microbe=c(microbe,name[k])
    rrbcell=rbind(rrbcell,rr)
     }

}

For CD8, GEE method does not yield any significant results. <>

Microbes associated with Mono

Click me
options(warn = 2)
m=ncol(longidata)-2
n=nrow(longidata)
name=colnames(longidata)[-c(1,2)]
microbe=c()                            
rrbcell=data.frame()
for (k in 1:m) {
  y1=longidata[index,k+2]
  y2=apply(longidata[index,-c(1,2,k+2)],1,sum)
  fm=try({gee(cbind(y1,y2)~mono + bbymale + enrollment_age + imrbthwghtg_all +gestage_all+evercigpreg+alpha+deliver ,id=subject6w, data=longimono[index],family="binomial",corstr="independence")},silent = T)
  if (inherits(fm,"try-error")){
    next()
  }else{
    fm=gee(cbind(y1,y2)~mono + bbymale + enrollment_age + imrbthwghtg_all +gestage_all+evercigpreg+alpha+deliver ,id=subject6w, data=longimono[index,],family="binomial",corstr="independence")   
   a=summary(fm)
   r1=a$coefficients[2,1]
   r2=2*(1-pnorm(abs(a$coefficients[2,5])))
   r3= c(r1-1.96*a$coefficients[2,4],r1+ 1.96*a$coefficients[2,4])
   rr=c(r1,r2,r3)
   microbe=c(microbe,name[k])
    rrbcell=rbind(rrbcell,rr)
     }

}
data frame with 0 columns and 0 rows

Microbes associated with NK

Click me
options(warn = 2)
m=ncol(longidata)-2
n=nrow(longidata)
name=colnames(longidata)[-c(1,2)]
microbe=c()                            
rrbcell=data.frame()
for (k in 1:m) {
  y1=longidata[index,k+2]
  y2=apply(longidata[index,-c(1,2,k+2)],1,sum)
  fm=try({gee(cbind(y1,y2)~nk + bbymale + enrollment_age + imrbthwghtg_all +gestage_all+evercigpreg+alpha+deliver ,id=subject6w, data=longink[index,],family="binomial",corstr="independence")},silent = T)
  if (inherits(fm,"try-error")){
    next()
  }else{
    fm=gee(cbind(y1,y2)~nk + bbymale + enrollment_age + imrbthwghtg_all +gestage_all+evercigpreg+alpha+deliver ,id=subject6w, data=longink[index,],family="binomial",corstr="independence")   
   a=summary(fm)
   r1=a$coefficients[2,1]
   r2=2*(1-pnorm(abs(a$coefficients[2,5])))
   r3= c(r1-1.96*a$coefficients[2,4],r1+ 1.96*a$coefficients[2,4])
   rr=c(r1,r2,r3)
   microbe=c(microbe,name[k])
    rrbcell=rbind(rrbcell,rr)
     }

}
colnames(rrbcell)=c("coef","pvalue","lower","upper")
fdr=p.adjust(rrbcell[,2],method = "BH")
rrbcell=data.frame(microbe,rrbcell,fdr)
rrbcell=rrbcell[order(rrbcell[,3]),]
rrbcellfdr=rrbcell[which(rrbcell[,6]<0.3),]
         microbe       coef      pvalue      lower       upper       fdr
21 Streptococcus -0.1438155 0.006659592 -0.2476992 -0.03993182 0.1465110
20 Ruminococcus2 -0.1306459 0.019678153 -0.2404310 -0.02086078 0.2164597

Microbes associated with NRBC

Click me
options(warn = 2)
m=ncol(longidata)-2
n=nrow(longidata)
name=colnames(longidata)[-c(1,2)]
microbe=c()                            
rrbcell=data.frame()
for (k in 1:m) {
  y1=longidata[index,k+2]
  y2=apply(longidata[index,-c(1,2,k+2)],1,sum)
  fm=try({gee(cbind(y1,y2)~nrbc + bbymale + enrollment_age + imrbthwghtg_all +gestage_all+evercigpreg+alpha+deliver ,id=subject6w, data=longinrbc[index,],family="binomial",corstr="independence")},silent = T)
  if (inherits(fm,"try-error")){
    next()
  }else{
    fm=gee(cbind(y1,y2)~nrbc + bbymale + enrollment_age + imrbthwghtg_all +gestage_all+evercigpreg+alpha+deliver ,id=subject6w, data=longinrbc[index,],family="binomial",corstr="independence")   
   a=summary(fm)
   r1=a$coefficients[2,1]
   r2=2*(1-pnorm(abs(a$coefficients[2,5])))
   r3= c(r1-1.96*a$coefficients[2,4],r1+ 1.96*a$coefficients[2,4])
   rr=c(r1,r2,r3)
   microbe=c(microbe,name[k])
    rrbcell=rbind(rrbcell,rr)
     }

}
colnames(rrbcell)=c("coef","pvalue","lower","upper")
fdr=round(p.adjust(rrbcell[,2],method = "BH"),3)
rrbcell=data.frame(microbe,rrbcell,fdr)
rrbcell=rrbcell[order(rrbcell[,3]),]
rrbcellfdr=rrbcell[which(rrbcell[,6]<0.3),]
                     microbe        coef     pvalue       lower         upper
4                    Blautia  0.06434720 0.00100589  0.02599957  0.1026948212
8  Clostridium_sensu_stricto -0.10239862 0.01786226 -0.18713773 -0.0176595073
10      Escherichia/Shigella -0.04778838 0.04803196 -0.09516377 -0.0004129773
1               Anaerostipes  0.05023228 0.06564783 -0.00325216  0.1037167135
6          Clostridium_XVIII -0.02894647 0.07578439 -0.06089751  0.0030045755
     fdr
4  0.018
8  0.161
10 0.273
1  0.273
6  0.273

Microbes associated with Gran

Click me
options(warn = 2)
m=ncol(longidata)-2
n=nrow(longidata)
name=colnames(longidata)[-c(1,2)]
microbe=c()                            
rrbcell=data.frame()
for (k in 1:m) {
  y1=longidata[index,k+2]
  y2=apply(longidata[index,-c(1,2,k+2)],1,sum)
  fm=try({gee(cbind(y1,y2)~gran + bbymale + enrollment_age + imrbthwghtg_all +gestage_all+evercigpreg+alpha+deliver ,id=subject6w, data=longigran[index,],family="binomial",corstr="independence")},silent = T)
  if (inherits(fm,"try-error")){
    next()
  }else{
    fm=gee(cbind(y1,y2)~gran + bbymale + enrollment_age + imrbthwghtg_all +gestage_all+evercigpreg+alpha+deliver ,id=subject6w, data=longigran[index,],family="binomial",corstr="independence")   
   a=summary(fm)
   r1=a$coefficients[2,1]
   r2=2*(1-pnorm(abs(a$coefficients[2,5])))
   r3= c(r1-1.96*a$coefficients[2,4],r1+ 1.96*a$coefficients[2,4])
   rr=round(c(r1,r2,r3),3)
   microbe=c(microbe,name[k])
    rrbcell=rbind(rrbcell,rr)
     }

}
colnames(rrbcell)=c("coef","pvalue","lower","upper")
fdr=round(p.adjust(rrbcell[,2],method = "BH"),3)
rrbcell=data.frame(microbe,rrbcell,fdr)
rrbcell=rrbcell[order(rrbcell[,3]),]
rrbcellfdr=rrbcell[which(rrbcell[,6]<0.4),]
       microbe   coef pvalue  lower  upper   fdr
2 Anaerostipes -0.044  0.014 -0.079 -0.009 0.322

<>


sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] vegan_2.6-2     lattice_0.20-45 permute_0.9-7   gee_4.13-23    

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9       pillar_1.8.0     compiler_4.1.2   bslib_0.4.0     
 [5] later_1.3.0      jquerylib_0.1.4  git2r_0.30.1     workflowr_1.7.0 
 [9] tools_4.1.2      digest_0.6.29    nlme_3.1-153     jsonlite_1.8.0  
[13] evaluate_0.15    lifecycle_1.0.1  tibble_3.1.7     mgcv_1.8-38     
[17] pkgconfig_2.0.3  rlang_1.0.4      Matrix_1.3-4     cli_3.3.0       
[21] rstudioapi_0.13  parallel_4.1.2   yaml_2.3.5       xfun_0.31       
[25] fastmap_1.1.0    cluster_2.1.2    stringr_1.4.0    knitr_1.39      
[29] fs_1.5.2         vctrs_0.4.1      sass_0.4.2       grid_4.1.2      
[33] rprojroot_2.0.3  glue_1.6.2       R6_2.5.1         fansi_1.0.3     
[37] rmarkdown_2.14   magrittr_2.0.3   splines_4.1.2    MASS_7.3-54     
[41] promises_1.2.0.1 ellipsis_0.3.2   htmltools_0.5.2  httpuv_1.6.5    
[45] utf8_1.2.2       stringi_1.7.6    cachem_1.0.6