R语言作差异基因火山图时无论我怎么修改选择显著差异条件,都有差异基因落在log2FC 条件外的区域
详细代码如下:
# step 1 :input data
getwd() # get pathway
setwd("C:/Users/Administrator/Desktop/RNA_seq Course")
cuff_diff=read.csv("HRFI_vs_LRFI.All.csv",header = T) # read data
log2FC=cuff_diff$log2FC # firgue out log2_fold_change
log10_p_value=log10(cuff_diff$Pvalue)*-1
length(log2FC)
length(log10_p_value)
plot(y=log10_p_value,x=log2FC,pch=16,col=rgb(0,0,1,0.1),ylim = c(0,9),xlim = c(-10,10))
log10_p_value_filter=log10_p_value[log10_p_value>=0.01]
log2FC_filter=log2FC[log10_p_value>=0.01
length(log10_p_value_filter)
length(log2FC_filter)
plot(x=log2FC_filter,y=log10_p_value_filter,ylim=c(0,10.5),xlim=c(-10,10),col=rgb(0,0,1,0.1),pch=16)
col_vector=rep(rgb(0,0,1,0.5),length(log2FC_filter))
length(col_vector)
col_vector[log10_p_value_filter > -log10(0.05)]=rgb(1,0,0,0.5)
length(col_vector[log10_p_value_filter > -log10(0.05)])
plot(x=log2FC_filter,y=log10_p_value_filter,ylim=c(0,10.5),xlim=c(-10,10),col=col_vector,pch=16)
select_sign_vector=abs(log2FC)>0.585 & cuff_diff$Pvalue<0.05
table(select_sign_vector)
select_sign_vector
write.csv(cuff_diff[select_sign_vector,],file = "C:/Users/Administrator/Desktop/RNA_seq Course/select_sign_for_qinchuan_LOG2_FC_pvalue.csv")
col_vector_filter=rep(rgb(0,0,1,0.5),length(log2FC_filter))
col_vector_filter[select_sign_vector]=rgb(1,0,0,0.5)
length(col_vector_filter)
length(col_vector[select_sign_vector])
length(log10_p_value)
length(log2FC_filter)
length(log10_p_value_filter)
plot(x=log2FC_filter,y=log10_p_value_filter,ylim=c(0,12),xlim=c(-10,10),col=col_vector_filter,pch=16,bty="O")
plot(x=log2FC_filter,y=log10_p_value_filter,ylim=c(0,10.5),xlim=c(-10,10),col=col_vector,pch=16,bty="l")
abline(h=c(-1*log10(0.01),-1*log10(0.05)),v=c(-0.585,0.585),lwd=c(2,2),lty=2,col=c("#4C5B61",col=rgb(0.5,0,0)))
阅读全文
收起全文