乍一看,这看起来像是一个沮丧的情节,但这不是因为我不想对交点进行制表。我有下面的代码来生成一个图表,该图表将心烦图中的交点制成表格,但是我想要的是只计算总数并像上面的图像一样显示交点。这可能吗?
library ( ComplexHeatmap)
lt = list(drug1 = c ( "s1","s2","s3"),
drug2 = c ( "s1","s2"),
drug3 = c ( "s2") )
m1 = make_comb_mat(lt) # the default mode is `distinct`
length ( unique ( unlist ( lt) ) ) # three samples
UpSet( m1)
答案 0 :(得分:1)
这在基本情节中是可行的,但也许不值得麻烦。
lt = list(drug1 = c ( "s1","s2","s3"),
drug2 = c ( "s1","s2"),
drug3 = c ( "s2"))
bc = table(unlist(lt))
bc = bc[order(names(bc))]
m = sapply(sort(unique(unlist(lt))), function(x) sapply(lt, function(y) x %in% y))
margin = 0.25
graphics.off()
plot(1, 1,
xlim = c(1, length(bc)),
ylim = c(0, max(bc) + NROW(m) + margin),
type = "n",
ann = FALSE,
axes = FALSE)
#box()
for (i in seq_along(bc)){
lines(rbind(c(i, 0), c(i, bc[i])), lwd = 8, lend = "butt")
}
for (i in 1:NROW(m)){
for (j in seq_along(bc)){
if (m[i, j]){
points(j, i + max(bc) + margin, cex = 2, lwd = 2)
if (i > 1 & m[max(1, i-1), j]){
lines(rbind(c(j, i - 1 + max(bc) + margin),
c(j, i + max(bc) + margin)))
}
}
}
}
axis(1, at = 1:NCOL(m), labels = colnames(m), las = 1)
# axis(2, at = seq_along(bc), labels = seq_along(bc), las = 1)
axis(2, at = (1:NROW(m))+ max(bc) + margin, labels = row.names(m), las = 1)