私のデータは、ヘッダーなしで、必ずしも同じ種類の情報を含むとは限らない列を使用して、特定の方法で配置されています。その一部は、次を使用して作成できます。
data <- textConnection("rs123,22,337647,C,T
1,7385,0.4156,-0.0019,0.0037
1,16550,0.959163800640972,-0.0241,0.0128
1,17218,0.0528,0.015,0.039
rs193,22,366349,C,T
1,7385,0.3708,0.0017,0.0035
1,16550,0.793259111116741,-0.0028,0.009
1,17218,0.9547,-0.016,0.033
rs194,22,366300,NA,NA
0,0,0,0,0
0,0,0,0,0
0,0,0,0,0
rs118,22,301327,C,T
1,7385,0.0431,-0.0085,0.0077
1,16550,0.789981059331214,0.0036,0.0092
1,17218,0.99,-0.057,0.062
rs120,22,497528,C,G
1,7385,0.0716,0.0012,0.0073
1,16550,0.233548238634496,-0.0033,0.0064
1,17218,0.4563,-0.002,0.015
rs109,22,309825,A,G
1,5520,0.8611,2e-04,0.0044
0,0,0,0,0
1,17218,0.9762,0.076,0.044
rs144,22,490068,C,T
0,0,0,0,0
0,0,0,0,0
1,17218,0.2052,-0.013,0.032")
mydata <- read.csv(data, header = F, sep = ",", stringsAsFactors=FALSE)
私の質問は次のとおりです。「NA」を含む行を grep/awk 行に書き込むことができます (これらはデータを含まない SNP です)。
grep -v 'NA' file.in > file.out
しかし、次の3行も削除するように指定するにはどうすればよいですか? すべてゼロを含むすべての行を削除したくはありません。「NA」を含む SNP を含む行に続くすべてゼロを含む行のみを削除します。
ご意見ありがとうございます。