Tutorial 4: Comparing datasets

A final task that you might be interested in is comparing associations between datasets with similar nodes. This can cause problems for interpretation because the arrangement of nodes is typically different between panels, e.g.

# get some example data

# split into separate datasets (for example purposes only)
data.list<-list(beetles[, 1:8], beetles[, 4:12], beetles[, 8:16], beetles[, 10:17])
names(data.list)<-paste("subset", c(1:4), sep="_")

# calculate pairwise associations
spaa.list<-lapply(data.list, function(x){spaa(x, method="or.symmetric")})

# plot in 'traditional' way
par(mfrow=c(2, 2))
lapply(spaa.list, circleplot)
par(mfrow=c(1, 1))


We can see that each panel has different species, and although there is overlap between them, it is difficult to see how much. If these datasets were independent, we might also be interested in whether the association between two species varied in strength between plots, though that is not sensible in this example as we are looking at subsets of a single dataset.

An alternative is to use new features to plot all species on each sub-panel.



This is better, but doesn’t allow us to customise the plot, such as by using split.screen instead of mfrow for arranging panels, or to add information to each panel. Therefore, we can calculate the degree of overlap between list entries for ourselves, and repeat using a more ‘manual’ approach:

new.list<-clean.list(spaa.list) # rearranges the matrices stored in spaa.list
par(mfrow=c(2, 2))
for(i in 1:4){
circleplot(new.list[[i]], plot.control=list(
  plot=list(xlim=c(-1.3, 1.3)),
  line.cols=brewer.pal(4, c("Greys", "Purples", "Reds", "Greens")[i]),
mtext(names(new.list)[i], side=3, adj=0.5, line=-0.5)
par(mfrow=c(1, 1))

# we can also ask which species was present in the original subsets
# this can be useful for customising plots further.


Finally, we might wish to plot only those species that are present in all subsets:

circleplot(spaa.list[3:4], type="AND")