臨近國(guó)慶節(jié)啦色洞,花花9月19號(hào)上完了9月的線上課,飛回自己家里當(dāng)廢物啦(不要問我為什么不帶豆豆冠胯,回家當(dāng)廢物怎么能帶豆豆呢火诸,帶了豆豆還怎么當(dāng)廢物呢)何況豆豆是一個(gè)要按時(shí)按點(diǎn)上班的人,不像我荠察,時(shí)間自由置蜀,地點(diǎn)自由奈搜,只要完成了工作任務(wù),老板不管我在哪兒~所以只要我膽子大盯荤,天天都放假馋吗,不建議大家輕易嘗試,因?yàn)橛械墓緯绻と炀鸵_除啦G锍印(在危險(xiǎn)的邊緣瘋狂試探) 言歸正傳宏粤!upsetplot是進(jìn)階版的韋恩圖,用于展示多個(gè)向量間交集的數(shù)量航缀。仔細(xì)看一下圖商架,會(huì)看懂的堰怨。
1.準(zhǔn)備R包和數(shù)據(jù)
library(UpSetR)
x = paste0("gene",1:600)
g = list(g1 = sample(x,450),
g2 = sample(x,400),
g3 = sample(x,430),
g4 = sample(x,410),
g5 = sample(x,200))
lapply(g,head,3)
## $g1
## [1] "gene457" "gene441" "gene409"
##
## $g2
## [1] "gene94" "gene321" "gene313"
##
## $g3
## [1] "gene382" "gene178" "gene576"
##
## $g4
## [1] "gene245" "gene69" "gene535"
##
## $g5
## [1] "gene403" "gene138" "gene60"
2.極簡(jiǎn)出圖
upset(fromList(g), order.by = "freq")
3.標(biāo)注出重點(diǎn)關(guān)注對(duì)象
函數(shù)設(shè)計(jì)的可讀性有點(diǎn)……嗯芥玉。下面讓我們蕩起雙槳,把所有五個(gè)向量的交集那一列標(biāo)出來备图。
upset(fromList(g), order.by = "freq",
queries = list(list(query = intersects,
params = list("g1","g2","g3","g4","g5"),
color = "darkred",
active = T)))
可以標(biāo)出任意想標(biāo)的列灿巧,幾列都可
upset(fromList(g), order.by = "freq",
queries = list(list(query = intersects,
params = list("g2","g3"),
color = "purple",
active = T),
list(query = intersects,
params = list("g1","g3","g5"),
color = "darkred",
active = T)))
4.保持原來的分組順序
默認(rèn)按照每個(gè)集合數(shù)據(jù)量大小來排序。我覺得不是很順眼揽涮】倥海可以用sets參數(shù)指定順序,但我發(fā)現(xiàn)順序默認(rèn)從下往上蒋困。也就是說你想要從上向下依次是g1~g5,就必須寫成:
rev(names(g))
## [1] "g5" "g4" "g3" "g2" "g1"
upset(fromList(g),
order.by = "freq",
sets = rev(names(g)),
keep.order = T,
queries = list(list(query = intersects,
params = list("g2","g3"),
color = "purple",
active = T),
list(query = intersects,
params = list("g1","g3","g5"),
color = "darkred",
active = T)))