heatmap.2默认为dist用于计算距离矩阵和hclust用于聚类.现在有人怎么设置dist来使用欧几里德方法和hclust来使用质心方法?我提供了一个可编译的代码示例.我尝试过:distfun = dist(method ="euclidean"),但这不起作用.有任何想法吗?
library("gplots")
library("RColorBrewer")
test <- matrix(c(79,38.6,30.2,10.8,22,
81,37.7,28.4,9.7,19.9,
82,36.2,26.8,9.8,20.9,
74,29.9,17.2,6.1,13.9,
81,37.4,20.5,6.7,14.6),ncol=5,byrow=TRUE)
colnames(test) <- c("18:0","18:1","18:2","18:3","20:0")
rownames(test) <- c("Sample 1","Sample 2","Sample 3", "Sample 4","Sample 5")
test <- as.table(test)
mat=data.matrix(test)
heatmap.2(mat,
dendrogram="row",
Rowv=TRUE,
Colv=NULL,
distfun = dist,
hclustfun = hclust,
xlab = "Lipid Species",
ylab = NULL,
colsep=c(1),
sepcolor="black",
key=TRUE,
keysize=1,
trace="none",
density.info=c("none"),
margins=c(8, 12),
col=bluered
)
Run Code Online (Sandbox Code Playgroud) I have an algorithm that finds the set of all unique sums of the combinations of k tuples drawn with replacement from of a list of tuples. Each tuple contains n positive integers, the order of these integers matters, and the sum of the tuples is defined as element-wise addition. e.g. (1, 2, 3) + (4, 5, 6) = (5, 7, 9)
Simple example for k=2 and n=3:
input = [(1,0,0), (2,1,1), (3,3,2)]
solution = [(1,0,0)+(2,1,1), (1,0,0)+(3,3,2), (2,1,1)+(3,3,2), (1,0,0)+(1,0,0), (2,1,1)+(2,1,1), …Run Code Online (Sandbox Code Playgroud) listener在 Vue 应用程序中,我在a 上粘贴了一个内容textarea,目的是当用户将数据粘贴到该字段时运行验证代码。当我记录粘贴事件时,我可以在控制台中看到粘贴到字段中的数据位于event -> target -> value. 但我似乎无法访问它event.target.value。我究竟做错了什么?
最小的例子:
<div id="app">
<textarea name="myField" @paste="onPaste"></textarea>
<p>Field name: {{ fieldName }}</p>
<p>Pasted data: {{ pasted }}</p>
</div>
Run Code Online (Sandbox Code Playgroud)
var app = new Vue({
el: '#app',
data: {
fieldName: '',
pasted: ''
},
methods: {
onPaste(event){
console.log(event)
this.message = event.target.name
this.paste = event.target.value
}
}
})
Run Code Online (Sandbox Code Playgroud)
我想在我的应用程序中保留每个数据库更改事件的日志。像时间戳+用户名+哪个模型被更改,写入日志文件(只记录模型实例被修改,而不是更改是什么)。信号和日志记录的结合似乎很自然。
所以在模型的信号中我会这样做:
import logging
...
logger = logging.getLogger(__name__)
logger.info("Order {} deleted by {}".format(order.barcode, request.user.email))
Run Code Online (Sandbox Code Playgroud)
这样做的问题是日志的信息级别充满了 POST 和 GET 请求。通常的建议是,如果您不希望日志文件中的所有请求日志都进入更高级别(例如“警告”),但在此处将这些事件标记为警告是没有意义的。另一种选择是使用过滤器来删除 GET/POST 日志,如此处推荐的。但默认情况下,警告和错误级别日志事件也会出现在信息日志中,在这种情况下这也不是所需的行为,因此这些事件也必须被过滤掉。该日志文件实际上只是用于记录“此用户更改了此模型实例”事件。
另外,理想情况下,员工级用户可以在现场访问该文件(只读),因此我正在考虑将此文件放在 MEDIA 目录中。如果日志还包含错误跟踪,那可能是一个坏主意。
这看起来像是一个黑客解决方案,我在这里忽略了什么?
combinations ×1
distribution ×1
django ×1
hclust ×1
heatmap ×1
javascript ×1
logging ×1
math ×1
optimization ×1
performance ×1
python ×1
r ×1
vue-events ×1
vue.js ×1