2012-10-26 91 views
-2

我的代码显示如下:如何绘制与非分类x轴(格)的柱状图

read.table("GO.txt",header=T,sep=',')->go 
library(lattice) 
barchart(go[,1]~go[,2],horiz=F,ylim=c(30,29666), 
layout=c(1,1),stack=F, 
auto.key=list(space='right'), 
ylab="Yes", 
scales=list(x=list(rot=45),y=list(log = T))) 

不过,我不希望绘制与排序X的图表,又该我做? 格子排序我的数据,我不需要。

数据:

number_of_A-Unigene Class Ontology 
    45 biological adhesion biological_process 
    5328 biological regulation biological_process 
    8 carbon utilization biological_process 
    6 cell killing biological_process 
    119 cell proliferation biological_process 
    3248 cellular component organization or biogenesis biological_process 
    16594 cellular process biological_process 
    244 death biological_process 
    4354 developmental process biological_process 
    3547 establishment of localization biological_process 
    917 growth biological_process 
    429 immune system process biological_process 
    3716 localization biological_process 
    30 locomotion biological_process 
    15726 metabolic process biological_process 
    4182 multicellular organismal process biological_process 
    1673 multi-organism process biological_process 
    877 negative regulation of biological process biological_process 
    10 nitrogen utilization biological_process 
    11 pigmentation biological_process 
    640 positive regulation of biological process biological_process 
    4808 regulation of biological process biological_process 
    2462 reproduction biological_process 
    2437 reproductive process biological_process 
    7812 response to stimulus biological_process 
    190 rhythmic process biological_process 
    2001 signaling biological_process 
    2 sulfur utilization biological_process 
    44 viral reproduction biological_process 
    19852 cell cellular_component 
    1763 cell junction cellular_component 
    19852 cell part cellular_component 
    31 extracellular matrix cellular_component 
    9 extracellular matrix part cellular_component 
    686 extracellular region cellular_component 
    30 extracellular region part cellular_component 
    3698 macromolecular complex cellular_component 
    9829 membrane cellular_component 
    3432 membrane part cellular_component 
    1439 membrane-enclosed lumen cellular_component 
    15252 organelle cellular_component 
    6024 organelle part cellular_component 
    1753 symplast cellular_component 
    216 antioxidant activity molecular_function 
    15917 binding molecular_function 
    15103 catalytic activity molecular_function 
    2 channel regulator activity molecular_function 
    433 electron carrier activity molecular_function 
    319 enzyme regulator activity molecular_function 
    8 metallochaperone activity molecular_function 
    522 molecular transducer activity molecular_function 
    708 nucleic acid binding transcription factor activity molecular_function 
    26 nutrient reservoir activity molecular_function 
    102 protein binding transcription factor activity molecular_function 
    6 protein tag molecular_function 
    613 receptor activity molecular_function 
    1039 structural molecule activity molecular_function 

5翻译调节活性molecular_function 2478转运活性molecular_function

+0

请张贴'dput(去)',而不是剪切和粘贴您的打印数据。 – BenBarnes

回答

0

“格子” 把你的因子变量和默认的(字母)顺序排列它们。您可以更改订单。也许:

go[,2] <- factor(go[,2] unique(as.character(go[,2]))) 

这应该设置在同一顺序的水平,他们将第一次出现,如果你是通过翻阅。另一个等值,虽然更巴洛克,转让将是:

go[,2] <- factor(go[,2] as.character(go[,2][!duplicated(go[,2])])) 

然后做你的情节。 (我没有试图输入你的数据,他们看起来太杂乱了,实际上,我确实给了它一个选项卡作为分隔符,如果他们曾经有过标签,那么他们会丢失它们,并且元素的数量是可变的如果白色空间是分隔符)

在重复的问题,使用数据标签进行排序:

go[[2]] <- factor(go[[2]], levels=unique(as.character(go[[2]]))) 

+0

3Q,但你的建议是没用的......它仍然被排序。 – Sandy

+0

恐怕什么是'无用'就是你的榜样。我解释了为什么它不能用read.table(...,header = TRUE)加载。如果您提供输入代码,则可能有进展的可能性。 –

+0

好吧,非常感谢,我的数据代码在这里发布。 http://goo.gl/2laUX – Sandy