我有一个邻接矩阵(netm),其共现主要是0' s。我使用以下方式绘制热图:
<form class="form-horizontal">
<fieldset>
<!-- Form Name -->
<legend>Align Label Form</legend>
<div class="col-sm-6"><!-- Text input-->
<div class="form-group">
<label class="col-sm-4 control-label" for="textinput">Left Align</label>
<div class="col-sm-6">
<input id="textinput" name="textinput" placeholder="placeholder" class="form-control input-md" type="text">
</div>
</div>
</div>
<div class="col-sm-6"><!-- Text input-->
<div class="form-group">
<label class="col-sm-4 control-label" for="textinput">Right Align</label>
<div class="col-sm-6">
<input id="textinput" name="textinput" placeholder="placeholder" class="form-control input-md" type="text">
</div>
</div>
</div>
</fieldset>
</form>
如何忽略矩阵中某个阈值以下的值?我不想在我的图形共生矩阵中绘制低于3的值。
数据快照(共现矩阵)
require(gplots)
heatmap.2(netm,col=c("gold", "dark orange","orange","yellow"),
Rowv=F, Colv=F, dendrogram="none", scale="none", trace="none")
答案 0 :(得分:2)
您可以将NA
替换为不需要的值(例如0),并将它们保存在图中:
netm2 <- netm
netm2[netm2 == 0] <- NA
heatmap.2(netm2, col=c("gold", "dark orange","orange","yellow"), Rowv=F, Colv=F, dendrogram="none", scale="none", trace="none")
或手动删除包含NA
s:
netm3 <- netm2[complete.cases(netm2), complete.cases(t(netm2))]
heatmap.2(netm3, col=c("gold", "dark orange","orange","yellow"), Rowv=F, Colv=F, dendrogram="none", scale="none", trace="none")