library(vegan)
N <- 1000
xy <- data.frame(x = rnorm(N), y = rnorm(N), z = rnorm(N))
pca <- prcomp(xy)
plot(pca$x, type = "n")
orditorp(x = pca, display = "sites", air = 2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(scrbook) | |
scrPID.um2 <- function (n, X, y, M, mmax, obsmod = c("pois", "bern"), niters, | |
npics, xlims, ylims, inits, delta) | |
{ | |
obsmod <- match.arg(obsmod) | |
J <- nrow(n) | |
K <- ncol(n) | |
S <- inits$S | |
D <- e2dist(S, X) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xy1 <- data.frame(x = rnorm(10), y = rnorm(10)) | |
xy2 <- data.frame(x = rnorm(5), y = rnorm(5)) | |
library(ggplot2) | |
ggplot() + | |
theme_bw() + | |
geom_point(data = xy1, aes(x = x, y = y)) + | |
geom_point(data = xy2, aes(x = x, y = y), color = "red") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xy <- data.frame(x = 1:3, y = letters[1:3], z = LETTERS[1:3]) | |
chg <- data.frame(old = colnames(xy), new = toupper(colnames(xy))) | |
library(plyr) | |
colnames(xy) <- mapvalues(x = colnames(xy), | |
from = as.character(chg$old), | |
to = as.character(chg$new)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qs <- read.table("number_r_qs_per_day.csv", header = TRUE, sep = ",") | |
qs$r <- NULL | |
qs$Datum <- as.Date(with(qs, paste(Year, Month, Day, sep = "-")), format = "%Y-%m-%d") | |
qs$Weekday <- as.POSIXlt(qs$Datum)$wday | |
qs <- qs[order(qs$Datum), ] | |
qs$CumSum <- cumsum(qs$Total) | |
qs$Workday <- NA | |
qs$Workday[qs$Weekday %in% c(0, 6)] <- "Weekend" | |
qs$Workday[qs$Weekday %in% 1:5] <- "Non-Weekend" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def splitCalcMerge(pop, param): | |
# Calculate population sizes to help with splitting (see below). | |
pop_size_croatia = pop.subPopSize(0) | |
pop_size_slovenia = pop.subPopSize(1) | |
pop_sizes = {"1":pop_size_croatia, "3":pop_size_slovenia} | |
# Split population into two. First subpopulation is the main one minus the | |
# sample size (ss). | |
sim.splitSubPops(pop = pop, subPops = 0, sizes = [pop_size_croatia - param["croatia"], param["croatia"]]) | |
sim.splitSubPops(pop = pop, subPops = 2, sizes = [pop_size_slovenia - param["slovenia"], param["slovenia"]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import simuPOP as sim | |
import numpy as np | |
from simuPOP.utils import viewVars | |
pop = sim.Population(size = [550, 400], loci = 10, infoFields = ["age", "migrate_to"], subPopNames = ["croatia", "slovenia"]) | |
sim.initInfo(pop = pop, values = np.random.choice([1, 2, 3, 4, 5], replace = True, size = 200), infoFields = "age") | |
sim.initGenotype(pop = pop, prop = [0.1]*10) | |
sim.initSex(pop, maleProp = 0.5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this example demostrantes that two individuals are not migrated from VSP [1, 1] to subpopulation 0 | |
import simuPOP as sim | |
import numpy as np | |
pop = sim.Population(size = [100, 100], loci = 3, infoFields = ["age", "migrate_to"]) | |
sim.initInfo(pop = pop, values = np.random.negative_binomial(n = 3, p = 0.4, size = 20), infoFields = "age") | |
sim.initSex(pop, maleProp = 0.5) | |
pop.setVirtualSplitter(sim.ProductSplitter(splitters = [ | |
sim.SexSplitter(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import simuPOP as sim | |
import numpy as np | |
import random | |
from math import exp | |
#from scipy.stats import poisson # for poisson pmf | |
popHR = 2000 | |
popSI = 1000 | |
population_size = popHR + popSI |
I'm trying to install adegenet
package using install_github()
, but I get a few errors. I'm able to install the package if I build and install the package from console. For the latter output see below. I'm using 64-bit Windows 7. I wonder to what can we attribute the discrepancy between these two ways of installing a package?
> install_github("thibautjombart/adegenet/pkg")
Downloading github repo thibautjombart/adegenet@master
Installing adegenet
"C:/PROGRA~1/R/R-31~1.2/bin/x64/R" --vanilla CMD INSTALL \
"C:/Users/romunov/AppData/Local/Temp/RtmpSo6w8C/devtools15882f7c4022/thibautjombart-adegenet-8cca9e1/pkg" \
--library="C:/Users/romunov/Documents/R/win-library/3.1" --install-tests