如何计算LD衰减一半的距离?

发布日期:2025-03-07 14:37    点击次数:130

大家好,我是邓飞。

LD衰减图,可以形象的查看群体LD衰减的情况。LD衰减是由于连锁不平衡所致,LD衰减速度在不同物种或者不同亚种中差异不同,通常用LD衰减到一般的距离来作为群体的衰减距离(还有其它计算方法),如果LD衰减很快,则在进行GWAS分析时需要更多的位点才能达到一定的精度。(计算群体GWAS分析所需要的最少SNP个数)

另外,LD衰减也可以反应群体受选择的情况,一般来说,野生群体比驯化改良群体LD衰减快,异花授粉比自花授粉植物LD衰减快。

之前写过推文教程(LD衰减图绘制--PopLDdecay)

图片

出的图是上面这个样子的,如果人为查看的衰减一半的距离,大约是100kb左右,如何更科学的计算呢?

网上看到了一个perl脚本可以根据PopLDdecay的结果自动计算衰减一半的距离:(https://www.jianshu.com/p/8205dbcb3839)

代码如下:calculate_LDlength.pl

#!/usr/bin/perl -wuse strict;my $in0 = $ARGV[0]; ##- sarson.LD.stat.gzopen IN0, "gzip -dc $in0 | ";<IN0>;my $firstLine = <IN0>;chomp($firstLine);my @firstLine = split(/\t/, $firstLine);my $max = $firstLine[1];close IN0;my %dis2Value = ();open IN1, "gzip -dc $in0 | ";<IN1>;while(<IN1>){  chomp;  my @temp = split(/\t/, $_);  $dis2Value{$temp[0]} = $temp[1];}close IN1;my $halfValue = $max/2;for my $key1(sort {$a<=>$b} keys %dis2Value){    my $next = $key1 + 1;        if(exists $dis2Value{$next}) {        my $currentValue = $dis2Value{$key1};       my $nextValue = $dis2Value{$next};             if($currentValue >= $halfValue && $nextValue < $halfValue){          print "Processing ", $in0, "\n";          print "max LD: r2: ", $max, "\n";          print "half LD:  r2: ", $halfValue, "\t", "LD length: ", $key1, "\n";           last;       }     }}

例如PopLDdecay生成的文件为:LDdecay.stat.gz,用上面的程序处理这个文件,就能得到衰减一半的距离,调用方法:

$ perl calculate_LDlength.pl LDdecay.stat.gz Processing LDdecay.stat.gzmax LD: r2: 0.8551half LD:  r2: 0.42755  LD length: 67

可以看到LD衰减一半的值是0.427,对应的距离是67kb。

以上。

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报。