gpt4 book ai didi

linux - 按列和一般编号对床文件进行排序

转载 作者:太空宇宙 更新时间:2023-11-04 09:58:05 25 4
gpt4 key购买 nike

我有一个这样的床文件:

#chrom  start   end     value
chr1 11323785 11617177 0.862170087976540
chr1 12645605 13926923 0.934891485809683
chr1 14750216 15119039 0.945945945945946
chr1 18102157 19080189 0.895174708818636
chr1 29491029 30934636 0.892526250772082
chr1 33716472 35395979 0.911901081916538
chr2 13108570 15600747 0.902084152575698
chr2 15694926 17648720 0.887029288702929
chr2 17724731 18378756 0.000837797619047
chr2 19442702 19551715 0.304347826090000
chr2 20745595 21842850 0.000430434255552
chr3 59553227 59708848 1
chr3 59790383 61504477 0.772413793103448
chr3 62167230 62508631 0.230046948357259
chr3 62589695 63775476 0.979970326409496
chr3 64469064 65348951 0.980019980019980
chr3 66972860 67511514 0.850828729281768
chr6 84151925 85317754 0.900999091734787
chr6 85428902 86109751 0.961119751166407
chr6 86456610 87828399 0.963746223564955
chr6 88048916 88236474 0.886227544910183
chr6 88568774 89535038 0.976602238046796
chrX 123088093 128394210 0.855213637369936
chrX 130635879 133327791 0.895311949242157
chrX 134061433 134880328 0.878120411160059
chrX 135187116 135597436 0.940133037694013

我的目标是使用 sort 来“排序”为一般数字 (1e-3 < 0.05)。我尝试:

sort -g -k4 filename
sort -g -k4 filename

awk '{print $4}' small.bed | sort -g

但是我没有得到我所要求的。最后一个可以很好地对浮点值进行排序,但是我只打印了第四列。有什么建议吗?

感谢您的宝贵时间。

保罗

最佳答案

为什么不使用数字排序?任何非数字键的计算结果都将为零,因此您无需剪掉“# header”行。

$ sort -n -k4,4 filename
#chrom start end value
chr2 20745595 21842850 0.000430434255552
chr2 17724731 18378756 0.000837797619047
chr3 62167230 62508631 0.230046948357259
chr2 19442702 19551715 0.304347826090000
chr3 59790383 61504477 0.772413793103448
chr3 66972860 67511514 0.850828729281768
chrX 123088093 128394210 0.855213637369936
chr1 11323785 11617177 0.862170087976540
chr6 88048916 88236474 0.886227544910183
chr2 15694926 17648720 0.887029288702929
chr1 29491029 30934636 0.892526250772082
chr1 18102157 19080189 0.895174708818636
chrX 130635879 133327791 0.895311949242157
chr6 84151925 85317754 0.900999091734787
chr2 13108570 15600747 0.902084152575698
chr1 33716472 35395979 0.911901081916538
chr1 12645605 13926923 0.934891485809683
chr1 14750216 15119039 0.945945945945946
chr6 85428902 86109751 0.961119751166407
chr6 86456610 87828399 0.963746223564955
chr6 88568774 89535038 0.976602238046796
chr3 62589695 63775476 0.979970326409496
chr3 64469064 65348951 0.980019980019980
chr3 59553227 59708848 1

关于linux - 按列和一般编号对床文件进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58525081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com