Last updated: 2022-09-20

Checks: 5 2

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.

Using absolute paths to the files within your workflowr project makes it difficult for you and others to run your code on a different machine. Change the absolute path(s) below to the suggested relative path(s) to make your code more reproducible.

absolute relative
C:/Users/Jie Zhou/Documents/paper02052022/immune cell study/Immunue_Cell_Study/data/inputdataMZILN.Rdata data/inputdataMZILN.Rdata
C:/Users/Jie Zhou/Documents/paper02052022/immune cell study/Immunue_Cell_Study/data/SILVAtaxtab_G_12M.RDS data/SILVAtaxtab_G_12M.rds
C:/Users/Jie Zhou/Documents/paper02052022/immune cell study/Immunue_Cell_Study/data/NHBCSreq19SEP2018ym_deided.csv data/NHBCSreq19SEP2018ym_deided.csv

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 5bf2b3b. 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

Unstaged changes:
    Modified:   analysis/marginal_model_complete.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 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

input data

confounder=read.csv("//dartfs-hpc.dartmouth.edu/rc/lab/M/MRKepistor7/collab/JieZhou/SourceFiles/req19jul2019_ym_06jul2020.csv")
linkage=read.csv("//dartfs-hpc.dartmouth.edu/rc/lab/M/MRKepistor7/collab/JieZhou/SourceFiles/MBLID_linkage.csv")

combine 6-week and 12-month data

colnames(data6w)[1:2]=c("subject","time")
colnames(data12m)[1:2]=c("subject","time")
name6w=colnames(data6w)[-c(1,2)]
name12m=colnames(data12m)[-c(1,2)]
jointname=unique(c(name6w, name12m))
n1=nrow(data6w)
n2=nrow(data12m)
data6w_swell=data.frame(matrix(nrow = n1,ncol = length(jointname)))
data12m_swell=data.frame(matrix(nrow = n2,ncol = length(jointname)))
for (j in 1:length(jointname)) {
  index1=which(name6w==jointname[j])
  index2=which(name12m==jointname[j])
  if (length(index1)==1){
    data6w_swell[,j]=data6w[,index1+2]
  }else{
    data6w_swell[,j]=0  
  }
  if (length(index2)==1){
    data12m_swell[,j]=data12m[,index2+2]
  }else{
    data12m_swell[,j]=0  
  }
}
data6w_swell=cbind(data6w$subject,data6w$time, data6w_swell)
rownames(data6w_swell)=rownames(data6w)
colnames(data6w_swell)=c("subject","time",jointname)
data12m_swell=cbind(data12m$subject,data12m$time, data12m_swell)
rownames(data12m_swell)=rownames(data12m)
colnames(data12m_swell)=c("subject","time",jointname)
data6w12m=rbind(data6w_swell,data12m_swell)
#which(apply(data6w12m[,-c(1,2)], 2, sum)==0)
data6w12m=data6w12m[,-207]
index=order(data6w12m$subject,data6w12m$time)
data6w12m=data6w12m[index,]
save(data6w12m,file = "data6w12m.Rdata")

align the microbiome data with immunce cell data

overlap=intersect(data6w_swell$subject,data12m_swell$subject)
##overlapping data
data12msub=data.frame()
df.bcelladj_o=data.frame()
df.cd4tadj_o=data.frame()
df.cd8tadj_o=data.frame()
df.cd8tcd4tadj_o=data.frame()
df.monoadj_o=data.frame()
df.nkadj_o=data.frame()
df.nrbcadj_o=data.frame()
df.granadj_o=data.frame()
for (i in 1:length(overlap)) {
  index1=which(data12m_swell$subject==overlap[i])
  a=data12m_swell[index1,]
  data12msub=rbind(data12msub,a)
  
  index1=which(df.bcelladj6w$subject6w==overlap[i])
  a=df.bcelladj6w[index1,]
  df.bcelladj_o=rbind(df.bcelladj_o,a)
 

  a=df.cd4tadj6w[index1,]
  df.cd4tadj_o=rbind(df.cd4tadj_o,a)

  a=df.cd8tadj6w[index1,]
  df.cd8tadj_o=rbind(df.cd8tadj_o,a)
 
  a=df.cd8tcd4tadj6w[index1,]
  df.cd8tcd4tadj_o=rbind(df.cd8tcd4tadj_o,a)
  
  
  a=df.monoadj6w[index1,]
  df.monoadj_o=rbind(df.monoadj_o,a)

  a=df.nkadj6w[index1,]
  df.nkadj_o=rbind(df.nkadj_o,a)

  a=df.nrbcadj6w[index1,]
  df.nrbcadj_o=rbind(df.nrbcadj_o,a)

  a=df.granadj6w[index1,]
  df.granadj_o=rbind(df.granadj_o,a)
}
longidata=rbind(data6w_swell,data12msub)
longibcell=rbind(df.bcelladj6w,df.bcelladj_o)
longicd4=rbind(df.cd4tadj6w,df.cd4tadj_o)
longicd8=rbind(df.cd8tadj6w, df.cd8tadj_o)
longicd8cd4=rbind(df.cd8tcd4tadj6w,df.cd8tcd4tadj_o)
longimono=rbind(df.monoadj6w,df.monoadj_o)
longink=rbind(df.nkadj6w,df.nkadj_o)
longinrbc=rbind(df.nrbcadj6w,df.nrbcadj_o)
longigran=rbind(df.granadj6w,df.granadj_o)

