0

I want to have labels only one time on the left of each line in a parallel coordinates plot. I only managed to get labels on every instances so it doesn't look clear.

## test data set
data2 <- data.frame(
  "geneSymbol" = paste("Gene", 1:10),
  "condition1" = rnorm(10, 3, 1),
  "condition2" = rnorm(10, 4, 0.5),
  "condition3" = rnorm(10, 7, 0.3)
  )

#building parallel coordination plot with ggparcoord() from GGally
ggparcoord(data= data2,
           columns = 2:4,
           groupColumn = 1,
           scale = "std",
           scaleSummary = "mean",
           centerObsID = 1,
           missing = "exclude",
           showPoints = FALSE,
           splineFactor = FALSE,
           alphaLines = 1,
           boxplot = TRUE,
           shadeBox = NULL,
           mapping = NULL,
           title = "TEST")+
  geom_text(aes(label=geneSymbol))

Does anyone has an idea? Best regards wbart

wbart
  • 17
  • 3

1 Answers1

0

You can make the labels dependent on the x axis value using ifelse

ggparcoord(data= data2,
           columns = 2:4,
           groupColumn = 1,
           scale = "std",
           scaleSummary = "mean",
           centerObsID = 1,
           missing = "exclude",
           showPoints = FALSE,
           splineFactor = FALSE,
           alphaLines = 1,
           boxplot = TRUE,
           shadeBox = NULL,
           mapping = NULL,
           title = "TEST") +
  geom_text(aes(label = ifelse(variable == "condition1", 
                               as.character(geneSymbol), "")), hjust = 1.2)

enter image description here

Allan Cameron
  • 147,086
  • 7
  • 49
  • 87
  • Do you also get an error called"The following aesthetics were dropped during statistical transformation: color". I ignored this message until know and I do not know the cause. Your modification has nothing to do with this message so maybe it is so wrong place to post. – wbart Aug 09 '23 at 08:28