提问人:scurry200 提问时间:11/4/2023 最后编辑:scurry200 更新时间:11/4/2023 访问量:51
从尝试运行 ggplot() 时收到“错误:必须从色调调色板请求至少一种颜色”
Getting "Error: Must request at least one colour from a hue palette." from trying to run ggplot()
问:
遇到一些错误导致我无法绘制 PCA 图?这是我在终端上运行这组代码时的输出。
> #pdf(file="pca.mouse.control.pdf")
> #performing PCA using top 500 varying genes
> pcaData<-plotPCA(logTrans, intgroup=c("condition","time"), ntop=3000,returnData=TRUE) #top 1000
> percentVar<-round(100*attr(pcaData,"percentVar")) #percent variance caused by pca1, pca2 rounded to a percentage
> #coloring the points by Condition and shaping the points by Sex
> ggplot(pcaData, aes(PC1, PC2, color=condition, shape=time))+
+ geom_point(size=3)+
+ xlab(paste0("PC1: ",percentVar[1],
+ "%variance"))+
+ ylab(paste0("PC2: ",percentVar[2],
+ "%variance"))+
+ coord_fixed()
Error: Must request at least one colour from a hue palette.
我似乎没有添加颜色或要求调色板?我很困惑这个错误是从哪里来的。
我尝试用括号进行修改,但它们对我根本没有帮助。也许是括号,但我目前没有把它们弄对。需要一些帮助。
编辑: logTrans 上下文
> dput(sampleTable)
structure(list(trash = c("024_S113.gff", "067_S146.gff", "076_S154.gff",
"084_S160.gff", "093_S168.gff", "104_S178.gff", "111_S185.gff",
"012_S103.gff", "029_S118.gff", "050_S134.gff", "052_S135.gff",
"083_S159.gff", "086_S162.gff", "005_S99.gff", "013_S104.gff",
"057_S139.gff", "061_S142.gff", "064_S144.gff", "071_S149.gff",
"098_S172.gff", "117_S190.gff", "014_S105.gff", "023_S112.gff",
"027_S116.gff", "037_S125.gff", "045_S131.gff", "046_S132.gff",
"088_S164.gff", "090_S166.gff", "070_S148.gff", "081_S157.gff",
"082_S158.gff", "087_S163.gff", "105_S179.gff", "010_S102.gff",
"020_S109.gff", "021_S110.gff", "034_S122.gff", "036_S124.gff",
"068_S147.gff", "073_S151.gff", "074_S152.gff", "110_S184.gff",
"022_S111.gff", "031_S120.gff", "035_S123.gff", "049_S133.gff",
"072_S150.gff", "085_S161.gff", "089_S165.gff", "099_S173.gff",
"101_S175.gff", "015_S106.gff", "026_S115.gff", "053_S136.gff",
"065_S145.gff", "096_S170.gff", "109_S183.gff", "118_S191.gff",
"001_S96.gff", "004_S98.gff", "007_S100.gff", "017_S107.gff",
"028_S117.gff", "059_S141.gff", "078_S155.gff", "103_S177.gff",
"106_S180.gff", "115_S188.gff", "002_S97.gff", "041_S128.gff",
"063_S143.gff", "075_S153.gff", "080_S156.gff", "095_S169.gff",
"102_S176.gff", "107_S181.gff", "114_S187.gff", "008_S101.gff",
"019_S108.gff", "032_S121.gff", "038_S126.gff", "040_S127.gff",
"091_S167.gff", "097_S171.gff", "100_S174.gff", "025_S114.gff",
"030_S119.gff", "042_S129.gff", "044_S130.gff", "055_S137.gff",
"056_S138.gff", "058_S140.gff", "108_S182.gff", "113_S186.gff",
"116_S189.gff", "119_S192.gff", "121_S193.gff", "122_S194.gff",
"124_S195.gff", "125_S196.gff", "126_S197.gff", "127_S198.gff",
"128_S199.gff", "129_S200.gff", "130_S201.gff", "131_S202.gff",
"132_S203.gff", "039_S211.gff", "043_S212.gff", "120_S213.gff",
"123_S214.gff", "018_S204.gff", "033_S205.gff", "051_S206.gff",
"062_S207.gff", "066_S208.gff", "077_S209.gff", "094_S210.gff"
), filename = c("A-000h-024_S113.gff", "A-000h-067_S146.gff",
"A-000h-076_S154.gff", "A-000h-084_S160.gff", "A-000h-093_S168.gff",
"A-000h-104_S178.gff", "A-000h-111_S185.gff", "A-072h-012_S103.gff",
"A-072h-029_S118.gff", "A-072h-050_S134.gff", "A-072h-052_S135.gff",
"A-072h-083_S159.gff", "A-072h-086_S162.gff", "A-168h-005_S99.gff",
"A-168h-013_S104.gff", "A-168h-057_S139.gff", "A-168h-061_S142.gff",
"A-168h-064_S144.gff", "A-168h-071_S149.gff", "A-168h-098_S172.gff",
"A-168h-117_S190.gff", "B-000h-014_S105.gff", "B-000h-023_S112.gff",
"B-000h-027_S116.gff", "B-000h-037_S125.gff", "B-000h-045_S131.gff",
"B-000h-046_S132.gff", "B-000h-088_S164.gff", "B-000h-090_S166.gff",
"B-072h-070_S148.gff", "B-072h-081_S157.gff", "B-072h-082_S158.gff",
"B-072h-087_S163.gff", "B-072h-105_S179.gff", "B-168h-010_S102.gff",
"B-168h-020_S109.gff", "B-168h-021_S110.gff", "B-168h-034_S122.gff",
"B-168h-036_S124.gff", "B-168h-068_S147.gff", "B-168h-073_S151.gff",
"B-168h-074_S152.gff", "B-168h-110_S184.gff", "C-000h-022_S111.gff",
"C-000h-031_S120.gff", "C-000h-035_S123.gff", "C-000h-049_S133.gff",
"C-000h-072_S150.gff", "C-000h-085_S161.gff", "C-000h-089_S165.gff",
"C-000h-099_S173.gff", "C-000h-101_S175.gff", "C-072h-015_S106.gff",
"C-072h-026_S115.gff", "C-072h-053_S136.gff", "C-072h-065_S145.gff",
"C-072h-096_S170.gff", "C-072h-109_S183.gff", "C-072h-118_S191.gff",
"C-168h-001_S96.gff", "C-168h-004_S98.gff", "C-168h-007_S100.gff",
"C-168h-017_S107.gff", "C-168h-028_S117.gff", "C-168h-059_S141.gff",
"C-168h-078_S155.gff", "C-168h-103_S177.gff", "C-168h-106_S180.gff",
"C-168h-115_S188.gff", "D-000h-002_S97.gff", "D-000h-041_S128.gff",
"D-000h-063_S143.gff", "D-000h-075_S153.gff", "D-000h-080_S156.gff",
"D-000h-095_S169.gff", "D-000h-102_S176.gff", "D-000h-107_S181.gff",
"D-000h-114_S187.gff", "D-072h-008_S101.gff", "D-072h-019_S108.gff",
"D-072h-032_S121.gff", "D-072h-038_S126.gff", "D-072h-040_S127.gff",
"D-072h-091_S167.gff", "D-072h-097_S171.gff", "D-072h-100_S174.gff",
"D-168h-025_S114.gff", "D-168h-030_S119.gff", "D-168h-042_S129.gff",
"D-168h-044_S130.gff", "D-168h-055_S137.gff", "D-168h-056_S138.gff",
"D-168h-058_S140.gff", "D-168h-108_S182.gff", "D-168h-113_S186.gff",
"D-168h-116_S189.gff", "N-000h-119_S192.gff", "N-000h-121_S193.gff",
"N-000h-122_S194.gff", "N-000h-124_S195.gff", "N-000h-125_S196.gff",
"N-000h-126_S197.gff", "N-000h-127_S198.gff", "N-000h-128_S199.gff",
"N-000h-129_S200.gff", "N-000h-130_S201.gff", "N-000h-131_S202.gff",
"N-000h-132_S203.gff", "X-000h-039_S211.gff", "X-000h-043_S212.gff",
"X-000h-120_S213.gff", "X-000h-123_S214.gff", "X-072h-018_S204.gff",
"X-072h-033_S205.gff", "X-072h-051_S206.gff", "X-072h-062_S207.gff",
"X-072h-066_S208.gff", "X-072h-077_S209.gff", "X-072h-094_S210.gff"
), treatment_group = c("A", "A", "A", "A", "A", "A", "A", "A",
"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",
"B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B",
"B", "B", "B", "B", "B", "B", "B", "B", "B", "C", "C", "C", "C",
"C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C",
"C", "C", "C", "C", "C", "C", "C", "C", "C", "D", "D", "D", "D",
"D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D",
"D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "N", "N", "N",
"N", "N", "N", "N", "N", "N", "N", "N", "N", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X"), time = c("000h", "000h",
"000h", "000h", "000h", "000h", "000h", "072h", "072h", "072h",
"072h", "072h", "072h", "168h", "168h", "168h", "168h", "168h",
"168h", "168h", "168h", "000h", "000h", "000h", "000h", "000h",
"000h", "000h", "000h", "072h", "072h", "072h", "072h", "072h",
"168h", "168h", "168h", "168h", "168h", "168h", "168h", "168h",
"168h", "000h", "000h", "000h", "000h", "000h", "000h", "000h",
"000h", "000h", "072h", "072h", "072h", "072h", "072h", "072h",
"072h", "168h", "168h", "168h", "168h", "168h", "168h", "168h",
"168h", "168h", "168h", "000h", "000h", "000h", "000h", "000h",
"000h", "000h", "000h", "000h", "072h", "072h", "072h", "072h",
"072h", "072h", "072h", "072h", "168h", "168h", "168h", "168h",
"168h", "168h", "168h", "168h", "168h", "168h", "000h", "000h",
"000h", "000h", "000h", "000h", "000h", "000h", "000h", "000h",
"000h", "000h", "000h", "000h", "000h", "000h", "072h", "072h",
"072h", "072h", "072h", "072h", "072h")), row.names = c(NA, -119L
), class = c("tbl_df", "tbl", "data.frame"))
ddsHTSeq<-DESeqDataSetFromHTSeqCount(sampleTable=sampleTable, directory=directory, design=~treatment_group+time)
ddsHTSeq<- estimateSizeFactors(ddsHTSeq)
logTrans<- vst(ddsHTSeq) #normalized counts
dput(pca数据)
> pcaData
PC1 PC2 group condition time name
A-000h-024_S113 -0.320694178 2.7778412 NA:000h <NA> 000h A-000h-024_S113
A-000h-067_S146 -0.002410985 8.3898396 NA:000h <NA> 000h A-000h-067_S146
A-000h-076_S154 0.499607961 3.7851280 NA:000h <NA> 000h A-000h-076_S154
A-000h-084_S160 2.067338462 3.3101123 NA:000h <NA> 000h A-000h-084_S160
A-000h-093_S168 3.111691815 1.7002517 NA:000h <NA> 000h A-000h-093_S168
A-000h-104_S178 -3.818532232 1.1508051 NA:000h <NA> 000h A-000h-104_S178
A-000h-111_S185 -3.742749898 3.5110641 NA:000h <NA> 000h A-000h-111_S185
A-072h-012_S103 -0.534166142 1.8638765 NA:072h <NA> 072h A-072h-012_S103
A-072h-029_S118 -0.836948039 0.2941960 NA:072h <NA> 072h A-072h-029_S118
A-072h-050_S134 2.960265751 -0.6157736 NA:072h <NA> 072h A-072h-050_S134
A-072h-052_S135 3.525457747 -2.4132327 NA:072h <NA> 072h A-072h-052_S135
A-072h-083_S159 2.409759291 -0.1038610 NA:072h <NA> 072h A-072h-083_S159
A-072h-086_S162 3.722458157 5.0023295 NA:072h <NA> 072h A-072h-086_S162
A-168h-005_S99 2.146962939 -0.0394367 NA:168h <NA> 168h A-168h-005_S99
A-168h-013_S104 2.460944560 -2.6037950 NA:168h <NA> 168h A-168h-013_S104
A-168h-057_S139 0.726681360 0.3563937 NA:168h <NA> 168h A-168h-057_S139
A-168h-061_S142 3.054806788 -2.7197222 NA:168h <NA> 168h A-168h-061_S142
A-168h-064_S144 2.848271362 -1.8982479 NA:168h <NA> 168h A-168h-064_S144
A-168h-071_S149 1.305806698 -2.6754773 NA:168h <NA> 168h A-168h-071_S149
A-168h-098_S172 2.567909657 -0.8122940 NA:168h <NA> 168h A-168h-098_S172
A-168h-117_S190 -8.141619722 -2.5115206 NA:168h <NA> 168h A-168h-117_S190
B-000h-014_S105 2.370623844 2.5494356 NA:000h <NA> 000h B-000h-014_S105
B-000h-023_S112 0.658832442 3.3414638 NA:000h <NA> 000h B-000h-023_S112
B-000h-027_S116 -0.869408244 2.7761878 NA:000h <NA> 000h B-000h-027_S116
B-000h-037_S125 6.529922314 1.8519230 NA:000h <NA> 000h B-000h-037_S125
B-000h-045_S131 3.880650507 4.0539278 NA:000h <NA> 000h B-000h-045_S131
B-000h-046_S132 2.862712194 3.9337226 NA:000h <NA> 000h B-000h-046_S132
B-000h-088_S164 1.847039948 6.1028658 NA:000h <NA> 000h B-000h-088_S164
B-000h-090_S166 0.849799101 2.5122905 NA:000h <NA> 000h B-000h-090_S166
B-072h-070_S148 0.359739401 -1.7607710 NA:072h <NA> 072h B-072h-070_S148
B-072h-081_S157 1.099741212 -0.5528003 NA:072h <NA> 072h B-072h-081_S157
B-072h-082_S158 -1.149739682 3.5483062 NA:072h <NA> 072h B-072h-082_S158
B-072h-087_S163 2.474424568 3.3227377 NA:072h <NA> 072h B-072h-087_S163
B-072h-105_S179 -4.870152140 4.2411364 NA:072h <NA> 072h B-072h-105_S179
B-168h-010_S102 1.622330196 -2.3225392 NA:168h <NA> 168h B-168h-010_S102
B-168h-020_S109 0.443072770 -1.9743801 NA:168h <NA> 168h B-168h-020_S109
B-168h-021_S110 0.605650856 -1.8533296 NA:168h <NA> 168h B-168h-021_S110
B-168h-034_S122 3.793121081 -0.4871453 NA:168h <NA> 168h B-168h-034_S122
B-168h-036_S124 2.284190679 -1.0805896 NA:168h <NA> 168h B-168h-036_S124
B-168h-068_S147 1.466100677 0.2844068 NA:168h <NA> 168h B-168h-068_S147
B-168h-073_S151 1.542207973 -2.3339288 NA:168h <NA> 168h B-168h-073_S151
B-168h-074_S152 3.269648176 0.1098486 NA:168h <NA> 168h B-168h-074_S152
B-168h-110_S184 -4.812980315 -1.7470181 NA:168h <NA> 168h B-168h-110_S184
C-000h-022_S111 0.421081990 -1.5410538 NA:000h <NA> 000h C-000h-022_S111
C-000h-031_S120 1.924790839 -1.0966968 NA:000h <NA> 000h C-000h-031_S120
C-000h-035_S123 5.767409891 5.6004148 NA:000h <NA> 000h C-000h-035_S123
C-000h-049_S133 2.698040920 -2.0511850 NA:000h <NA> 000h C-000h-049_S133
C-000h-072_S150 0.153482258 -1.8688691 NA:000h <NA> 000h C-000h-072_S150
C-000h-085_S161 3.974074066 -1.5456674 NA:000h <NA> 000h C-000h-085_S161
C-000h-089_S165 0.895956414 -4.6147697 NA:000h <NA> 000h C-000h-089_S165
C-000h-099_S173 1.403521355 -1.2112024 NA:000h <NA> 000h C-000h-099_S173
C-000h-101_S175 1.120086666 -1.3397290 NA:000h <NA> 000h C-000h-101_S175
C-072h-015_S106 3.042787752 2.7031248 NA:072h <NA> 072h C-072h-015_S106
C-072h-026_S115 2.986361551 1.2819011 NA:072h <NA> 072h C-072h-026_S115
C-072h-053_S136 2.612581837 -3.0030911 NA:072h <NA> 072h C-072h-053_S136
C-072h-065_S145 5.337826050 -1.4428190 NA:072h <NA> 072h C-072h-065_S145
C-072h-096_S170 0.900925163 0.8642273 NA:072h <NA> 072h C-072h-096_S170
C-072h-109_S183 -5.334425078 -2.4136414 NA:072h <NA> 072h C-072h-109_S183
C-072h-118_S191 -7.231001196 3.2579731 NA:072h <NA> 072h C-072h-118_S191
C-168h-001_S96 3.023570539 -0.7010362 NA:168h <NA> 168h C-168h-001_S96
C-168h-004_S98 1.823423831 -1.7113056 NA:168h <NA> 168h C-168h-004_S98
C-168h-007_S100 0.962411992 -2.2924658 NA:168h <NA> 168h C-168h-007_S100
C-168h-017_S107 1.065361860 3.0621013 NA:168h <NA> 168h C-168h-017_S107
C-168h-028_S117 -0.366006851 -2.9235285 NA:168h <NA> 168h C-168h-028_S117
C-168h-059_S141 1.428278165 -1.9400322 NA:168h <NA> 168h C-168h-059_S141
C-168h-078_S155 0.815843404 2.1067205 NA:168h <NA> 168h C-168h-078_S155
C-168h-103_S177 -1.143954264 1.7431866 NA:168h <NA> 168h C-168h-103_S177
C-168h-106_S180 -6.143535335 -2.2050061 NA:168h <NA> 168h C-168h-106_S180
C-168h-115_S188 -10.687616920 0.8673982 NA:168h <NA> 168h C-168h-115_S188
D-000h-002_S97 1.713323672 -1.8416271 NA:000h <NA> 000h D-000h-002_S97
D-000h-041_S128 3.324591638 -2.2369055 NA:000h <NA> 000h D-000h-041_S128
D-000h-063_S143 2.509382117 -2.0362103 NA:000h <NA> 000h D-000h-063_S143
D-000h-075_S153 2.748652742 -3.7119225 NA:000h <NA> 000h D-000h-075_S153
D-000h-080_S156 2.282400058 -2.6198194 NA:000h <NA> 000h D-000h-080_S156
D-000h-095_S169 2.144568051 -2.0766734 NA:000h <NA> 000h D-000h-095_S169
D-000h-102_S176 -1.311142185 -2.3878073 NA:000h <NA> 000h D-000h-102_S176
D-000h-107_S181 -5.927155889 -2.1570771 NA:000h <NA> 000h D-000h-107_S181
D-000h-114_S187 -3.340403022 -0.8760670 NA:000h <NA> 000h D-000h-114_S187
D-072h-008_S101 2.241312455 -1.5338208 NA:072h <NA> 072h D-072h-008_S101
D-072h-019_S108 1.645271817 -0.5504861 NA:072h <NA> 072h D-072h-019_S108
D-072h-032_S121 4.718969159 -1.1478291 NA:072h <NA> 072h D-072h-032_S121
D-072h-038_S126 3.978578789 -1.2264232 NA:072h <NA> 072h D-072h-038_S126
D-072h-040_S127 3.871264202 -0.6495841 NA:072h <NA> 072h D-072h-040_S127
D-072h-091_S167 1.679631907 0.6100731 NA:072h <NA> 072h D-072h-091_S167
D-072h-097_S171 1.934509572 4.2551949 NA:072h <NA> 072h D-072h-097_S171
D-072h-100_S174 -2.205379764 3.1915375 NA:072h <NA> 072h D-072h-100_S174
D-168h-025_S114 1.371362706 -1.7243487 NA:168h <NA> 168h D-168h-025_S114
D-168h-030_S119 -1.341233490 -2.0945257 NA:168h <NA> 168h D-168h-030_S119
D-168h-042_S129 2.172584323 -2.4828478 NA:168h <NA> 168h D-168h-042_S129
D-168h-044_S130 1.258171332 -1.9402257 NA:168h <NA> 168h D-168h-044_S130
D-168h-055_S137 3.962113103 -0.4879615 NA:168h <NA> 168h D-168h-055_S137
D-168h-056_S138 0.901000865 1.1711941 NA:168h <NA> 168h D-168h-056_S138
D-168h-058_S140 2.414236421 -0.0441272 NA:168h <NA> 168h D-168h-058_S140
D-168h-108_S182 -5.604362515 -1.0181219 NA:168h <NA> 168h D-168h-108_S182
D-168h-113_S186 -6.850762875 -1.1256681 NA:168h <NA> 168h D-168h-113_S186
D-168h-116_S189 -8.408673481 -0.8937453 NA:168h <NA> 168h D-168h-116_S189
N-000h-119_S192 -0.003130916 1.3419868 NA:000h <NA> 000h N-000h-119_S192
N-000h-121_S193 -0.103201056 -2.0279611 NA:000h <NA> 000h N-000h-121_S193
N-000h-122_S194 -1.950250818 -0.7800179 NA:000h <NA> 000h N-000h-122_S194
N-000h-124_S195 0.045145274 -1.7753548 NA:000h <NA> 000h N-000h-124_S195
N-000h-125_S196 -0.176879963 -2.2177693 NA:000h <NA> 000h N-000h-125_S196
N-000h-126_S197 -0.624386897 -1.3394352 NA:000h <NA> 000h N-000h-126_S197
N-000h-127_S198 -1.893840840 -0.5811596 NA:000h <NA> 000h N-000h-127_S198
N-000h-128_S199 -0.459150758 -0.6233492 NA:000h <NA> 000h N-000h-128_S199
N-000h-129_S200 -4.304056142 -0.5741117 NA:000h <NA> 000h N-000h-129_S200
N-000h-130_S201 -3.652964941 -2.9512770 NA:000h <NA> 000h N-000h-130_S201
N-000h-131_S202 -7.494324473 -1.6510467 NA:000h <NA> 000h N-000h-131_S202
N-000h-132_S203 -4.586636098 -1.6417175 NA:000h <NA> 000h N-000h-132_S203
X-000h-039_S211 -1.598262248 0.4686062 NA:000h <NA> 000h X-000h-039_S211
X-000h-043_S212 -4.110502622 5.5563299 NA:000h <NA> 000h X-000h-043_S212
X-000h-120_S213 -2.662484813 -2.2099994 NA:000h <NA> 000h X-000h-120_S213
X-000h-123_S214 -3.526951600 5.0218529 NA:000h <NA> 000h X-000h-123_S214
X-072h-018_S204 -4.928491326 -1.2340832 NA:072h <NA> 072h X-072h-018_S204
X-072h-033_S205 -5.692045983 -0.5669768 NA:072h <NA> 072h X-072h-033_S205
X-072h-051_S206 -7.672251061 0.2607200 NA:072h <NA> 072h X-072h-051_S206
X-072h-062_S207 -6.029460116 1.7019388 NA:072h <NA> 072h X-072h-062_S207
X-072h-066_S208 -1.350411695 2.0435592 NA:072h <NA> 072h X-072h-066_S208
X-072h-077_S209 -1.086626889 2.2381641 NA:072h <NA> 072h X-072h-077_S209
X-072h-094_S210 -1.741291539 1.3277506 NA:072h <NA> 072h X-072h-094_S210
答:
0赞
Maria Vaz Salvador
11/4/2023
#1
当您显示 PCA 时,您的条件列中充满了 NA。我相信您可能有 PCA 不支持的“条件”标称值(PCA 仅在数值数据上完成)。你有办法对付它们。例如,您可以创建虚拟变量。我会给你一个讨论这个问题的网站。
评论
0赞
scurry200
11/4/2023
你是对的。PCAdata 在“conditions”中有一个 NA 列。有什么修复它的想法吗?
0赞
scurry200
11/4/2023
我附上了一个dput(PCAdata)以供参考。
0赞
Maria Vaz Salvador
11/4/2023
@scurry200我已经编辑了我的答案。请检查您的数据集是否准确
评论
condition
treatment_group