0

I am looking for the reason why I am getting the "could not find function "geom_text"" error. Enter the following commands to generate a PCA graph with captions on the graph of each "dot":

counts <- read.delim('case_vs_control.txt', sep="\t", header=T, row.names=1)
counts <- as.matrix(counts)
design <- data.frame( condition=factor( c("case", "case", "case", "case", "case", "case", "control", "control", "control", "control", "control", "control") ) )
rownames(design) <- colnames(counts)
dataset <- DESeqDataSetFromMatrix(countData = counts, colData = design, design = ~condition)
dds <- DESeq(dataset)
rld <- rlog(dds, blind=FALSE)
names <- c("0099-M9-PGA-rep1", "0099-M9-PGA-rep2", "0099-M9-PGA-rep3", "0223-M9-PGA-rep1", "0223-M9-PGA-rep2", "0223-M9-PGA-rep3", "0099-M9-rep1", "0099-M9-rep2", "0099-M9-rep3", "0223-M9-rep1", "0223-M9-rep2", "0223-M9-rep3")
pdf("PCAall.pdf")
plotPCA(rld, intgroup=c("condition")) + geom_text(aes(label=names),vjust=2, size = 2)
dev.off()

Unfortunately, I am only able to generate a chart without sample captions on the chart (assignment of a specific dot to a specific sample).

I will be grateful for help :)

jrcalabrese
  • 2,184
  • 3
  • 10
  • 30
  • Can you include any relevant `library()` calls? – jrcalabrese Feb 23 '23 at 14:22
  • Do you have `ggplot2` loaded? – jpsmith Feb 23 '23 at 14:22
  • Put `library(ggplot2)` before your codes. Do `install.packages("ggplot2")` if it returns package not found – benson23 Feb 23 '23 at 14:22
  • At first i included library(gplots2). Now as suggested by the leaf I have installed ggplot2 (because if I understand correctly it is a different library than gplots2). However, when I try to enable this library, I get the following error: Error in value[[3L]](cond) : Package 'ggplot2' version 3.4.0 cannot be released: Error in unloadNamespace(package) : namespace 'ggplot2' is imported by 'DESeq2', 'phyloseq' cannot be removed In addition: Warning message: package 'ggplot2' was built in R 4.1.3 – Weronika Babińska Feb 23 '23 at 15:00
  • What version of R are you using? – jrcalabrese Feb 23 '23 at 15:06
  • It worked! I have captions for every point on the PCA chart. I have a last question, how can I increase the font of the captions of each point. What argument should I add to this command to increase the font size? png(filename ="PCA label.png", width = 1000, height = 1000) Thank you in advance for your help :) – Weronika Babińska Feb 23 '23 at 15:43
  • 1
    Your question has been closed, so if you have a new question, please ask a separate question with a reproducible example. – jrcalabrese Feb 23 '23 at 16:16

0 Answers0