krassowski / complex-upset

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

complex-upset for multiple lists #166

Closed fazeliniah closed 1 year ago

fazeliniah commented 1 year ago

Thank you very much for developing this nice tool. I have been using the UpSetR package and would like to replace it with complex-upset. Here is an example, where I used UpSetR to generate the plot for 4 lists:

Listupset <- list(Phos_up = filter(phosphopeptides, adj.P.Val.Phos <= 0.05, logFC.phos > 1)$Gene,
                  Phos_down = filter(phosphopeptides, adj.P.Val.Phos <= 0.05, logFC.phos < 1)$Gene,
                  Protein_up = filter(proteins, adj.P.Val.Prot <= 0.05, logFC.Prot > 1)$Gene,
                  Protein_down = filter(proteins, adj.P.Val.Prot <= 0.05, logFC.Prot < 1)$Gene)
UpSetR::upset(fromList(Listupset))

The lists are of varying length. Is there any easy way to prepare/convert this for complex-upset? Thanks H

krassowski commented 1 year ago

There is no special utility function. There are multiple ways to convert the list to input. For example, if you got phosphoproteomic readouts for 50 proteins:

proteins_measured = paste0('protein', seq(50))
head(proteins_measured)

[1] "protein1" "protein2" "protein3" "protein4" "protein5" "protein6"

And saw 20 up, 20 down, 20 with phospo site up and 20 with phospho down:

data = list(
    protein_up=sample(proteins_measured, 20, TRUE),
    protein_down=sample(proteins_measured, 20, TRUE),
    phospho_up=sample(proteins_measured, 20, TRUE),
    phospho_down=sample(proteins_measured, 20, TRUE)
)

You could convert the result using a two-liner:

membership = data.frame(sapply(
    data,
    function(significant_proteins) proteins_measured %in% significant_proteins)
)
rownames(membership) = proteins_measured

And plot it with:

upset(membership, colnames(membership))

image

Does it help?

krassowski commented 1 year ago

I am going to close this one as answered. Please reopen if you have further questions on this topic. Thanks for trying complex-upset!