how to make a UpSet plot with data frame in R
2
0
Entering edit mode
18 months ago
sata72 • 0

How to create a UpSet plot with my data, this is an example of data.

I want to know how many of features are common between column names and how many are not overlap. for example, some features are only in cds and some in downstream only and some in both of them are share.

head(cpg_region2)
          cds   downstream     exon1       exons     intron1    introns      other    promoter            UTR3        UTR5
 1  1_47963035  1_68276036  1_68276036  1_47963035 1_33831751 1_33831751  1_32347715  1_48132522     11_18394188  1_68276036
 2  1_48088881  10_2648462 1_104414426  1_48088881 1_33831751 1_33831751  14_2527831  1_68276036     11_18394188  12_3142614
 3 1_168677980   12_396767 1_168677980  1_68276036 1_34481401 1_33831751  15_7112579  1_70154145      12_3134049 2_120841166
 4  10_2627156 14_12686663  12_3142614 1_104414426 1_48132522 1_33831751 17_10524429  1_70154145      13_9959153 20_13434035
 5  10_2627156 14_12686663  14_3960061 1_168677980 1_68276036 1_33831751  19_7740157 1_104414426      13_9959153   26_663159
 6  10_2627156  15_7007155 17_11003840  10_2627156 1_68276036 1_34188568   2_5702062 1_104414426      16_2178551   26_663159
R UpSet-plot • 2.3k views
ADD COMMENT
6
Entering edit mode
18 months ago
ATpoint 85k

Given these data, the most basic code could be:

library(data.table)
library(UpSetR)

d <- data.table::fread(text="         cds   downstream     exon1       exons     intron1    introns      other    promoter            UTR3        UTR5
 1  1_47963035  1_68276036  1_68276036  1_47963035 1_33831751 1_33831751  1_32347715  1_48132522     11_18394188  1_68276036
 2  1_48088881  10_2648462 1_104414426  1_48088881 1_33831751 1_33831751  14_2527831  1_68276036     11_18394188  12_3142614
 3 1_168677980   12_396767 1_168677980  1_68276036 1_34481401 1_33831751  15_7112579  1_70154145      12_3134049 2_120841166
 4  10_2627156 14_12686663  12_3142614 1_104414426 1_48132522 1_33831751 17_10524429  1_70154145      13_9959153 20_13434035
 5  10_2627156 14_12686663  14_3960061 1_168677980 1_68276036 1_33831751  19_7740157 1_104414426      13_9959153   26_663159
 6  10_2627156  15_7007155 17_11003840  10_2627156 1_68276036 1_34188568   2_5702062 1_104414426      16_2178551   26_663159")

d$V1 <- NULL

fld <- fromList(as.list(d))

upset(fld)

enter image description here

Please read the UpSetR documentation on how to customize the plot.

ADD COMMENT
0
Entering edit mode

thank you.

ADD REPLY

Login before adding your answer.

Traffic: 2551 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6