sparcc网络分析
运行sparcc
- 首先先安装fastspar,地址https://github.com/scwatts/fastspar
- 整理abundance_counts数据,abundance_counts.txt 格式为 第一列为feature ID,且列名为 #OTU ID,其他列是样本的OTU丰度
- 然后执行下列脚本
fastspar --iterations 50 --exclude_iterations 20 --otu_table ./abundance_counts.txt --correlation median_correlation.tsv --covariance median_covariance.tsv --threads 8
mkdir bootstrap_counts
fastspar_bootstrap --otu_table ./abundance_counts.txt --number 100 --prefix ./bootstrap_counts/abundance_counts
mkdir bootstrap_correlation
parallel fastspar --otu_table {
} --correlation bootstrap_correlation/cor_{
/} --covariance ./bootstrap_correlation/cov_{
/} -i 5 ::: bootstrap_counts/*
fastspar_pvalues --otu_table ./abundance_counts.txt --correlation median_correlation.tsv --prefix bootstrap_correlation/cor_abundance_counts_ --permutations 100 --outfile pvalues.tsv
网络可视化
定义函数,
pvalue_path:sparcc生成的每个关系对的pvaule值
cor_path:sparcc生成的每个关系对的r值
taxa_table:OTU taxonomy 分类表
cut_off_p:pvaule阈值
level:给otu映射颜色的分类水平,推荐Phylum
library(tidyverse)
library(phyloseq)
library(igraph)
plot_sparcc_graph <- function(pvalue_path, cor_path, taxa_table, cut_off_p, level){
sparcc_A_pvalue <- read_delim(pvalue_path, col_names = TRUE, delim = '\t')