# NOT RUN {
# Set up some data
library("poppr")
library("magrittr")
data(monpop)
splitStrata(monpop) <- ~Tree/Year/Symptom
summary(monpop)
monpop_ssr <- c(CHMFc4 = 7, CHMFc5 = 2, CHMFc12 = 4,
SEA = 4, SED = 4, SEE = 2, SEG = 6,
SEI = 3, SEL = 4, SEN = 2, SEP = 4,
SEQ = 2, SER = 4)
t26 <- monpop %>% setPop(~Tree) %>% popsub("26") %>% setPop(~Year/Symptom)
t26
imsn() # select Bruvo's distance and enter "monpop_ssr" into the Repeat Length field.
# It is also possible to run this from github if you are connected to the internet.
# This allows you to access any bug fixes that may have been updated before a formal
# release on CRAN
shiny::runGitHub("grunwaldlab/poppr", subdir = "inst/shiny/msn_explorer")
# You can also use your own distance matrices, but there's a small catch.
# in order to do so, you must write a function that will subset the matrix
# to whatever populations are in your data. Here's an example with the above
# data set:
mondist <- bruvo.dist(monpop, replen = monpop_ssr)
myDist <- function(x, d = mondist){
dm <- as.matrix(d) # Convert the dist object to a square matrix
xi <- indNames(x) # Grab the sample names that exist
return(as.dist(dm[xi, xi])) # return only the elements that have the names
# in the data set
}
# After executing imsn, choose:
# Distance: custom
# myDist
imsn()
# }
Run the code above in your browser using DataLab