我有一个名为rRna_RDP_taxonomy_phylum的文件,其中包含以下数据:
364 "Firmicutes" 39.31
244 "Proteobacteria" 26.35
218 "Actinobacteria" 23.54
65 "Bacteroidetes" 7.02
22 "Fusobacteria" 2.38
6 "Thermotogae" 0.65
3 unclassified_Bacteria 0.32
2 "Spirochaetes" 0.22
1 "Tenericutes" 0.11
1 Cyanobacteria 0.11
Run Code Online (Sandbox Code Playgroud)
我正在使用此代码在R中创建饼图:
if(file.exists("rRna_RDP_taxonomy_phylum")){
family <- read.table ("rRna_RDP_taxonomy_phylum", sep="\t")
piedat <- rbind(family[1:7, ],
as.data.frame(t(c(sum(family[8:nrow(family),1]),
"Others",
sum(family[8:nrow(family),3])))))
png(file="../graph/RDP_phylum_low.png", width=600, height=550, res=75)
pie(as.numeric(piedat$V3), labels=piedat$V3, clockwise=TRUE, col=graph_col, main="More representative Phyliums")
legend("topright", legend=piedat$V2, cex=0.8, fill=graph_col)
dev.off()
png(file="../graph/RDP_phylm_high.png", width=1300, height=850, res=75)
pie(as.numeric(piedat$V3), labels=piedat$V3, clockwise=TRUE, col=graph_col, main="More representative Phyliums")
legend("topright", legend=piedat$V2, cex=0.8, fill=graph_col)
dev.off()
}
Run Code Online (Sandbox Code Playgroud)
我一直在使用这个代码用于不同的数据文件,它工作正常,但随着文件显示adobe它崩溃返回以下消息:
Error …Run Code Online (Sandbox Code Playgroud) 我使用awk从两个不同的文件中提取和计算信息,我想将结果合并到列中的单个文件中(例如,第1列和第2列中第一个文件的输出以及第3和第4列中第二个文件的输出) ).
输入文件包含:
文件1
SRR513804.1218581HWI-ST695_116193610:4:1307:17513:49120 SRR513804.16872HWI ST695_116193610:4:1101:7150:72196 SRR513804.2106179HWI-
ST695_116193610:4:2206:10596:165949 SRR513804.1710546HWI-ST695_116193610:4:2107:13906:128004 SRR513804.544253
Run Code Online (Sandbox Code Playgroud)
文件2
>SRR513804.1218581HWI-ST695_116193610:4:1307:17513:49120
TTTTGTTTTTTCTATATTTGAAAAAGAAATATGAAAACTTCATTTATATTTTCCACAAAG
AATGATTCAGCATCCTTCAAAGAAATTCAATATGTATAAAACGGTAATTCTAAATTTTAT
ACATATTGAATTTCTTTGAAGGATGCTGAATCATTCTTTGTGGAAAATATAAATGAAGTT
TTCATATTTCTTTTTCAAAT
Run Code Online (Sandbox Code Playgroud)
要解析第一个文件,我这样做:
awk '
{
s = NF
center = $1
}
{
printf "%s\t %d\n", center, s
}
' file1
Run Code Online (Sandbox Code Playgroud)
要解析第二个文件,我这样做:
awk '
/^>/ {
if (count != "")
printf "%s\t %d\n", seq_id, count
count = 0
seq_id = $0
next
}
NF {
long = length($0)
count = count+long
}
END{
if (count != "")
printf "%s\t %d\n", seq_id, count
}
' …Run Code Online (Sandbox Code Playgroud) 我用以下代码制作了一个图表:
library(ggplot2)
dat <- mtcars
# Make the x-axis labels very long for this example
dat$car <- paste0(rownames(mtcars),rownames(mtcars),rownames(mtcars),rownames(mtcars))
ggplot(dat, aes (x=car,y=hp)) +
geom_bar(stat ="identity", fill="#009E73",colour="black") +
theme_bw() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
Run Code Online (Sandbox Code Playgroud)
在x轴上表示不同蛋白质的名称,当这个名称太长时我会遇到麻烦,因为在图形中只看到名称而不是图形.有没有办法减少X标签字符串的字符,而不是"打印"更大的图形?
像这样的东西:
Thisisaveryveryveryloooooongprotein - > Thisisavery [...]
谢谢!
也许这是一个简单的问题,但我检查了一些问题,但无法找到适合我的问题的解决方案。我有一个大文件,分为 10 列。在第 9 列中,有一个字符串,其中包含用点分隔的数字和字母。像这样的东西:
id.aa.xx.1.rr.2930
id.ee.yy.2.gres.1
id.ww.3232
Run Code Online (Sandbox Code Playgroud)
我想要的是删除最后一个点之后字符串的最后一部分。那么输出应该是这样的:
id.aa.xx.1.rr
id.ee.yy.2.gres
id.ww
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,字符串没有相同的模式,所以我不能使用 split 函数,也不能使用 python 中的 rsplit() ,因为点后面的最后一个字段每个字符串有 1 到 6 个字符。
python 或 awk 有什么简单的解决方案吗?