krassowski/complex-upset

How to color points by variable not in the dataset

matthlfu opened this issue · 0 comments

Hi there,

I'm trying to color the points of the plot by an additional dataset. Just as a short explanation: there are different grouping variables (PFOA, PFBA....), which do have different or the same number of c-atoms (see the color in the stripes). Is there a way to color the points according to the number of c-atoms (described in additional data frame) and to show the legend (ideally at the bottom of the whole plot)?

image

Sorry, the code is not reproducible. It's shown just to see how it works at the moment:

`
catome_metadata <- data.frame(
set=c("PFBA", "PFBS", "PFPeA", "PFPeS","PFHxA", "PFHxS", "PFHpA" , "PFHpS", "PFOA", "PFOS", "PFNA", "PFNS", "PFDA", "PFDS", "PFUnDA", "PFUnDS", "PFDoDA", "PFDoDS", "PFTrDA", "PFTrDS"),
catome=c('4', '4', '5', '5', '6', '6','7','7', '8', '8','9','9','10','10','11','11','12','12','13','13')
)

upset20222023 <- upset(
vennpfas20222023count,
colnames(vennpfas20222023count),
width_ratio=0.2,
base_annotations=list('Either here'=intersection_size() + ylab('Anzahl gemeinsamer \nNachweise')),
stripes=upset_stripes(
mapping=aes(color=catome),
geom = geom_segment(size = 7, show.legend=FALSE),
colors=colorlegend,
data=catome_metadata
),
set_sizes=(
upset_set_size(geom=geom_bar(width=0.4))
+ theme(
axis.line.x=element_line(colour='black'),
axis.ticks.x=element_line(),
)
+ ylab('Anzahl Nachweise')
),
ylab('Gemeinsame PFAS-Nachweise')
)`