我想就如何对大文件(数百万行或多行)进行子集化提供建议/帮助.
例如,
(1)我有大文件(数百万行,制表符分隔).我想要这个文件的一个子集,只有10000到100000的行.
(2)我有大文件(数百万列,制表符分隔).我想要这个文件的一个子集,只有10000到100000的列.
我知道有头,尾,切,分裂,awk或sed等工具.我可以用它们做简单的子集化.但是,我不知道该怎么做.
你能提出任何建议吗?提前致谢.
添加辅助y轴,缩放原始y轴之一.这个话题并不新鲜.它已被触及时间,例如在这个ggplot2 google groups线程上.继哈德利的意见,我试图通过添加辅助y轴geom_vline,geom_segment和geom_text.但是,它仍然很难看.
所以我会请求你帮助完善它.我想很多ggplot2用户会对这个主题感兴趣并且更喜欢你的专业知识或贡献.提前致谢.
#########################################
# what I have gotten.
library(ggplot2)
# build up a box plot
p <- ggplot(mtcars, aes(factor(cyl), mpg))
# add the secondary y axis on right side of the plot
p + geom_boxplot() + geom_vline(xintercept = 3.5) +
geom_segment(aes(x=3.49, y=c(7,14,21,28), xend = 3.52, yend = c(7,14,21,28))) +
geom_text(aes(x=3.55, y=c(7,14,21,28), label=c(7,14,21,28)))
Run Code Online (Sandbox Code Playgroud) 我希望您通过删除具有相同值的列来修剪文件.
# the file I have (tab-delimited, millions of columns)
jack 1 5 9
john 3 5 0
lisa 4 5 7
Run Code Online (Sandbox Code Playgroud)
# the file I want (remove the columns with the same value in all lines)
jack 1 9
john 3 0
lisa 4 7
Run Code Online (Sandbox Code Playgroud)
你能否就这个问题给我任何指示?我更喜欢sed或awk解决方案,或者可能是perl解决方案.
提前致谢.最好,
数据文件中有两个数字列.我需要按第一列的间隔(例如100)计算第二列的平均值.
我可以用R编程这个任务,但我的R代码对于一个相对较大的数据文件来说真的很慢(数百万行,第一列的值在1到33132539之间变化).
在这里,我展示了我的R代码.我怎么能把它调到更快?其他解决方案是perl,python,awk或shell.
提前致谢.
(1)我的数据文件(制表符分隔,数百万行)
5380 30.07383\n
5390 30.87\n
5393 0.07383\n
5404 6\n
5428 30.07383\n
5437 1\n
5440 9\n
5443 30.07383\n
5459 6\n
5463 30.07383\n
5480 7\n
5521 30.07383\n
5538 0\n
5584 20\n
5673 30.07383\n
5720 30.07383\n
5841 3\n
5880 30.07383\n
5913 4\n
5958 30.07383\n
Run Code Online (Sandbox Code Playgroud)
(2)我想得到的,这里间隔= 100
intervals_of_first_columns, average_of_2nd column_by_the_interval
100, 0\n
200, 0\n
300, 20.34074\n
400, 14.90325\n
.....
Run Code Online (Sandbox Code Playgroud)
(3)R代码
chr1 <- 33132539 # set the limit for the interval
window <- 100 # set the size of interval
spe …Run Code Online (Sandbox Code Playgroud) 我有两个整数向量.我想确定在由第一个载体调节的第二个载体中呈现的连续整数序列的间隔(该载体可以看作是一个因子,通过该因子,第二个载体可以分成几个组).
在这里,我为我的问题提出了一个假人.
在第二个向量的一组(由第一向量定义)中的数据,整数单调增加.
my.data <- data.frame(
V1=c(rep(1, 10), rep(2, 9), rep(3,11)),
V2=c(seq(2,5), seq(7,11), 13, seq(4, 9), seq(11,13), seq(1, 6), seq(101, 105))
)
Run Code Online (Sandbox Code Playgroud)
我想要的是:
预期成绩:
1, 2, 5 \n
1, 7, 11 \n
1, 13, 13 \n
2, 4, 9 \n
2, 11, 13 \n
3, 1, 6 \n
3, 101, 105 \n
Run Code Online (Sandbox Code Playgroud) 我想听听你如何插入标题行(文件中的所有行)到另一个文件(更大,几GB)的说明.我更喜欢使用Unix/awk/sed方式完成这项工作.
# header I need to insert to another, they are in a file named "header".
##fileformat=VCFv4.0
##fileDate=20090805
##source=myImputationProgramV3.1
##reference=1000GenomesPilot-NCBI36
##phasing=partial
##INFO=<ID=NS,Number=1,Type=Integer,Description="Number of Samples With Data">
##INFO=<ID=DP,Number=1,Type=Integer,Description="Total Depth">
##INFO=<ID=AF,Number=.,Type=Float,Description="Allele Frequency">
##INFO=<ID=AA,Number=1,Type=String,Description="Ancestral Allele">
##INFO=<ID=DB,Number=0,Type=Flag,Description="dbSNP membership, build 129">
##INFO=<ID=H2,Number=0,Type=Flag,Description="HapMap2 membership">
##FILTER=<ID=q10,Description="Quality below 10">
##FILTER=<ID=s50,Description="Less than 50% of samples have data">
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
##FORMAT=<ID=GQ,Number=1,Type=Integer,Description="Genotype Quality">
##FORMAT=<ID=DP,Number=1,Type=Integer,Description="Read Depth">
##FORMAT=<ID=HQ,Number=2,Type=Integer,Description="Haplotype Quality">
#CHROM POS ID REF ALT QUAL FILTER INFO
Run Code Online (Sandbox Code Playgroud) 我想通过 Unix 和 awk 命令有条件地将列中的值替换为一个文件中同一行中特定列的值。
例如,我有 myfile.txt(3 行,5 列,制表符分隔):
1 A . C .
2 C T . T
3 T C C .
Run Code Online (Sandbox Code Playgroud)
有 ”。” 在第 3 至 5 列中。我想替换那些“.”。第 3 - 5 列中的值与第 2 列中的值位于同一行。
您能给我指点一下吗?
我想对我在awk中遇到的问题提供帮助或指导.
我有一个包含超过5个字段的制表符分隔文件.我想输出除前5个字段之外的字段.
你能告诉我如何写一个awk脚本来完成这个任务吗?
最好的,jianfeng.mao
请注意以下类型的评论:
我的文件中有很多字段.不同的行具有不同数量的字段.每行的字段数不是标准的.