Skip to content

go plot

Xu Gang edited this page Nov 11, 2020 · 3 revisions
library(ggplot2)
# read data.
tumor_up=read.table('/home/xugang/data/xtail_v1/david_go_0916/tumor_te_up.txt',sep="\t",header=T)

# log10 of p value.
tumor_up$log10Pvalue=-(log10(tumor_up$PValue))
tumor_up$position=0
tumor_up=tumor_up[with(tumor_up, order(Fold.Enrichment)), ]
tumor_up$Term <- factor(tumor_up$Term, levels = tumor_up$Term[order(tumor_up$Fold.Enrichment)])

data <- ggplot(tumor_up, aes(position,Term ))
data + geom_point(aes(size = Fold.Enrichment, fill = log10Pvalue), shape = 21, alpha = 0.7) + scale_fill_gradient(low = "#6abaf8", high = "#142d46") +
  labs(title="Tumor TE up GO",fill='-log10 P value', size="Fold Enrichment",
        x ="", y = "Term")+
  scale_size_continuous(range = c(1, 7.5) )+ theme(axis.text.x = element_blank(),axis.ticks = element_blank(),plot.margin = margin(0.1,0.4,0.1,4, "cm"),panel.grid.minor = element_blank())

# read data.
tumor_up=read.table('/home/xugang/data/xtail_v1/david_go_0916/tumor_te_down.txt',sep="\t",header=T)

# log10 of p value.
tumor_up$log10Pvalue=-(log10(tumor_up$PValue))
tumor_up$position=0

tumor_up=tumor_up[with(tumor_up, order(Fold.Enrichment)), ]
tumor_up$Term <- factor(tumor_up$Term, levels = tumor_up$Term[order(tumor_up$Fold.Enrichment)])

data <- ggplot(tumor_up, aes(position,Term ))
data + geom_point(aes(size = Fold.Enrichment, fill = log10Pvalue), shape = 21, alpha = 0.7) + scale_fill_gradient(low = "#6abaf8", high = "#142d46") +
  labs(title="Tumor TE down GO",fill='-log10 P value', size="Fold Enrichment",
        x ="", y = "Term")+
  scale_size_continuous(range = c(1, 7.5) )+ theme(axis.text.x = element_blank(),axis.ticks = element_blank(),plot.margin = margin(0.1,0.4,0.1,4, "cm"),panel.grid.minor = element_blank())

# read data.
tumor_up=read.table('/home/xugang/data/xtail_v1/david_go_0916/adjacent_te_up.txt',sep="\t",header=T)

# log10 of p value.
tumor_up$log10Pvalue=-(log10(tumor_up$PValue))
tumor_up$position=0

tumor_up=tumor_up[with(tumor_up, order(Fold.Enrichment)), ]
tumor_up$Term <- factor(tumor_up$Term, levels = tumor_up$Term[order(tumor_up$Fold.Enrichment)])

data <- ggplot(tumor_up, aes(position,Term ))
data + geom_point(aes(size = Fold.Enrichment, fill = log10Pvalue), shape = 21, alpha = 0.7) + scale_fill_gradient(low = "#6abaf8", high = "#142d46") +
  labs(title="Adjacent TE up GO",fill='-log10 P value', size="Fold Enrichment",
        x ="", y = "Term")+
  scale_size_continuous(range = c(1, 7.5) )+ theme(axis.text.x = element_blank(),axis.ticks = element_blank(),plot.margin = margin(0.1,0.4,0.1,4, "cm"),panel.grid.minor = element_blank())

# read data.
tumor_up=read.table('/home/xugang/data/xtail_v1/david_go_0916/adjacent_te_down.txt',sep="\t",header=T)

# log10 of p value.
tumor_up$log10Pvalue=-(log10(tumor_up$PValue))
tumor_up$position=0

tumor_up=tumor_up[with(tumor_up, order(Fold.Enrichment)), ]
tumor_up$Term <- factor(tumor_up$Term, levels = tumor_up$Term[order(tumor_up$Fold.Enrichment)])

data <- ggplot(tumor_up, aes(position,Term ))
data + geom_point(aes(size = Fold.Enrichment, fill = log10Pvalue), shape = 21, alpha = 0.7) + scale_fill_gradient(low = "#6abaf8", high = "#142d46") +
  labs(title="Adjacent TE down GO",fill='-log10 P value', size="Fold Enrichment",
        x ="", y = "Term")+
  scale_size_continuous(range = c(1, 7.5) )+ theme(axis.text.x = element_blank(),axis.ticks = element_blank(),plot.margin = margin(0.1,0.4,0.1,4, "cm"),panel.grid.minor = element_blank())

library(ggplot2)
# read data.
go=read.table('/home/xugang/go_data/go.top.txt',sep="\t",header=T)

go
Term	position	PValue	Fold.Enrichment	order
<chr>	<int>	<dbl>	<dbl>	<int>
ribosomal large subunit biogenesis	0	0.070501781	26.867200	1
mitotic sister chromatid segregation	0	0.070501781	26.867200	2
mRNA polyadenylation	0	0.078627589	23.988571	3
regulation of calcium ion-dependent exocytosis	0	0.097318150	19.190857	4
SRP-dependent cotranslational protein	0	0.030751184	10.718298	5
viral transcription	0	0.042313335	8.995714	6
nonsense-mediated decay	0	0.047185957	8.466555	7
mRNA splicing, via spliceosome	0	0.003955277	7.563964	8
translational initiation	0	0.060590280	7.354161	9
protein homooligomerization	0	0.094227942	5.692203	10
keratan sulfate catabolic process	1	0.053676561	35.880342	11
morphogenesis of an epithelium	1	0.062341862	30.754579	12
response to toxic substance	1	0.058046314	7.598190	13
negative regulation of apoptotic process	1	0.057779615	2.838884	14
go$Term <- factor(go$Term, levels = go$Term[order(-go$order)])
data <- ggplot(go, aes(position,Term ))
data + geom_point(aes(size = Fold.Enrichment, fill = PValue), shape = 21, alpha = 0.7) + scale_fill_gradient(low = "#FF0001", high = "#3212FF") +
  labs(title="GO",fill='P value', size="Fold Enrichment",  
        x ="", y = "Term")+ xlim(-1, 2)+
  scale_size_continuous(range = c(1, 7.5) )+ theme(axis.text.x = element_blank(),axis.ticks = element_blank(),plot.margin = margin(0.1,0.4,0.1,4, "cm"),panel.grid.minor = element_blank())

Clone this wiki locally