params <- list(alignments = "/tmp/Rtmp5cPR2G/Rinst1301ae76720f34/amplican/extdata/results/alignments/events_filtered_shifted_normalized.csv", config_summary = "/tmp/Rtmp5cPR2G/Rinst1301ae76720f34/amplican/extdata/results/config_summary.csv") ## ----load data, message=F, warning=FALSE, include=FALSE----------------------- library(amplican) library(ggplot2)对齐<-data.table :: fread(params $ alignments)data.table :: setdf(校准)config <-data.frame(data.table :: fread :: fread(params $ config_summary))高度<-plot_height <-plot_height(length)(config $ group))## ------------------------------------------------------------------x = as.factor(group),y = log10(reads + 1),订单= group,filt = group)) + geom_boxplot() + ylab('reads + 1的数量 + 1,log10缩放') + xlab('group('group)') +主题(legend.position ='none',axis.text = element_text(size = 12),axis.title = element_text(size = 14,face = 14,face ='bold')) + coord_flip()## --------------plot_f_per,echo = false,fig.height = height,fig.width = 14,消息= f,警告= false---- config $ f_percentage < - (config $ primer_dimer + config + config $ low_score) * 100/config $ read $ read reads config config config config config config config config for config config for f_percentage [is.nan(config $ f_percentage)] <-0 ggplot(data = config,aes(x = as.factor(group),y = f_percentage,order conder = group,fill = group)) + geom_boxplot() + xlab('group')+ ylab('过滤读取百分比') +主题(axis.text = element_text(size = 12),axis.title = element_text(size = 14,face ='bold'),legend.position.position ='none') +ylim(0,100) + coord_flip()## ----绘图indel百分比,echo = false,图。<-config $ reads_edited * 100/config $ reads_filtered config $ edit_percentage [is.nan(config $ edit_percentage)] <-0 ggplot(data = config,aes(x = as.factor(group),y = edit_percentage,y = edit_percentage,order_percentage,order_percentage =组,填充= group)) + geom_boxplot() + xlab('group') + ylab('读取(未过滤)具有编辑'的读数百分比') + theme(axis.text = element_text(size = 12),axis。title = element_text(size=14, face = 'bold'), legend.position = 'None') + ylim(0,100) + coord_flip() ## ----plot_frameshift_per, echo=FALSE, fig.height=height,图。width = 14,消息= f,parning = false--- config $ frameshift_percentage <-- config $ reads_frameshifted * 100/config $ reads_filtered config $ frameshift_percentage [is.nan(config $ frameshift_percentage) = config, aes(x = as.factor(Group), y = frameshift_percentage, order = Group, fill = Group)) + geom_boxplot() + xlab('Group') + ylab('Percentage of reads (not filtered) that have frameshift') + theme(axis.text = element_text(size=12), axis.title = element_text(size=14,face = 'bold'), legend.position = 'None') + ylim(0, 100) + coord_flip() ## ----plot read heterogeneity, echo=FALSE, fig.height=height + 1, fig.width=14, message=F, warning=FALSE---- plot_heterogeneity(alignments, config, level = 'Group') ## ----del-Betty, echo = F, results = "asis", message=F, warning=F------------- amplican::metaplot_deletions(alignments, config, "Group", "Betty") ## ----ins-Betty, echo = F, results = "asis", message=F, warning=F------------- amplican::metaplot_insertions(alignments, config, "Group", "Betty") ## ----mis-Betty, echo = F, results = "asis", message=F, warning=F------------- amplican::plot_mismatches(alignments, config, "Group", "Betty") ## ----del-Tom, echo = F, results = "asis", message=F, warning=F--------------- amplican::metaplot_deletions(alignments, config, "Group", "Tom") ## ----ins-Tom, echo = F, results = "asis", message=F, warning=F--------------- amplican::metaplot_insertions(alignments, config, "Group", "Tom") ## ----mis-Tom, echo = F, results = "asis", message=F, warning=F--------------- amplican::plot_mismatches(alignments, config, "Group", "Tom") ## ----plot_alignments, results='asis', echo=F, message=F, warning=F------------ alignments <- alignments[alignments$consensus & alignments$overlaps, ] alignments$strand <- "+" # strand does not matter after consensus filtering src = sapply(unique(config$Group), function(i) { knitr::knit_expand(text = c( "## Group {{i}} \n", "### Deletions \n", paste('```{r del-{{i}}, echo = F, results = "asis", ', 'message=F, warning=F}', collapse = ''), 'amplican::metaplot_deletions(alignments, config, "Group", "{{i}}")', '```\n', "### Insertions", paste('```{r ins-{{i}}, echo = F, results = "asis", ', 'message=F, warning=F}', collapse = ''), 'amplican::metaplot_insertions(alignments, config, "Group", "{{i}}")', '```\n', "### Mismatches", paste('```{r mis-{{i}}, echo = F, results = "asis", ', 'message=F, warning=F}', collapse = ''), 'amplican::plot_mismatches(alignments, config, "Group", "{{i}}")', '```\n')) }) # knit the source res = knitr::knit_child(text = src, quiet = TRUE) cat(res, sep = '\n')