数据分析:基于STAR+FeatureCounts的RNA-seq分析全流程流程

请添加图片描述

流程主要包含两部分组成:

  1. 第一部分:二代测序数据的Raw data的fastq文件转换成Gene Count或者Features Counts表(行是Features,列是样本名);
  2. 第二部分:对counts 表进行统计分析,并对其生物学意义或者临床意义进行解读。

Installating Software

分析流程涉及到众多的软件以及R包等,为了更方便配置该环境,建议使用anaconda软件安装。anaconda是包管理工具,可以将软件作为其包进行安装管理,并且可以设置多个环境,方便不同依赖环境的软件在同一台机器安装。安装anaconda方法见网上教程。

流程所需要软件:Use conda search software before conda install

  1. conda install -c bioconda fastqc --yes
  2. conda install -c bioconda trim-galore --yes
  3. conda install -c sortmerna --yes
  4. conda install -c bioconda star --yes
  5. conda install -c bioconda subread --yes
  6. conda install -c bioconda multiqc --yes
  7. conda install -c bioconda r-base

流程所需要的R包:

# method1
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

RNA_seq_packages <- function(){
metr_pkgs <- c("DESeq2", "ggplot2", "clusterProfiler", "biomaRt", "ReactomePA", "DOSE", 
               "KEGG.db", "KEGG.db", "org.Mm.eg.db", "org.Hs.eg.db", "pheatmap",
               "genefilter","RColorBrewer", "GO.db", "topGO","dplyr","gage","ggsci")
list_installed <- installed.packages()
new_pkgs <- subset(metr_pkgs, !(metr_pkgs %in% list_installed[, "Package"]))
if(length(new_pkgs)!=0){if (!requireNamespace("BiocManager", quietly = TRUE))
        install.packages("BiocManager")
        BiocManager::install(new_pkgs)
        print(c(new_pkgs, " packages added..."))
    }
if((length(new_pkgs)<1)){
        print("No new packages added...")
    }
}
RNA_seq_packages()

# method2
install.packages("pacman")
pacman::p_load(c("DESeq2", "ggplot2", "clusterProfiler", "biomaRt", "ReactomePA", "DOSE", 
               "KEGG.db", "KEGG.db", "org.Mm.eg.db", "org.Hs.eg.db", "pheatmap",
               "genefilter","RColorBrewer", "GO.db", "topGO","dplyr","gage","ggsci"))

The Folder Structure

── RNA_seq_dir/
  │   └── annotation/               <- Genome annotation file (.GTF/.GFF)
  │  
  │   └── genome/                   <- Host genome file (.FASTA)
  │  
  │   └── raw_data/                 <- Location of input  RNAseq data
  │  
  │   └── output/                   <- Data generated during processing steps
  │       ├── 01.fastqc/            <- Main alignment files for each sample
  │       ├── 02.trim/              <-  Log from running STAR alignment step
  │       ├── 03.sortrRNA/          <- STAR alignment counts output (for comparison with featureCounts)
  │           ├── aligned/          <-  Sequences that aligned to rRNA databases (rRNA contaminated)
  │           ├── filtered/         <-  Sequences with rRNA sequences removed  (rRNA-free)
  │           ├── logs/             <- logs from running SortMeRNA
  │       ├── 04.aligment/          <- Main alignment files for each sample
  │           ├── aligned_bam/      <-  Alignment files generated from STAR (.BAM)
  │           ├── aligned_logs/     <- Log from running STAR alignment step
  │       ├── 05.genecount/         <- Summarized gene counts across all samples
  │       ├── 06.multiQC/           <- Overall report of logs for each step
  │  
  │   └── sortmerna_db/             <- Folder to store the rRNA databases for SortMeRNA
  │       ├── index/                <- indexed versions of the rRNA sequences for faster alignment
  │       ├── rRNA_databases/       <- rRNA sequences from bacteria, archea and eukaryotes
  │  
  │   └── star_index/               <-  Folder to store the indexed genome files from STAR 

Download Host Genome

