Skip to content

Commit

Permalink
Plot update
Browse files Browse the repository at this point in the history
  • Loading branch information
quanc1989 committed Oct 29, 2020
1 parent a256dc6 commit 3327eb2
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 80 deletions.
97 changes: 97 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,100 @@ ggplot(data=data_plot[data_plot$SVTYPE!='TRA',], aes(x=SVLEN, color = SVTYPE)) +
ylab("SV Count")
```
![SV distribution](plots/sv.len.freqploy.png)

* SV length group
```R
data_sv_group <- plyr::count(data_plot,c('GROUP_LEN','GROUP_SUPP'))
data_sv_group$label <- 0

for (type_sv in levels(data_sv_group$GROUP_LEN)){
data_sv_group[data_sv_group$GROUP_LEN==type_sv,]$label <- sum(data_sv_group[data_sv_group$GROUP_LEN==type_sv,]$freq)
}
ggplot(data_sv_group, aes(x = GROUP_LEN, y = freq, fill = GROUP_SUPP)) +
geom_bar(position = "fill",stat = "identity") +
scale_y_continuous(labels = scales::percent_format(), expand = expand_scale(mult = .1)) +
coord_flip() +
theme_minimal()+
theme(legend.title=element_blank(),
legend.position="bottom",
legend.spacing.x = unit(0.1, 'cm'),
legend.key.size=unit(0.3, 'cm'),
legend.text = element_text(size = 6,face = "bold"),
axis.text.x = element_text(size = 6,face = "bold"),
axis.text.y = element_text(size = 6,face = "bold"),
axis.title.y = element_text(size = 6,face = "bold"),
axis.title.x.bottom = element_text(margin = margin(-10,0,0,0))) +
scale_fill_manual(values=config_color_group_supp) +
xlab("") +
ylab("") +
geom_text(aes(label = label, y= ..prop..), stat= "count", hjust = -0.1, size=1)
```
![SV distribution](plots/sv.len.group_supp.bar.png)

* SV type group
```R
data_sv_group <- plyr::count(data_plot,c('SVTYPE','GROUP_SUPP'))
data_sv_group$SVTYPE <- factor(data_sv_group$SVTYPE)
data_sv_group$label <- 0

for (type_sv in levels(data_sv_group$SVTYPE)){
data_sv_group[data_sv_group$SVTYPE==type_sv,]$label <- sum(data_sv_group[data_sv_group$SVTYPE==type_sv,]$freq)
}
data_sv_group$SVTYPE <- factor(data_sv_group$SVTYPE, levels = c( 'DEL', 'INS', 'DUP', 'INV', 'TRA'))

ggplot(data_sv_group, aes(x = SVTYPE, y = freq, fill = GROUP_SUPP)) +
geom_bar(position = "fill",stat = "identity") +
scale_y_continuous(labels = scales::percent_format(), expand = expand_scale(mult = .1)) +
coord_flip() +
theme_minimal()+
theme(legend.title=element_blank(),
legend.position="bottom",
legend.spacing.x = unit(0.1, 'cm'),
legend.key.size=unit(0.3, 'cm'),
legend.text = element_text(size = 6,face = "bold"),
axis.text.x = element_text(size = 6,face = "bold"),
axis.text.y = element_text(size = 6,face = "bold"),
axis.title.y = element_text(size = 6,face = "bold"),
axis.title.x.bottom = element_text(margin = margin(-15,0,0,0))) +
scale_fill_manual(values=config_color_group_supp) +
xlab("") +
ylab("") +
geom_text(aes(label = label, y= ..prop..), stat= "count", hjust = -0.1, size=2)
```
![SV distribution](plots/sv.type.group_supp.bar.png)

* SV breakpoints CI
```R
data_tmp <- data_plot

data_tmp$GROUP_CI <- NA
data_tmp[data_tmp$MAXCI_POS<=1000&data_tmp$MAXCI_END<=1000,]$GROUP_CI <- '500bp-1kb'
data_tmp[data_tmp$MAXCI_POS<=500&data_tmp$MAXCI_END<=500,]$GROUP_CI <- '250bp-500bp'
data_tmp[data_tmp$MAXCI_POS<=250&data_tmp$MAXCI_END<=250,]$GROUP_CI <- '100bp-250bp'
data_tmp[data_tmp$MAXCI_POS<=100&data_tmp$MAXCI_END<=100,]$GROUP_CI <- '0-100bp'
data_tmp$GROUP_CI <- factor(data_tmp$GROUP_CI, levels = c('0-100bp', '100bp-250bp', '250bp-500bp', '500bp-1kb'))


