structure(list(coord = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L,
60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L,
31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L,
44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L,
57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L,
28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L,
41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L,
54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L,
67L, 68L, 69L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L,
25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L,
38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L,
51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L,
64L, 65L, 66L, 67L, 68L, 69L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L,
35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L,
48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L,
61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L), .Label = c("21906057-21916057",
"21916057-21926057", "21976057-21986057", "21986057-21996057",
"22006057-22016057", "22016057-22026057", "22036057-22046057",
"22046057-22056057", "22056057-22066057", "22066057-22076057",
"22076057-22086057", "22096057-22106057", "22106057-22116057",
"22116057-22126057", "22126057-22136057", "22136057-22146057",
"22146057-22156057", "22156057-22166057", "22166057-22176057",
"22176057-22186057", "22186057-22196057", "22196057-22206057",
"22206057-22216057", "22226057-22236057", "22236057-22246057",
"22246057-22256057", "22256057-22266057", "22306057-22316057",
"22316057-22326057", "22326057-22336057", "22336057-22346057",
"22346057-22356057", "22356057-22366057", "22366057-22376057",
"22426057-22436057", "22436057-22446057", "22446057-22456057",
"22466057-22476057", "22476057-22486057", "22506057-22516057",
"22516057-22526057", "22526057-22536057", "22536057-22546057",
"22546057-22556057", "22556057-22566057", "22566057-22576057",
"22576057-22586057", "22586057-22596057", "22596057-22606057",
"22606057-22616057", "22616057-22626057", "22626057-22636057",
"22636057-22646057", "22646057-22656057", "22686057-22696057",
"22726057-22736057", "22736057-22746057", "22746057-22756057",
"22806057-22816057", "22816057-22826057", "22826057-22836057",
"22836057-22846057", "22866057-22876057", "22876057-22886057",
"22886057-22896057", "22896057-22906057", "22906057-22916057",
"22916057-22926057", "22956057-22966057"), class = "factor"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, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L), .Label = c("gene1", "gene2", "gene3",
"gene4", "gene5"), class = "factor"), value = c(0L, 3L, 0L,
0L, 0L, 0L, 43L, 0L, 0L, 0L, 0L, 0L, 0L, 56L, 56L, 31L, 31L,
31L, 31L, 5L, 11L, 11L, 11L, 1L, 24L, 9805L, 72L, 74L, 74L,
74L, 74L, 74L, 74L, 74L, 2187L, 0L, 40L, 54L, 54L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 1L, 62L,
62L, 1L, 26L, 26L, 26L, 3L, 40L, 40L, 6L, 6L, 6L, 6L, 200L,
0L, NA, NA, NA, NA, 0L, 49L, NA, NA, 0L, NA, 0L, 0L, NA,
36L, NA, 1L, 54L, 54L, NA, NA, NA, NA, NA, 0L, 72L, NA, NA,
NA, NA, 0L, NA, NA, NA, 6L, 40L, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0L, NA, NA, NA, 1L,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 60L, NA, NA,
NA, NA, NA, 0L, NA, NA, NA, NA, NA, NA, NA, NA, 0L, NA, NA,
NA, 5L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 0L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, 12L, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, 31L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), exp = c("Extremely low",
"Very Low", "Extremely low", "Extremely low", "Extremely low",
"Extremely low", "Moderately high", "Extremely low", "Extremely low",
"Extremely low", "Extremely low", "Extremely low", "Extremely low",
"High", "High", "Moderately high", "Moderately high", "Moderately high",
"Moderately high", "Low", "Moderate", "Moderate", "Moderate",
"Very Low", "Moderate", "Extremely high", "High", "High",
"High", "High", "High", "High", "High", "High", "Extremely high",
"Extremely low", "Moderately high", "High", "High", "Low",
"Low", "Low", "Low", "Low", "Low", "Low", "Low", "Low", "Low",
"Low", "Low", "Low", "Low", "Low", "Very Low", "High", "High",
"Very Low", "Moderately high", "Moderately high", "Moderately high",
"Very Low", "Moderately high", "Moderately high", "Low",
"Low", "Low", "Low", "Very high", "Extremely low", NA, NA,
NA, NA, "Extremely low", "Moderately high", NA, NA, "Extremely low",
NA, "Extremely low", "Extremely low", NA, "Moderately high",
NA, "Very Low", "High", "High", NA, NA, NA, NA, NA, "Extremely low",
"High", NA, NA, NA, NA, "Extremely low", NA, NA, NA, "Low",
"Moderately high", NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, "Extremely low", NA, NA, NA, "Very Low",
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "High", NA, NA,
NA, NA, NA, "Extremely low", NA, NA, NA, NA, NA, NA, NA,
NA, "Extremely low", NA, NA, NA, "Low", NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "Extremely low",
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, "Moderate", NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "Moderately high",
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA)), .Names = c("coord",
"variable", "value", "exp"), row.names = c(NA, -345L), class = "data.frame")
我想使用ggplot2将此数据绘制为分组条形图。 我执行了以下步骤:
test[is.na(test)] <- 0
q<-ggplot(test, aes(x=coord, y=value, fill=factor(exp))) + geom_bar(aes(fill=exp),stat="identity",position = "dodge")+theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))+scale_y_continuous(trans = "log10")
进入单个群体的条形图没有明确定义,我可以将该条形图中的每个条形图边界化吗?
我也试过这个:
barchart(log10(value) ~ coord, groups=exp, test, auto.key = list(columns = 3))
但我无法控制像旋转x轴标签这样的事情。但是,我更喜欢ggplot2,因为我必须添加另一层数据,其中我必须突出显示几个x轴标签,这些标签将通过引用另一个数据集并合并到现有的“测试”d.f.我使用SO问题/答案的帮助做了很少的情节所以没有问题。
更新: 由于log10(0)将给出-Inf值,正在做 scale_y_continuous(trans =“log10”,expand = c(0,0)) 正确的吗?