下载基因组以及基因组注释信息,前者是fasta格式,后者是GTF或者GFF等格式,两者的版本要是同一版本。UCSC、ENSEMBL、NCBI和GENCODE提供了多个下载网址。注意每个网址对同一物种基因组的命名,它会反映出版本不同。下载压缩文件gz后,可以使用gunzip解压。

  1. GENCODE:

    # Download genome fasta file into the genome/ folder
    wget ftp://ftp.sanger.ac.uk/pub/gencode/Gencode_mouse/release_M12/GRCm38.p5.genome.fa.gz
    
    # Download annotation file into the annotation/ folder
    wget ftp://ftp.sanger.ac.uk/pub/gencode/Gencode_mouse/release_M12/gencode.vM12.annotation.gtf.gz
    
  2. ENSEMBL:

    # download genome 
    wget ftp://ftp.ensembl.org/pub/release-100/fasta/mus_musculus/dna/Mus_musculus.GRCm38.dna.primary.fa.gz
    # download annotation file
    wget ftp://ftp.ensembl.org/pub/release-100/gtf/mus_musculus/Mus_musculus.GRCm38.100.gtf.gz
    

The Procedures of Analysis pipeline

所需软件安装完成后,可以通过which命令查看是否已经export在环境中。分析流程主要包含11步,其中1-6步是fastq数据质控以及注释;7-12步是简单的统计分析;后续会扩展其他分析。

Step1: Quality Control by Fastqc

fastqc能够对二代测序数据的原始数据fastq进行质控检测,它能从多方面反映出fastq数据的质量情况(如碱基质量分布和GC含量等)

fastqc -o results/01.fastqc/ --noextract  raw_data/sampleid.fq.gz

Step2: Removing Low Quality Sequences with Trim_Galore

Trim_Galore是一款控制reads质量并且能够移除接头的软件。在第一步了解fastq质量后,设定过滤fastq碱基质量的阈值,对fastq数据进行质控。Trim_Galore包含了cutadapt和fastqc,前者目的是移除接头,或者是获取reads质量情况再根据阈值过滤低质量的reads。

trim_galore \
--quality 20 \
--fastqc \
--length 25 \
--output_dir results/02.trim/ \
input/sample.fastq

Step3: Removing rRNA Sequences with SortMeRNA

SortMeRNA是一款在宏基因组和宏转录组领域内对二代测序数据进行过滤、比对和OTU聚类的软件,其核心算法是根据种子序列快速比对敏感序列,该软件的目的是过滤宏转录组数据的核糖体DNA序列。在使用该软件前,需要下载核糖体DNA序列(fasta格式)并对DNA序列进行建立比对索引。(在测试过程,发现耗时很久,并且存在会对db报错,暂时没有解决)

# download the rRNA DNA sequences
wget https://github.com/biocore/sortmerna/tree/master/data/rRNA_databases/*fasta

# build index 
STAR \
	--runThreadN 6 \
	--runMode genomeGenerate \
	--genomeDir index/silva-euk-28s-id98 \
	--genomeFastaFiles ./silva-euk-28s-id98.fasta
# remove rRNA sequence 
rm -rf /home/sortmerna/run/  # debug for exist db
sortmerna \
	--ref /home/database/sortmerna_db/silva-bac-16s-id90.fasta \
	--reads ./result/02.trim/TAC_NC04_RNA_b1.r1_val_1.fq.gz \
	--reads ./result/02.trim/TAC_NC04_RNA_b1.r2_val_2.fq.gz \
	--aligned ./result/03.sortrRNA/TAC_NC04_aligned \
	--other ./result/03.sortrRNA/TAC_NC04_filtered \
	--fastx

Step4: Aligning to Genome with STAR-aligner

STAR(Spliced Transcripts Alignment to a Reference)是基于Sequential maximum mappable seed search方法将RNA_seq数据比对到参考基因组上的软件。

# create genome index for alignment
mkdir genome_index_star
STAR \
	--runThreadN 30 \
	--runMode genomeGenerate \
	--genomeDir genome_index_star \
	--genomeFastaFiles Mus_musculus.GRCm38.dna_sm.primary_assembly.fa \
	--sjdbGTFfile ./genome_annotation/Mus_musculus.GRCm38.100.gtf \
	--sjdbOverhang 99

# run aligning 
STAR \
	--genomeDir /home/database/Mus_musculus.GRCm38_release100/genome_index_star \
	--readFilesIn ./result/03.sortrRNA/HF07_filtered.fq \
	--runThreadN 10 \
	--outSAMtype BAM SortedByCoordinate \
	--outFileNamePrefix ./result/04.aligment_v2/HF07 \
	--quantMode GeneCounts #\
	#--readFilesCommand zcat        # for gz files

Step5: Summarizing Gene Counts with featureCounts (subread)

subread是一个包含多个高效处理二代测序数据的软件的包,其中featureCounts能够从比对结果SAM/BAM和注释信息文件(annotation files GTF)获取genomic features(genes, exons,promoter,gene bodies, genomic bins和chromosomal locations)等。

