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 file has unstaged changes. 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.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/marginal_model_complete.Rmd) and HTML (docs/marginal_model_complete.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 716cb2a Jie Zhou 2022-09-22 simplication of data reading
html 716cb2a Jie Zhou 2022-09-22 simplication of data reading
Rmd 9600acc Jie Zhou 2022-09-22 unify the data reading
html 9600acc Jie Zhou 2022-09-22 unify the data reading
Rmd 8caf0a0 Jie Zhou 2022-09-21 title changed
html 8caf0a0 Jie Zhou 2022-09-21 title changed
Rmd 1c9b204 Jie Zhou 2022-09-21 title changed
html 1c9b204 Jie Zhou 2022-09-21 title changed
Rmd e75d82e Jie Zhou 2022-09-20 add the remote repo
html e75d82e Jie Zhou 2022-09-20 add the remote repo
Rmd 546725f Jie Zhou 2022-09-20 add the remote repo
html 546725f Jie Zhou 2022-09-20 add the remote repo
Rmd 5bf2b3b Jie Zhou 2022-09-20 add the remote repo
html 5bf2b3b Jie Zhou 2022-09-20 add the remote repo
Rmd 098d058 Jie Zhou 2022-09-20 immune cell
html 098d058 Jie Zhou 2022-09-20 immune cell

clean the data

library(gee)
source("./code/datacleaning.r")

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[,k+2]
  y2=apply(longidata[,-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,family="binomial",corstr="exchangeable")},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,family="binomial",corstr="exchangeable")   
   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
8   Enterobacter 0.1595854 0.002074279 0.05801078 0.2611599 0.0394113
1   Anaerostipes 0.1358712 0.014665627 0.02675257 0.2449898 0.1230639
18 Streptococcus 0.1153356 0.019431135 0.01861212 0.2120592 0.1230639

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[,k+2]
  y2=apply(longidata[,-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,family="binomial",corstr="exchangeable")},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,family="binomial",corstr="exchangeable")   
   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
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[,k+2]
  y2=apply(longidata[,-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,family="binomial",corstr="exchangeable")},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,family="binomial",corstr="exchangeable")   
   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

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[,k+2]
  y2=apply(longidata[,-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,family="binomial",corstr="exchangeable")},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,family="binomial",corstr="exchangeable")   
   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.4),]
          microbe     coef     pvalue      lower       upper       fdr
3 Bifidobacterium -0.13236 0.01525392 -0.2392826 -0.02543741 0.2898245

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[,k+2]
  y2=apply(longidata[,-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,family="binomial",corstr="exchangeable")},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,family="binomial",corstr="exchangeable")   
   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
4        Bifidobacterium -0.1434283 1.650503e-05 -0.20868993 -0.07816674
12 F__Enterobacteriaceae  0.2416072 7.318915e-03  0.06503946  0.41817499
            fdr
4  0.0003301007
12 0.0731891467

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[,k+2]
  y2=apply(longidata[,-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,family="binomial",corstr="exchangeable")},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,family="binomial",corstr="exchangeable")   
   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   fdr
3             Blautia 0.04587232 0.01207582 0.01005058 0.08169407 0.105
13     Flavonifractor 0.07556633 0.01721470 0.01338983 0.13774283 0.105
11 F__Lachnospiraceae 0.08422010 0.01966937 0.01345285 0.15498735 0.105

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[,k+2]
  y2=apply(longidata[,-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,family="binomial",corstr="exchangeable")},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,family="binomial",corstr="exchangeable")   
   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
4  Bifidobacterium  0.029  0.002  0.010  0.048 0.040
2     Anaerostipes -0.050  0.020 -0.093 -0.008 0.200
15  Flavonifractor -0.065  0.037 -0.127 -0.004 0.247

<>


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   whisker_0.4      splines_4.1.2   
[41] MASS_7.3-54      promises_1.2.0.1 ellipsis_0.3.2   htmltools_0.5.2 
[45] httpuv_1.6.5     utf8_1.2.2       stringi_1.7.6    cachem_1.0.6