天天看點

upset plot

1. upset 概述

upset展現多個資料集合的互動關系的圖形,類似于傳統的venn圖

資料輸入格式:

list(set1=c(), set2=c()),通過字元UpSetR會自動算出交集;另外可以寫成0和1的矩陣,0代表不存在,1,代表存在,在矩陣中看不同子集的共有元素情況。此外,list可以通過list_to_matrix函數轉化為矩陣形式。

2. Upset mode

mode有三種模式,distinct:常用的,了解為venn形式的;intersect:共有的,不考慮在餘下資料集中是否有;union,是共有元素的或,并集,但是在第三個元素可存在和不存在。

ake_comb_mat(): 産生結合矩陣,計算每個資料集的大小和結合資料集的sets,态度set時,可以使用min_set_size 和top_n_sets過濾

m1 = make_comb_mat(lt, min_set_size = 6)
m2 = make_comb_mat(lt, top_n_sets = 2)

## 3. 圖形展現

## 3.1 普通圖展示

```bash
m1 = make_comb_mat(lt, min_set_size = 6)
m2 = make_comb_mat(lt, top_n_sets = 2)
# sets和結合的排序
UpSet(m, set_order = c("a", "b", "c"), comb_order = order(comb_size(m)))
# 顔色,大小等屬性需要和資料集數目一緻
UpSet(m, pt_size = unit(5, "mm"), lwd = 3,
    comb_col = c("red", "blue", "black")[comb_degree(m)])
           

3.2 熱圖展示

在upset plot中,展現的時粘合矩陣,邊上時每個sets的barplots和結合的sets,可以用熱圖展現,dots和segments(片段),2個barplots顯示兩個注釋anno_barplot()。

UpSet(m, top_annotation = upset_top_annotation(m, 
    gp = gpar(col = comb_degree(m))))
 #坐标軸改變
 UpSet(m, top_annotation = upset_top_annotation(m, 
    ylim = c(0, 15),
    bar_width = 1,
    axis_param = list(side = "right", at = c(0, 5, 10, 15),
        labels = c("zero", "five", "ten", "fifteen"))))
#添加更多的元素,分組
UpSet(m, right_annotation = rowAnnotation(
    "Set size" = anno_barplot(set_size(m), 
        border = FALSE, 
        gp = gpar(fill = "black"), 
        width = unit(2, "cm")
    ),
    group = c("group1", "group1", "group2")))
           

繼續閱讀