# bam/sam files
dirlist=$(ls -t ./result/04.aligment/*.bam | tr '\n' ' ')
# obtain the features
featureCounts \
-a /home/database/Mus_musculus.GRCm38_release100/genome_annotation/Mus_musculus.GRCm38.100.gtf -o /home/project/Heart_failure/Assay/00.RNA_seq/result/05.genecount/final_count_v2.tsv \
-t exon \
-g gene_name \
--primary \
-T 10 \
$dirlist

Step6: Generating analysis report with multiqc

MultiQC可以综合多个软件的日志文件最后形成一个统一的报告文件,方便后续审视结果。

multiqc ./result/ --outdir result/06.multiQC

Step7: Importing Gene Counts into R/Rstudio

在将数据导入R前,需要了解不同数据库对基因ID的编码方式。大部分基因都有自己的5种类型ID,特定的基因如miRNA在miRBase中有自己的ID (NCBI的entrez ID及gene symbol,Ensembl的gene ID,UCSC的gene ID,KEGG的gene ID)。ID之间的关系参考bioDBnet网址信息。

请添加图片描述

  1. Entrez id: Entrez是NCBI是美国国立生物技术信息中心(National Center for BiotechnologyInformation)的检索系统。NCBI的Gene数据库包含了不同物种的基因信息,其中每一个基因都被编制一个唯一的识别号ID(因此不同生物或者同属不同种的生物间的同源基因编号也不相同), 这个ID就叫做Entrez ID,就是基因身份证啦。目前通用的是Entrez id,也就是gene id。

    Entrez的第一个版本由NCBI于1991年在CD -ROM上发布,当时核酸序列来自GenBank和Protein Data Bank(PDB)数据库,蛋白序列来自GenBank、Protein Information Resource (PIR)、SWISS-PROT、PDB以及Protein Research Foundation (PRF)数据库,还从MEDLINE数据库(现在是PubMed)整合了文献摘要。

    Gene:基因序列注释+检索,目前共有61118个人类的记录,68389个小鼠的记录(含有功能基因、假基因、预测基因等)

  2. Gene symbol: HUGO Gene Symbol(也叫做HGNC Symbol,即基因符号)是HGNC组织对基因进行命名描述的一个缩写标识符

  3. Ensembl id: 由英国的Sanger研究所以及欧洲生物信息学研究所(EMBI-EBI)联合共同协作开发的一套基因信息标记系统。 PS: 不同物种的基因ID是不同的

  4. HGNC id: HGNC(人类基因命名委员会)由美国国家人类基因组研究所(NHGRI)和 Wellcome Trust(英国)共同资助,其中的每个基因只有一个批准的基因symbol。HGNC ID是HGNC数据库分配的基因编号,每一个标准的Symbol都有对应的HGNC ID 。我们可以用这个编号,在HGNC数据库中搜索相关的基因。例如:HGNC:11998。

  5. Gene Name: Gene Name是经过HGNC批准的全基因名称;对应于上面批准的符号(Gene Symbol)。例如TP53对应的Gene Name就是:tumor protein p53。

  6. UCSC id: UCSC的ID以uc开头,BRCA1对应的就是uc002ict.4

基因ID转换:

常常在Entrez gene ID与Ensembl gene ID以及gene ID与gene symbol之间转换 ,常用的工具就是

  1. clusterProfiler: 使用方法:`bitr(geneID, fromType, toType, OrgDb, drop = TRUE)``

    ``geneID是输入的基因ID,fromType是输入的ID类型,toType是输出的ID类型,OrgDb注释的db文件,drop`表示是否剔除NA数据

  2. biomaRt

    mouse_mart <- useMart(host="www.ensembl.org",biomart="ENSEMBL_MART_ENSEMBL", 
                            dataset="mmusculus_gene_ensembl")
    mouse_ensemble_gene_id <- gene_count_format$Geneid
    mouse_gene_all <- getBM(attributes=c('ensembl_gene_id', 'entrezgene_id', "hgnc_symbol",
                                           'external_gene_name', 'mgi_symbol', 
                                           'transcript_biotype', 'description'),
                                  filters='ensembl_gene_id',
                                  values=mouse_ensemble_gene_id, mart=mouse_mart)
    

读入数据

### load packages
library(dplyr)
library(tibble)
library(data.table)
library(DESeq2)
library(stringr)
### load data 
prof <- fread("final_count_v2.tsv")
phen <- read.csv("phenotype_20200629.csv")
### curation data 
gene_count_format <- prof %>% dplyr::select(c("Geneid", ends_with("bam"))) %>% 
      dplyr::rename_at(vars(ends_with("bam")), funs(str_replace(., "./result/04.aligment/", ""))) %>%
      dplyr::rename_at(vars(ends_with("bam")), funs(str_replace(., "Aligned.sortedByCoord.out.bam", ""))) 

处理数据:Differential Expression Gene by DESeq2 packages

Deseq2fun <- function(metaData, countData, 
                      group_col=c("TAC", "TAC_NC"),
                      occurence=0.5, ncount=10){
  # metaData <- phen
  # countData <- gene_count_format
  # group_col <- c("TAC", "TAC_NC")
  # occurence <- 0.5
  # ncount <- 10
  
  # get overlap 
  sid <- intersect(metaData$SampleID, colnames(countData))
  meta <- metaData %>% filter(SampleID%in%sid) %>% 
        filter(Group%in%group_col) %>%
        mutate(Group=factor(Group, levels = group_col)) %>%
        column_to_rownames("SampleID") 
  
  # quality control
  count <- countData %>% column_to_rownames("Geneid") %>% 
    dplyr::select(rownames(meta)) %>% 
    rownames_to_column("Type") %>% 
    filter(apply(dplyr::select(., -one_of("Type")), 1, function(x){sum(x != 0)/length(x)}) > occurence) %>%
            data.frame(.) %>% 
    column_to_rownames("Type")
  count <- count[rowSums(count) > ncount, ]
  
  # judge no row of profile filter
	if (nrow(count) == 0) {
		stop("No row of profile to be choosed\n")
	}
  
  # determine the right order between profile and phenotype 
  for(i in 1:ncol(count)){ 
    if (!(colnames(count) == rownames(meta))[i]) {
      stop(paste0(i, " Wrong"))
    }
  }
  
  dds <- DESeqDataSetFromMatrix(countData=count, 
                              colData=meta,
                              design=~Group)
  
  dds <- DESeq(dds)
  res <- results(dds, pAdjustMethod = "fdr", alpha = 0.05) %>% na.omit()
  res <- res[order(res$padj), ]
  return(list(dds=dds,results=res))
}

TAC_dge <- Deseq2fun(phen, gene_count_format)
TAC_dge_result <- TAC_dge$results 
TAC_dge_dds <- TAC_dge$dds
summary(TAC_dge_result)

Step8: Annotate Gene Symbols

除了上述两种ID转换方法,还存在其他ID转化方法。该方法结合DESeq2结果文件获取其他ID。使用org.Mm.eg.db包的mapIDs函数。

library(org.Mm.eg.db) 

# Add gene full name
TAC_dge_result$description <- mapIds(x = org.Mm.eg.db,
                              keys = row.names(TAC_dge_result),
                              column = "GENENAME",
                              keytype = "SYMBOL",
                              multiVals = "first")

# Add gene symbol
TAC_dge_result$symbol <- row.names(TAC_dge_result)

# Add ENTREZ ID
TAC_dge_result$entrez <- mapIds(x = org.Mm.eg.db,
                         keys = row.names(TAC_dge_result),
                         column = "ENTREZID",
                         keytype = "SYMBOL",
                         multiVals = "first")

# Add ENSEMBL
TAC_dge_result$ensembl <- mapIds(x = org.Mm.eg.db,
                          keys = row.names(TAC_dge_result),
                          column = "ENSEMBL",
                          keytype = "SYMBOL",
                          multiVals = "first")

# Subset for only significant genes (q < 0.05)
TAC_dge_sig <- subset(TAC_dge_result, padj < 0.05)

### output
# Write normalized gene counts to a .tsv file
write.table(x = as.data.frame(counts(TAC_dge_dds), normalized = T), 
            file = '../../Result/Profile/normalized_counts.tsv', 
            sep = '\t', 
            quote = F,
            col.names = NA)

# Write significant normalized gene counts to a .tsv file
write.table(x = counts(TAC_dge_dds[row.names(TAC_dge_sig)], normalized = T),
            file = '../../Result/Profile/normalized_counts_significant.tsv',
            sep = '\t',
            quote = F,
            col.names = NA)

# Write the annotated results table to a .tsv file
write.table(x = as.data.frame(TAC_dge_result), 
            file = "../../Result/Profile/results_gene_annotated.tsv", 
            sep = '\t', 
            quote = F,
            col.names = NA)

# Write significant annotated results table to a .tsv file
write.table(x = as.data.frame(TAC_dge_sig), 
            file = "../../Result/Profile/results_gene_annotated_significant.tsv", 
            sep = '\t', 
            quote = F,
            col.names = NA)

Step9: Plotting Gene Expression Data

从整体上看不同组的样本基因表达是否呈现自我成簇情况,这需要用到降维方法,通常适合转录组数据的降维方法有PCA和Rtsne等,这里使用PCA方法。后续会扩展其他方法。

library(ggplot2)
# Convert all samples to rlog
ddsMat_rlog <- rlog(TAC_dge_dds, blind = FALSE)

# Plot PCA by column variable
plotPCA(ddsMat_rlog, intgroup = "Group", ntop = 500) +
  geom_point(label=colnames(TAC_dge_dds), size = 5) + # Increase point size
  geom_hline(yintercept = 0, linetype = 2) + 
  geom_vline(xintercept = 0, linetype = 2) + 
  scale_y_continuous(limits = c(-20, 20)) + # change limits to fix figure dimensions
  ggtitle(label = "Principal Component Analysis (PCA)", 
          subtitle = "Top 500 most variable genes") +
  theme_bw() # remove default ggplot2 theme

基因表达情况还可以使用热图展示。

# Gather 30 significant genes and make matrix
mat <- assay(ddsMat_rlog[row.names(TAC_dge_sig)])[1:40, ]

# Choose which column variables you want to annotate the columns by.
annotation_col = data.frame(
  Group = factor(colData(ddsMat_rlog)$Group), 
  row.names = rownames(colData(ddsMat_rlog))
)

# Specify colors you want to annotate the columns by.
ann_colors = list(
  Group = c(TAC_NC = "lightblue", TAC = "darkorange")
)

library(pheatmap)
library(RColorBrewer)
# Make Heatmap with pheatmap function.
pheatmap(mat = mat, 
         color = colorRampPalette(brewer.pal(9, "YlOrBr"))(255), 
         scale = "row", # Scale genes to Z-score (how many standard deviations)
         annotation_col = annotation_col, # Add multiple annotations to the samples
         annotation_colors = ann_colors,# Change the default colors of the annotations
         fontsize = 10, # Make fonts smaller
         cellwidth = 10, # Make the cells wider
         show_rownames = T,
         show_colnames = T)

火山图能反应组间基因表达情况,通常分成3组:up-regulated, down-regulated 和 nonsignificant

# Gather Log-fold change and FDR-corrected pvalues from DESeq2 results
## - Change pvalues to -log10 (1.3 = 0.05)
data <- data.frame(gene = row.names(TAC_dge_result),
                   pval = -log10(TAC_dge_result$padj), 
                   lfc = TAC_dge_result$log2FoldChange) 

# Remove any rows that have NA as an entry
data <- na.omit(data)

# Color the points which are up or down
## If fold-change > 0 and pvalue > 1.3 (Increased significant)
## If fold-change < 0 and pvalue > 1.3 (Decreased significant)
data <- mutate(data, color = case_when(data$lfc > 0 & data$pval > 1.3 ~ "Increased",
                                       data$lfc < 0 & data$pval > 1.3 ~ "Decreased",
                                       data$pval < 1.3 ~ "nonsignificant"))

# Make a basic ggplot2 object with x-y values
ggplot(data, aes(x = lfc, y = pval, color = color)) + 
  ggtitle(label = "Volcano Plot", subtitle = "Colored by fold-change direction") +
  geom_point(size = 2.5, alpha = 0.8, na.rm = T) +
  scale_color_manual(name = "Directionality",
                     values = c(Increased = "#008B00", Decreased = "#CD4F39", nonsignificant = "darkgray")) +
  theme_bw(base_size = 14) + # change overall theme
  theme(legend.position = "right") + # change the legend
  xlab(expression(log[2]("TAC_NC" / "TAC"))) + # Change X-Axis label
  ylab(expression(-log[10]("adjusted p-value"))) + # Change Y-Axis label
  geom_hline(yintercept = 1.3, colour = "darkgrey") + # Add p-adj value cutoff line
  scale_y_continuous(trans = "log1p") # Scale yaxis due to large p-values

Step10: Finding Pathways from Differential Expressed Genes

通路富集分析(pathway enrichment analysis)是根据单个基因变化产生总体结论的好方法。 有时个体基因变化或大或小,均难以解释。 但是通过分析基因涉及的代谢途径,我们可以在更高层次上解释处理因素对基因的影响。常用富集分析的R包clusterProfiler

# Remove any genes that do not have any entrez identifiers
results_sig_entrez <- subset(TAC_dge_sig, is.na(entrez) == FALSE)

# Create a matrix of gene log2 fold changes
gene_matrix <- results_sig_entrez$log2FoldChange

# Add the entrezID's as names for each logFC entry
names(gene_matrix) <- results_sig_entrez$entrez

# KEGG
library(clusterProfiler)
kegg_enrich <- enrichKEGG(gene = names(gene_matrix),
                          organism = 'mouse',
                          pvalueCutoff = 0.05, 
                          qvalueCutoff = 0.10)

# Plot results
barplot(kegg_enrich, 
        drop = TRUE, 
        showCategory = 10, 
        title = "KEGG Enrichment Pathways",
        font.size = 8)

# GO 
go_enrich <- enrichGO(gene = names(gene_matrix),
                      OrgDb = 'org.Mm.eg.db', 
                      readable = T,
                      ont = "BP",
                      pvalueCutoff = 0.05, 
                      qvalueCutoff = 0.10)

# Plot results
barplot(go_enrich, 
        drop = TRUE, 
        showCategory = 10, 
        title = "GO Biological Pathways",
        font.size = 8)

Step11: Plotting KEGG Pathways

Pathview是一个软件包,可以使用KEGG标识符和对发现明显不同的基因进行覆盖倍数变化。 Pathview还可以与在KEGG数据库中找到的其他生物一起工作,并且可以绘制出特定生物的任何KEGG途径。

library(pathview)
pathview(gene.data = gene_matrix, 
         pathway.id = "04070", 
         species = "mouse")

Step12: Single Sample Gene-Set Enrichment Analysis

Single-sample GSEA (ssGSEA), an extension of Gene Set Enrichment Analysis (GSEA), calculates separate enrichment scores for each pairing of a sample and gene set. Each ssGSEA enrichment score represents the degree to which the genes in a particular gene set are coordinately up- or down-regulated within a sample.

ssGSEA富集分数表示通路的基因在样本中高低表达的程度,可以替代表达值。

# load packages
library(dplyr)
library(tibble)
library(data.table)
library(GSEABase)
library(GSVA)

# load data 
prof <- fread("../../Result/Profile/final_gene_hgnc.profile")
phen <- read.csv("../../Result/Phenotype/Heart_failure_phenotype_20200629.csv")
gene_set <- qusage::read.gmt("../../Result/GeneSetdb/msigdb.v7.1.symbols_v2.gmt") # msigdb: geneset

# Build ExpressionSet object 
get_expr_Set <- function(assay, meta){
  
  require(convert)
  colnames(assay)[1] <- "name"
  assay <- assay[rowSums(assay[, -1]) > 0, ]
  dat_assay <- setDT(assay)[, lapply(.SD, mean), keyby = name] %>% 
    column_to_rownames("name") 
  #if(length(subtype)>0){
  #  dat_meta <- meta %>% filter(Group%in%subtype)
  #}else{
    dat_meta <- meta
  #}
  sid <- intersect(dat_meta$SampleID, colnames(dat_assay))
  dat_meta.cln <- dat_meta %>% filter(SampleID%in%sid) %>%
    column_to_rownames("SampleID")
  dat_assay.cln <- dat_assay %>% rownames_to_column("tmp") %>%
    dplyr::select(c(tmp, rownames(dat_meta.cln))) %>%
    column_to_rownames("tmp")
  #dat_meta.cln$SampleID == colnames(dat_assay.cln)
  exprs <- as.matrix(dat_assay.cln)
  adf <-  new("AnnotatedDataFrame", data=dat_meta.cln)
  experimentData <- new("MIAME",
        name="Jin Chao", lab="Gong gdl Lab",
        contact="dong_ming@grmh-gdl.cn",
        title="Heart-failure Experiment",
        abstract="The gene ExpressionSet",
        url="www.grmh-gdl.cn",
        other=list(notes="Created from text files"))
  expressionSet <- new("ExpressionSet", exprs=exprs,
                       phenoData=adf, 
                       experimentData=experimentData)
  
  return(expressionSet)
}
gene_expr_set <- get_expr_Set(prof, phen)

# choose gene_set 
gene_set_KEGG <- gene_set[grep("^KEGG", names(gene_set))]

# ssgsea by GSVA packages
heartfailure_ssgsea <- gsva(gene_expr_set, 
                               gene_set_KEGG,
                               method="ssgsea", 
                               min.sz=5, 
                               max.sz=500,
                               kcdf="Poisson")

exprs(heartfailure_ssgsea) %>% t() %>% data.frame() %>% rownames_to_column("tmp") %>% arrange(tmp) %>% column_to_rownames("tmp") %>% t() %>% data.frame() -> dat2

# heatmap 
library(pheatmap)
library(RColorBrewer)
pheatmap(mat = dat2[c(1:20), ], 
         color = colorRampPalette(brewer.pal(9, "YlOrBr"))(255), 
         scale = "row", # Scale genes to Z-score (how many standard deviations)
         # annotation_col = annotation_col, # Add multiple annotations to the samples
         # annotation_colors = ann_colors,# Change the default colors of the annotations
         cluster_row = FALSE, 
         #cluster_cols = FALSE,
         fontsize = 10, # Make fonts smaller
         cellwidth = 15, # Make the cells wider
         show_colnames = T)

Reference

  1. RNAseq-workflow;

  2. 超精华生信ID总结

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/776430.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

使用 C# 和 CefSharp 构建的全功能且快速的 Web 浏览器

SharpBrowser项目介绍 使用 C# 和 CefSharp 构建的全功能且快速的 Web 浏览器&#xff1a;SharpBrowser。 SharpBrowser是一个基于高性能的CefSharp渲染器的开源C# Web浏览器&#xff0c;采用MIT许可证。相较于Google Chrome&#xff0c;它在渲染网页时略有提升速度。该项目选…

Open3D 在点云中构建八叉树

目录 一、概述 二、代码实现 2.1关键函数 2.2完整代码 三、实现效果 3.1原始点云 3.2构建后点云 一、概述 八叉树&#xff08;Octree&#xff09;是一种树状数据结构&#xff0c;用于递归地将3D空间分割成较小的立方体。八叉树特别适用于3D计算机图形学、点云处理和空间…

伯克利、斯坦福和CMU面向具身智能端到端操作联合发布开源通用机器人Policy,可支持多种机器人执行多种任务

不同于LLM或者MLLM那样用于上百亿甚至上千亿参数量的大模型&#xff0c;具身智能端到端大模型并不追求参数规模上的大&#xff0c;而是指其能吸收大量的数据&#xff0c;执行多种任务&#xff0c;并能具备一定的泛化能力&#xff0c;如笔者前博客里的RT1。目前该领域一个前沿工…

代理模式详解、RESTFul风格、Spring IOC

Day49 代理模式proxy 概念&#xff1a; 代理(Proxy)是一种设计模式&#xff0c;提供了对目标对象另外的访问方式&#xff0c;即通过代理对象访问目标对象.这样做的好处是:可以在目标对象实现的基础上,增强额外的功能操作,即扩展目标对象的功能. 代理模式分为静态代理和动态代理…

西安石油大学 课程习题信息管理系统(数据库课设)

主要技术栈 Java Mysql SpringBoot Tomcat HTML CSS JavaScript 该课设必备环境配置教程&#xff1a;&#xff08;参考给出的链接和给出的关键链接&#xff09; JAVA课设必备环境配置 教程 JDK Tomcat配置 IDEA开发环境配置 项目部署参考视频 若依框架 链接数据库格式注…

部署LVS+keepalived做网站的高可用,高负载。

LVSkeepalived keepalived背景 针对LVS的辅助工具&#xff0c;主要提供故障切换与健康检查。 工作场景&#xff1a;作为调度器的双机热备&#xff0c;以及节点服务器的健康检查以及故障切换&#xff08;删除条目&#xff09;。 借鉴了VRRP协议来实现高可用。 keepalived部署…

鸿蒙开发设备管理:【@ohos.vibrator (振动)】

振动 说明&#xff1a; 开发前请熟悉鸿蒙开发指导文档&#xff1a;gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md点击或者复制转到。 本模块首批接口从API version 8开始支持。后续版本的新增接口&#xff0c;采用上角标单独标记接口的起始版本。 导入模块 imp…

【网工】学习笔记1

windows&#xff1a;ipconfig ens40&#xff1a;和别人通信的网卡 lo本地回环和自己通信的网卡 ifconfig down/up 进程&#xff1a;运行起来的程序 使用浏览器访问网站&#xff1a;http&#xff1a;电脑上的程序和网站上的程序之间的通信。 主要用于服务器和客户端之间上传和…

Vue-Router4.0 报“Cannot read property ‘forEach‘ of undefined”

Vue-Router4.0在创建路由时 报“Cannot read property ‘forEach‘ of undefined” 解决办法 将路由规则名称更改为routes&#xff0c;否则报错 import { createWebHashHistory, createRouter } from vue-router; // 创建路由规定 const routes [{path: /login,name: login,co…

51单片机基础11——蓝牙模块控制亮灭

串口初试——蓝牙模块 蓝牙模块的使用1. 软硬件条件2. 蓝牙模块3. 代码(分文件处理之后的代码) 蓝牙模块的使用 1. 软硬件条件 单片机型号&#xff1a;STC89C52RC开发环境&#xff1a;KEIL4烧录软件串口通信软件&#xff1a;stc-isp蓝牙模块&#xff1a;HC-04LED模块(高电平点…

【数智化人物展】天云数据CEO雷涛:大模型连接数据库 为数智化提供高价值数据...

雷涛 本文由天云数据CEO雷涛投递并参与由数据猿联合上海大数据联盟共同推出的《2024中国数智化转型升级先锋人物》榜单/奖项评选。 大数据产业创新服务媒体 ——聚焦数据 改变商业 这几天&#xff0c;奥特曼讲SQL数据库和大模型结合起来会产生什么样的化学变化引起行业关注。为…

im即时通讯软件有哪些?WorkPlus安全专属移动数字化平台

IM即时通讯软件是为满足快速、即时沟通需求而设计的工具。在众多IM即时通讯软件中&#xff0c;WorkPlus作为一种安全专属移动数字化平台&#xff0c;为企业提供了全方位的移动办公解决方案&#xff0c;并注重信息安全和数据隐私保护。本文将介绍几种常见的IM即时通讯软件以及Wo…

【自动驾驶仿真在做什么——初学者总结(陆续补充)】

文章目录 基础概念自动驾驶级别再稍提一下ODD是什么&#xff1f; 自动驾驶仿真分类软件在环仿真硬件仿真 仿真究竟难在哪&#xff1f;关于lidar和radar区别一些名词解释 最近也是学习自动驾驶仿真相关知识&#xff0c;习惯去总结一下&#xff0c;方便自己回顾和总结&#xff0c…

layui-表单(输入框)

1.基本使用方法 先写一个表单元素块 form 加上layui-form 里面写行区块结构&#xff0c;如下&#xff1a; 2.输入框选项 placeholder默认文本 autocomplete自动填充 lay-verify required必填

2.5 C#视觉程序开发实例1----IO_Manager实现切换程序

2.5 C#视觉程序开发实例1----IO_Manager实现切换程序 1 IO_Manager中输入实现 1.0 IO_Manager中输入部分引脚定义 // 设定index 目的是为了今后可以配置这些参数、 // 输入引脚定义 private int index_trig0 0; // trig index private int index_cst 7; //cst index priva…

#招聘数据分析#2024年6月前程无忧招聘北上广深成渝对比情况

#招聘数据分析#2024年6月前程无忧招聘北上广深成渝对比情况 0、根据前程无忧不完全样本统计&#xff0c;北上广深成都重庆平均月工资从高到低依次为 北京15441元、上海14425元、深圳13310元、广州11192元、成都10539元、重庆10290。 1、成都招聘样本数全量35228个&#xff0c…

【论文阅读】-- Interactive Horizon Graphs:改进多个时间序列的紧凑可视化

Interactive Horizon Graphs: Improving the Compact Visualization of Multiple Time Series 摘要1 引言2 相关工作2.1 多个时间序列的可视化2.2 缩减折线图 &#xff08;RLC&#xff09;2.3 地平线图 &#xff08;HG&#xff09;2.4 大尺度和小尺度变异数据集2.5 多个时间序列…

Explore Synapse

rm -r dp-203 -f git clone https://github.com/MicrosoftLearning/dp-203-azure-data-engineer dp-203 cd dp-203/Allfiles/labs/01 ./setup.ps1 -- This is auto-generated code SELECTTOP 100 * FROMOPENROWSET(BULK https://datalakexxxxxxx.dfs.core.windows.net/fil…

vue css 链式布局模式

<div class"pp-wrap"> <div class"pp-left"><!--跳活动反思--><div class"even-box" v-for"(item,index) in trackingPtoPLeftList" :key"index" click"jumpReview(item)"><div …

嵌入式UI开发-lvgl+wsl2+vscode系列:6、布局(Layouts)

一、前言 这节总结一下整体页面的布局方式&#xff0c;lvgl的布局方式比较少&#xff0c;目前只有flex和grid两大类布局&#xff0c;即弹性布局和网格布局&#xff0c;弹性布局一般就是指定相对位置&#xff0c;网格布局就是将整个页面划分为网格状&#xff0c;我们做其它的UI…