# download files and initialize DNA:
download.file("http://www.philipleifeld.de/cms/upload/Downloads/dna-1.31.jar",
destfile = "dna-1.31.jar", mode = "wb")
download.file("http://www.philipleifeld.de/cms/upload/Downloads/sample.dna",
destfile = "sample.dna", mode = "wb")
dna.init("dna-1.31.jar")
# create network matrix
nw <- dna.network("sample.dna")
# compute (binary) density (without partitions)
dna.density(nw)
# create vector with groups (assuming they correspond to rows in the matrix)
groups <- c("Con", "Con", "Con", "Pro", "Pro", "Pro", "Con")
# compute (weighted) density by partition
dna.density(nw, partitions = groups, weighted = TRUE)
Run the code above in your browser using DataLab