df.new<-ddply(data_tmp,.(GROUP_SUPP),plyr::summarise,
prop=prop.table(table(GROUP_CI)),
SUPP=names(table(GROUP_CI)))
df.new$SUPP <- factor(df.new$SUPP, levels = c('0-100bp', '100bp-250bp', '250bp-500bp', '500bp-1kb'))
ggplot(df.new, aes(SUPP, prop, fill=GROUP_SUPP)) +
geom_bar(stat="identity",position = 'dodge') +
theme_minimal()+
theme(legend.title=element_blank(),
legend.position=c(0.5,0.9),
legend.direction = 'horizontal',
legend.spacing.x = unit(0.1, 'cm'),
legend.key.size=unit(0.3, 'cm'),
legend.text = element_text(size = 6,face = "bold"),
axis.text.x = element_text(size = 6,face = "bold"),
axis.text.y = element_text(size = 6,face = "bold"),
axis.title.y = element_text(size = 6,face = "bold"),
axis.title.x = element_text(size = 6,face = "bold")
) +
scale_fill_manual(values=config_color_group_supp) +
xlab("Max Interval of Breakpoints") +
ylab("Prop")
```
![SV distribution](plots/breakpoints.ci.group_supp.prop.png)
80 changes: 0 additions & 80 deletions pipeline.plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,6 @@ dev.off()

###################### Brepoints CI ###################################
data_tmp <- data_plot
# data_tmp$MAXCI_POS <- data_tmp$MAXCI_END
# data_tmp <- rbind(data_tmp,data_plot)
# data_tmp$MAXCI_POS <- data_tmp$MAXCI_END/2
# data_tmp <- data_tmp[data_tmp$SUPP>1,]

data_tmp$GROUP_CI <- NA
data_tmp[data_tmp$MAXCI_POS<=1000&data_tmp$MAXCI_END<=1000,]$GROUP_CI <- '500bp-1kb'
Expand All @@ -410,32 +406,11 @@ data_tmp[data_tmp$MAXCI_POS<=250&data_tmp$MAXCI_END<=250,]$GROUP_CI <- '100bp-25
data_tmp[data_tmp$MAXCI_POS<=100&data_tmp$MAXCI_END<=100,]$GROUP_CI <- '0-100bp'
data_tmp$GROUP_CI <- factor(data_tmp$GROUP_CI, levels = c('0-100bp', '100bp-250bp', '250bp-500bp', '500bp-1kb'))

## to do 需要画出每种SVTYPE在各个CI区间的比例,以及每种Group_SUPP在各个区间的比例
pdf(file = paste(prefix_filename,'breakpoints.ci','pdf',sep = '.'), width = 4, height = 3)
# png(filename = paste(prefix_filename,'breakpoints.ci.png',sep = '.'), width = 1200, height = 1000, res = val_res)
ggplot(data=data_tmp, aes(x=MAXCI_POS, fill = GROUP_SUPP)) +
geom_histogram() +
theme_minimal()+
theme(legend.title=element_blank(),
# legend.position='bottom',
legend.position=c(0.9,0.9),
legend.spacing.x = unit(0.1, 'cm'),
legend.key.size=unit(0.3, 'cm'),
legend.text = element_text(size = 6,face = "bold"),
axis.text.x = element_text(size = 6,face = "bold", angle = 45),
axis.text.y = element_text(size = 6,face = "bold"),
axis.title.y = element_text(size = 6,face = "bold"),
axis.title.x = element_text(size = 6,face = "bold")) +
scale_fill_manual(values=config_color_group_supp) +
xlab('Max Interval') +
ylab("SV Count")
dev.off()

df.new<-ddply(data_tmp,.(GROUP_SUPP),plyr::summarise,
prop=prop.table(table(GROUP_CI)),
SUPP=names(table(GROUP_CI)))
df.new$SUPP <- factor(df.new$SUPP, levels = c('0-100bp', '100bp-250bp', '250bp-500bp', '500bp-1kb'))
# png(filename = paste(prefix_filename,'breakpoints.ci.group_supp.prop.png',sep = '.'), width = 1200, height = 1000, res = val_res)
pdf(file = paste(prefix_filename,'breakpoints.ci.group_supp.prop','pdf',sep = '.'), width = 4, height =3)
ggplot(df.new, aes(SUPP, prop, fill=GROUP_SUPP)) +
geom_bar(stat="identity",position = 'dodge') +
Expand All @@ -456,61 +431,6 @@ ggplot(df.new, aes(SUPP, prop, fill=GROUP_SUPP)) +
ylab("Prop")
dev.off()

df.new<-ddply(data_tmp,.(GROUP_LEN),plyr::summarise,
prop=prop.table(table(GROUP_CI)),
SUPP=names(table(GROUP_CI)))
df.new$SUPP <- factor(df.new$SUPP, levels = c('0-100bp', '100bp-250bp', '250bp-500bp', '500bp-1kb'))
# png(filename = paste(prefix_filename,'breakpoints.ci.group_len.prop.png',sep = '.'), width = 1200, height = 1000, res = val_res)
pdf(file = paste(prefix_filename,'breakpoints.ci.group_len.prop','pdf',sep = '.'), width = 4, height = 3)
ggplot(df.new, aes(SUPP, prop, fill=GROUP_LEN)) +
geom_bar(stat="identity",position = 'dodge') +
theme_minimal()+
theme(legend.title=element_blank(),
legend.position=c(0.9,0.9),
legend.direction = 'vertical',
legend.spacing.x = unit(0.1, 'cm'),
legend.key.size=unit(0.3, 'cm'),
legend.text = element_text(size = 6,face = "bold"),
axis.text.x = element_text(size = 6,face = "bold"),
axis.text.y = element_text(size = 6,face = "bold"),
axis.title.y = element_text(size = 6,face = "bold"),
axis.title.x = element_text(size = 6,face = "bold"),
axis.title.x.bottom = element_text(margin = margin(15,0,0,0))
) +
scale_fill_manual(values=config_color_group_len) +
xlab("Max Interval of Breakpoints") +
ylab("Prop")
dev.off()

data_sv_group <- plyr::count(data_tmp,c('GROUP_SUPP','GROUP_CI'))
data_sv_group$label <- 0

for (type_sv in levels(factor(data_sv_group$GROUP_SUPP))){
data_sv_group[data_sv_group$GROUP_SUPP==type_sv,]$label <- sum(data_sv_group[data_sv_group$GROUP_SUPP==type_sv,]$freq)
}
# png(filename = paste(prefix_filename,'breakpoints.ci.group_supp.bar.png',sep = '.'), width = 1200, height = 1000, res = val_res)
pdf(file = paste(prefix_filename,'breakpoints.ci.group_supp.bar','pdf',sep = '.'), width = 8, height = 6)
ggplot(data_sv_group, aes(x = GROUP_SUPP, y = freq, fill = forcats::fct_rev(GROUP_CI))) +
geom_bar(position = "fill",stat = "identity") +
scale_y_continuous(labels = scales::percent_format(), expand = expand_scale(mult = .1)) +
coord_flip() +
theme_minimal()+
theme(legend.title=element_blank(),
legend.position="bottom",
legend.spacing.x = unit(0.1, 'cm'),
legend.key.size=unit(0.5, 'cm'),
legend.text = element_text(size = 5,face = "bold"),
axis.text.x = element_text(size = 10,face = "bold"),
axis.text.y = element_text(size = 10,face = "bold"),
axis.title.y = element_text(size = 10,face = "bold"),
axis.title.x.bottom = element_text(margin = margin(-10,0,0,0))) +
scale_fill_manual(values=config_color_group_len) +
xlab("") +
ylab("") +
geom_text(aes(label = label, y= ..prop..), stat= "count", hjust = -0.1, size=2)
dev.off()


###################### Brepoints & Repeat ###################################
data_tmp <- data_plot[,c('SVID','SVTYPE','GROUP_LEN','SVLEN','Repeats_type_right', 'Repeats_type_left', 'GCcontent_left','GCcontent_right', 'GROUP_SUPP')]
data_tmp <- rbind(data_tmp, data_tmp)
Expand Down
Binary file added plots/breakpoints.ci.group_supp.prop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plots/sv.len.group_supp.bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plots/sv.type.group_supp.bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3327eb2

Please sign in to comment.