跟着Nature Genetics学作图:R语言ggplot2频率分布图展示TE的identity

论文

High-quality de novo assembly of the apple genome and methylome dynamics of early fruit development

https://www.nature.com/articles/ng.3886/

苹果基因组ng.3886.pdf

今天的推文我们来试着复现一下论文中的Figure3c

image.png

论文中对应的图注

Distribution of sequence identity values between genomic copies and consensus repeats in the GDDH13 assembly (based on 2,198,722 data points). The relative frequencies per percentage of identity of the Helitron, TIR, LTR, LINE, SINE and unclassified TEs (NoCat) are represented in different colors.

论文中的部分数据存储在这个链接

https://iris.angers.inra.fr/gddh13/the-apple-genome-downloads.html

image.png

这个TE注释里有identity这个值(这里我不太确定是不是用到的这个值来画图)

文件的格式

image.png

写个脚本把SINE LINE 和Helitron的值提取出来

import sys
import re

input_txt = sys.argv[1]
output_txt = sys.argv[2]



pattern01 = sys.argv[3]

regexp01 = re.compile(pattern01)

pattern02 = "ID=\S+;"

regexp02 = re.compile(pattern02)

fr = open(input_txt,'r')

ID_list = []

for line in fr:
    if 'TargetDescription' in line and len(regexp01.findall(line)) >= 1:
        ID_list.append(regexp02.findall(line)[0].replace("ID=","").replace(";",""))
        
        
print(len(ID_list))

fr.close()

fr = open(input_txt,'r')

pattern03 = "Parent=\S+;"
regexp03 = re.compile(pattern03)

pattern04 = "Identity=\S+"
regexp04 = re.compile(pattern04)

fw = open(output_txt,'w')
for line in fr:
    if "Parent" in line and regexp03.findall(line)[0].replace("Parent=","").replace(";","") in ID_list:
        if len(regexp04.findall(line)) >= 1:
            fw.write("%s=%s\n"%(regexp04.findall(line)[0],pattern01))

fw.close()

运行脚本

python appleNG.py GDDH13_1-1_TE.gff3 line_identity.txt LINE
python appleNG.py GDDH13_1-1_TE.gff3 sine_identity.txt SINE
python appleNG.py GDDH13_1-1_TE.gff3 helitron_identity.txt Helitron

输出文件格式

image.png

接下来是画图代码

library(tidyverse)

dfsine<-read_delim("sine_identity.txt",
               delim = "=",
               col_names = FALSE)
dfline<-read_delim("line_identity.txt",
                   delim = "=",
                   col_names = FALSE)
dfhelitron<-read_delim("helitron_identity.txt",
                   delim = "=",
                   col_names = FALSE)

df<-bind_rows(dfsine,dfline,dfhelitron)



ggplot(data=df,aes(x=X2,stat(density),color=X3))+
  geom_freqpoly(binwidth=1,linewidth=3)+
  theme_classic()+
  scale_x_continuous(expand = expansion(mult = c(0,0)),
                     limits = c(60,100))+
  scale_y_continuous(expand = expansion(mult = c(0,0)),
                     limits = c(0,0.1))+
  labs(y="Frequency",x="Identity")+
  scale_color_manual(values = c("#2d2884","#c2a20c","#6497d0"),
                     name="Element")
image.png

和论文中的图并不能完全对应上,不太清楚论文中是怎么来统计这个值的

怎么根据这个identity的值算插入时间暂时还没有搞明白

这个图的峰和binwidth的值设置是有关系,binwidth如果改动,line的第二个峰也会有影响,不太明白这个参数应该怎么设置

论文中对这个图的描述文字

To investigate the evolutionary history of TEs in the apple genome, we plotted the distribution of identity values between genomic copies and their consensus sequences (Fig. 3c). Distributions for all classes of repeats showed a peak at 77% identity. By considering the mutation rate that has been reported for LTR-RTs in plants (1.3 × 10−8 base substitutions per site per year40,41), we estimated the age of those insertions as described by the International Human Genome Sequencing Consortium42. We concluded that the peak at 77% identity corresponded to an insertion age of around 21 million years ago (Mya) (Fig. 3c).
We also noted a second peak, particularly for LINE elements, at 98% identity that corresponded to a TE burst at ~1.6 Mya

TEs also have an important role in structuring genomes. The in-depth TE annotation we performed showed a major TE burst in apple that we estimated to have happened around 21 Mya. This affected all types of TEs, suggesting that the precursor of the modern apple underwent environmental changes with resulting stresses that led to the activation of these TEs50. The observed TE burst corresponds to the Miocene epoch (23 Mya to 5 Mya) and may coincide with two events: the divergence between pear and apple48 and an uplift event occurring at the Tian Shan mountains51, which cover the region where the ancestor of the apple originates from52. We hypothesize that these TE bursts, which presumably must have been very different in the predecessor of pear and apple, have contributed to the diversification, and possibly even speciation, of these plants.

推文记录的是自己的学习笔记,很可能存在错误,请大家批判着看

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 161,873评论 4 370
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 68,483评论 1 306
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 111,525评论 0 254
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,595评论 0 218
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 53,018评论 3 295
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,958评论 1 224
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 32,118评论 2 317
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,873评论 0 208
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,643评论 1 250
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,813评论 2 253
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,293评论 1 265
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,615评论 3 262
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,306评论 3 242
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,170评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,968评论 0 201
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 36,107评论 2 285
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,894评论 2 278

推荐阅读更多精彩内容