compute alpha diversity

library(vegan)
Warning: package 'vegan' was built under R version 4.1.3
Loading required package: permute
Warning: package 'permute' was built under R version 4.1.3
Loading required package: lattice
This is vegan 2.6-2
index=order(longidata[,1],longidata[,2])
longidata=longidata[index,]
alpha6w=diversity(data6w_swell[,-c(1,2)],index = "shannon")
alpha12m=diversity(data12msub[,-c(1,2)],index = "shannon")
alpha=diversity(longidata[,-c(1,2)],index = "shannon")
longibcell=cbind(longibcell[index,],alpha)
longicd4=cbind(longicd4[index,],alpha)
longicd8=cbind(longicd8[index,],alpha)
longicd8cd4=cbind(longicd8cd4[index,],alpha)
longigran=cbind(longigran[index,],alpha)
longimono=cbind(longimono[index,],alpha)
longink=cbind(longink[index,],alpha)
longinrbc=cbind(longinrbc[index,],alpha)

incorporate the deliver mode

exmblid=rownames(longidata)
deliver=c()
for (i in 1:length(exmblid)) {
  index2=which(linkage[,2]==exmblid[i])
  unq_id=linkage[index2,1]
  index3=which(confounder[,1]==unq_id)
  a=confounder$deliverytype[index3]
  deliver=c(deliver,a)
}
longibcell=cbind(longibcell,deliver)
longicd4=cbind(longicd4,deliver)
longicd8=cbind(longicd8,deliver)
longimono=cbind(longimono,deliver)
longink=cbind(longink,deliver)
longinrbc=cbind(longinrbc,deliver)
longigran=cbind(longigran,deliver)
ss=df.granadj6w$subject6w
dd=c()
for (i in 1:73) {
  index=which(longibcell$subject6w==ss[i])[1]
  dd=c(dd,longibcell$deliver[index])
}
library(gee)
Warning: package 'gee' was built under R version 4.1.3

Regression analysis

Bcell

         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

cd4t

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

cd8t

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

mono

          microbe     coef     pvalue      lower       upper       fdr
3 Bifidobacterium -0.13236 0.01525392 -0.2392826 -0.02543741 0.2898245

nk

                 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

nrbc

              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

gran

           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] gee_4.13-23     vegan_2.6-2     lattice_0.20-45 permute_0.9-7  

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     highr_0.9       
 [9] workflowr_1.7.0  tools_4.1.2      digest_0.6.29    nlme_3.1-153    
[13] jsonlite_1.8.0   evaluate_0.15    lifecycle_1.0.1  tibble_3.1.7    
[17] mgcv_1.8-38      pkgconfig_2.0.3  rlang_1.0.4      Matrix_1.3-4    
[21] cli_3.3.0        rstudioapi_0.13  parallel_4.1.2   yaml_2.3.5      
[25] xfun_0.31        fastmap_1.1.0    cluster_2.1.2    stringr_1.4.0   
[29] knitr_1.39       fs_1.5.2         vctrs_0.4.1      sass_0.4.2      
[33] grid_4.1.2       rprojroot_2.0.3  glue_1.6.2       R6_2.5.1        
[37] fansi_1.0.3      rmarkdown_2.14   magrittr_2.0.3   whisker_0.4     
[41] splines_4.1.2    MASS_7.3-54      promises_1.2.0.1 ellipsis_0.3.2  
[45] htmltools_0.5.2  httpuv_1.6.5     utf8_1.2.2       stringi_1.7.6   
[49] cachem_1.0.6