rnaseq-R

library(ballgown)

library(RSkittleBrewer)

library(genefilter)

library(dplyr)

library(devtools)

patient_data = read.csv("D:/AAA-台式机-LY-WorkSpace/Patient_data-10samples.csv")

ten_sample = ballgown(dataDir = "D:/AAA-台式机-LY-WorkSpace/ballgown-10samples", samplePattern = "sample", pData=patient_data)

#dataDir告知数据路径, samplePattern则依据样本的名字来,pheno_data则指明了样本数据的关系,

#这个里面第一列样本名需要和ballgown下面的文件夹的样本名一样,不然会报错

ten_sample_filt = subset(ten_sample, "rowVars(texpr(ten_sample))>1", genomesubset=TRUE)

#滤掉低丰度的基因,这里选择过滤掉样本间差异少于一个转录本的数据

transcript_fpkm_filt = texpr(ten_sample_filt, 'FPKM')

gene_expression_filt = gexpr(ten_sample_filt)

full_table_filt <- texpr(ten_sample_filt , 'all')

#you can get a table with all the information in your ballgown object (bg) , doing:

#full_table <- texpr(bg , 'all')

#The table will include: transcript id, chromosome, strand, start positon, end position, number of exons, length, gene id, gene name, and the FPKM values for each sample.

#Btw, I have noticed that sometimes the same gene id (MSTRG.xxxx) can correspond to more than one gene name, so don't fully rely on the gene_id as a unique identifier.

# 赋予调色板五个指定颜色

tropical= c('darkorange', 'dodgerblue','hotpink', 'limegreen', 'yellow')

palette(tropical)

# 当然rainbow()函数也可以完成这个任务

palette(rainbow(5))

# 提取FPKM值

fpkm = texpr(ten_sample,meas="FPKM")

#方便作图将其log转换,+1是为了避免出现log2(0)的情况

fpkm = log2(fpkm+1)

# 作图

boxplot(fpkm,las=2,ylab='log2(FPKM+1)')

# plotTranscripts函数可以根据指定基因的id画出在特定区段的转录本

# 可以通过sample函数指定看在某个样本中的表达情况,这里选用id=6, sample=105TRA

plotTranscripts(ballgown::geneIDs(ten_sample)[6], ten_sample, main=c('Gene MSTRG.455 in sample 105TRA'), sample=c('105TRA'))

write.csv(full_table_filt,file = "D:/AAA-台式机-LY-WorkSpace/full_table_filt.CSV")

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 原文:http://blog.sina.com.cn/s/blog_751bd9440102v72b.html 一...
    简单点lili阅读 9,635评论 0 8
  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 13,150评论 0 13
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,160评论 0 10
  • 我的父亲母亲都是普通的农民,每天过着面朝黄土背朝天的生活。生于农村,我无法选择。年少时,也曾羡慕过别人光鲜亮丽的人...
    莫离西西阅读 2,463评论 0 0
  • 《你,耳朵红了》 那年冬天 风吹 雪飞 遇见你 不敢靠近 静默追随 心思漫动 佯装着 翘盼着 等待着 你 无意转身...
    苏雨之书阅读 2,778评论 14 4