krassowski / complex-upset

A library for creating complex UpSet plots with ggplot2 geoms
MIT License
469 stars 28 forks source link

Add more examples #182

Open krassowski opened 1 year ago

krassowski commented 1 year ago

For rotating count text over the top bar only, something like:

ComplexUpset::intersection_size(
    mapping=aes(angle=ifelse(..y..>threshold, 90, 0), vjust=ifelse(..y..>threshold, 0.5, -0.25)),
    size=0,
    text=list(check_overlap=TRUE, vjust=NULL)
)

For labelling venn diagrams over the edge, using:

geom_venn_label_set_edge = function(
    data,
    mapping=aes_(),
    sets=NULL,
    resolution=250,
    text_smoothing=30,
    vjust=1.1,
    ...
) {
    defaults = aes(
        x=x, y=y,
        group=region,
        label=region,
        hjust=ifelse(y<0, 'ymin', 'ymax'),
    )
    mapping = modifyList(defaults, mapping)

    df = ComplexUpset:::approximate_polygon(data, sets=sets, resolution=resolution)
    df = df[df$region %in% sets, ]

    geomtextpath::geom_textpath(
        data=df,
        mapping=mapping,
        text_only=TRUE,
        upright=TRUE,
        vjust=vjust,
        text_smoothing=text_smoothing,
        ...
    )
}