content
stringlengths 0
14.9M
| filename
stringlengths 44
136
|
---|---|
plot.dke.fun <-
function(x,
main=NULL,
sub = NULL,
xlab=NULL,
ylab=NULL,
type="l",
las=1,
lwd=1,
col="blue",
lty=1,...)
{
class(x) <- "dke.fun"
if(is.null(xlab)) xlab <- "x"
if(is.null(ylab)){
ylab <- "density function"
}
if(is.null(main)){
main <- "Kernel density estimate"
}
if(is.null(sub)){
if(x$kernel=="GA") kerf="gamma"
else if(x$kernel=="BE") kerf= "extended beta"
else if(x$kernel=="LN") kerf= "lognormal"
else if(x$kernel=="RIG") kerf= "reciprocal inverse Gaussian"
sub <- paste("Kernel = ",kerf,";", " h_n = ", formatC(x$h),";"," C_n = ",formatC(x$C_n))
}
hist(x$data,xlab=xlab,ylab=ylab,sub=sub,probability=TRUE,main=main,border ="gray",... )
lines(x$eval.points,x$est.fn,lwd=2,col=col,ylim=c(min(x$est.fn,na.rm = TRUE),max(x$est.fn,na.rm = TRUE)),...)
invisible(NULL)
}
| /scratch/gouwar.j/cran-all/cranData/Ake/R/plot.dke.fun.R |
plot.hcvc.fun <-
function(x,...) plot.hcvc.fun1d (x,...)
| /scratch/gouwar.j/cran-all/cranData/Ake/R/plot.hcvc.fun.R |
plot.hcvc.fun1d <-
function(f,main=NULL,sub = NULL, xlab=NULL, ylab=NULL,
type="l",las=1,lwd=1,...)
{
class(f) <- "bw.fun"
kernel <- f$ker
if(is.null(xlab)) xlab <- "h"
if(is.null(ylab)) ylab <- "CV(h)"
if(is.null(main)){
main <- "Cross-validation"
}
plot.default(f$seq_h,f$CV, type="l",las=las,lwd=lwd,xlab=xlab,ylab=ylab,
main=main,sub=sub,font.main=2,cex.main=0.9,font.sub=2,cex.sub=0.7,...)
}
| /scratch/gouwar.j/cran-all/cranData/Ake/R/plot.hcvc.fun1d.R |
plot.hcvd.fun <-
function(x,...) plot.hcvd.fun1d (x,...)
| /scratch/gouwar.j/cran-all/cranData/Ake/R/plot.hcvd.fun.R |
plot.hcvd.fun1d <-
function(f,main=NULL,sub = NULL, xlab=NULL, ylab=NULL,
type="l",las=1,lwd=1,...)
{
class(f) <- "CV.fun"
kernel <- f$ker
if(is.null(xlab)) xlab <- "h"
if(is.null(ylab)) ylab <- "CV(h)"
if(is.null(main)){
main <- "Cross-validation"
}
plot.default(f$seq_h,f$CV, type="l",las=las,lwd=lwd,xlab=xlab,ylab=ylab,
main=main,sub=sub,font.main=2,cex.main=0.9,font.sub=2,cex.sub=0.7,...)
}
| /scratch/gouwar.j/cran-all/cranData/Ake/R/plot.hcvd.fun1d.R |
plot.kern.fun <-
function(x,...) plot.kern.fun1d (x,...)
| /scratch/gouwar.j/cran-all/cranData/Ake/R/plot.kern.fun.R |
plot.kern.fun1d <-
function(x,main=NULL,sub = NULL, xlab=NULL, ylab=NULL,
pch=18,las=1,lwd=1,...)
{
class(x) <- "kern.fun"
kernel <- x$ker
if(is.null(xlab)) xlab <- "y"
if(is.null(ylab)) ylab <- "Prob(y)"
if(is.null(main)){
main <- "Kernel function"
}
plot.default(x$t,x$kx,pch=pch,las=las,lwd=lwd,xlab=xlab,ylab=ylab,
main=main,sub=sub,font.main=2,cex.main=0.9,font.sub=2,cex.sub=0.7,...)
}
| /scratch/gouwar.j/cran-all/cranData/Ake/R/plot.kern.fun1d.R |
plot.kpmfe.fun <-
function(x,...) plot.kpmfe.fun1d (x,...)
| /scratch/gouwar.j/cran-all/cranData/Ake/R/plot.kpmfe.fun.R |
plot.kpmfe.fun1d <-
function(x,main=NULL,sub = NULL, xlab=NULL, ylab=NULL,
type="h",las=1,lwd=1,...)
{
class(x) <- "kpmfe.fun"
kernel <- x$ker
if(is.null(xlab)) xlab <- "y"
if(is.null(ylab)) ylab <- "Prob(y)"
if(is.null(main)){
main <- "Discrete kernel estimaton"
}
plot.default(x$eval.points,x$est.fn, type="h",las=las,lwd=lwd,xlab=xlab,ylab=ylab,
main=main,sub=sub,font.main=2,cex.main=0.9,font.sub=2,cex.sub=0.7,...)
}
| /scratch/gouwar.j/cran-all/cranData/Ake/R/plot.kpmfe.fun1d.R |
plot.reg.fun <-
function(x,...) plot.reg.fun1d (x,...)
| /scratch/gouwar.j/cran-all/cranData/Ake/R/plot.reg.fun.R |
plot.reg.fun1d <-
function(f,main=NULL,sub = NULL, xlab=NULL, ylab=NULL,
pch=18,las=1,lwd=1,...)
{
class(f) <- "reg.fun"
kernel <- f$ker
if(is.null(xlab)) xlab <- "x"
if(is.null(ylab)) ylab <- "y"
if(is.null(main)){
main <- "kernel regression"
}
plot.default(f$data,f$y,pch=pch,col="grey",las=las,lwd=lwd,xlab=xlab,ylab=ylab,
main=main,sub=sub,font.main=2,cex.main=0.9,font.sub=2,cex.sub=0.7,...)
}
| /scratch/gouwar.j/cran-all/cranData/Ake/R/plot.reg.fun1d.R |
print.reg.fun <-
function(x, digits=NULL, ...)
{
class(x) <- "reg.fun"
if(x$kernel=="GA") kerf="gamma"
else if(x$kernel=="BE") kerf= " extended beta "
else if(x$kernel=="LN") kerf= " lognormal"
else if(x$kernel=="RIG") kerf= " reciprocal inverse Gaussian"
else if(x$kernel=="bino") kerf=" Binomial"
else if(x$kernel=="triang") kerf= " Triangular "
else if(x$kernel=="dirDU") kerf= "DiracDU"
cat("\nBandwidth h:",formatC(x$h,digits=digits), "\tCoef_det = ",x$Coef_det,"\n",
"\nNumber of points: ",x$n,";","\tKernel = ",kerf, "\n\n",sep="")
print(summary(as.data.frame(x[c("data","y")])), digits=digits, ...)
print(summary(as.data.frame(x[c("eval.points","m_n")])), digits=digits, ...)
#invisible(x)
}
| /scratch/gouwar.j/cran-all/cranData/Ake/R/print.reg.fun.R |
reg.fun <-
function(Vec, ...) UseMethod("reg.fun")
| /scratch/gouwar.j/cran-all/cranData/Ake/R/reg.fun.R |
reg.fun.default <-
function(Vec,y,type_data=c("discrete","continuous"),ker=c("bino","triang","dirDU","BE","GA","LN","RIG"),
h,
x=NULL,
a0=0,
a1=1,
a=1,
c=2,
...)
{
if (missing(type_data)) stop("argument 'type_data' is omitted")
if ((type_data=="discrete") & (ker=="GA"||ker=="LN"||ker=="BE" ||ker=="RIG"))
stop(" Not appropriate kernel for type_data")
if ((type_data=="continuous") & (ker=="bino"||ker=="triang"||ker=="dirDU"))
stop(" Not appropriate kernel for 'type_data'")
if ((type_data=="discrete") & missing(ker)) ker<-"bino"
if ((type_data=="continuous") & missing(ker)) ker<-"GA"
if(is.null(x)){x=Vec}
n <- length(x)
m=matrix(0,n,length(Vec))
m2=matrix(0,n,length(Vec))
for(i in 1:n){
for(j in 1:length(Vec)){
m[i,]= kef(x[i],Vec,h,type_data,ker,a0,a1,a,c)
m2[i,]= m[i,]*y
}
}
res<-apply(m,1,sum)
res2<-apply(m2,1,sum)
result<-res2/res
moyY<-mean(y)
R<-sum(((result-moyY)^2))/sum(((y-moyY)^2)) # Coefficient de détermination R^2
structure(list(data=Vec,y=y,n=length(Vec),kernel=ker,h=h,
eval.points=x, m_n = result,Coef_det=R),class="reg.fun")
}
| /scratch/gouwar.j/cran-all/cranData/Ake/R/reg.fun.default.R |
simp_int <-
function (x, fx, n.pts = 256, ret = FALSE)
{
if (inherits(fx, "function") )
fx = fx(x)
n.x = length(x)
if (n.x != length(fx))
stop("Unequal input vector lengths")
if (n.pts < 64)
n.pts = 64
ap = approx(x, fx, n = 2 * n.pts + 1)
h = diff(ap$x)[1]
integral = h * (ap$y[2 * (1:n.pts) - 1] + 4 * ap$y[2 * (1:n.pts)] +
ap$y[2 * (1:n.pts) + 1])/3
return(sum(integral))
}
| /scratch/gouwar.j/cran-all/cranData/Ake/R/simp_int.R |
# file FederovOpt.R
# copyright (C) 2002-2004 by Robert E. Wheeler
#
"optFederov" <-
function (frml,data=sys.frame(sys.parent()),nTrials,center=FALSE,approximate=FALSE,criterion="D",
evaluateI=FALSE,space=NULL,augment=FALSE,rows=NULL,nullify=0,maxIteration = 100,nRepeats=5,
DFrac=1,CFrac=1,args=FALSE)
{
if (!exists(".Random.seed"))
set.seed(555111666)
seed<-.Random.seed
if (missing(frml) || !inherits(frml,c("formula","character"))) {
if (missing(data))
stop("frml and data cannot both be missing.")
frml<-~.
}
if (missing(data)) { # Create a data matrix from the global variables in frml
frmla<-formula(paste("~-1+",paste(all.vars(frml),sep="",collapse="+"),sep=""))
data<-data.frame(model.matrix(frmla,data))
}
else {
if (!inherits(data,"data.frame")) {
data<-data.frame(data) # to insure the columns are named
if (ncol(data)==1)
colnames(data)<-"X1"
}
}
if (any(is.na(data)))
stop("Missing values are not allowed.")
numericColumn<-sapply(data,is.numeric)
if (center) {
means<-apply(data[,numericColumn,drop=FALSE],2,mean)
data[,numericColumn]<-sweep(data[,numericColumn,drop=FALSE],2,means)
}
frml<-expand.formula(frml,colnames(data),numerics=numericColumn)
X<-model.matrix(frml,data)
N <- nrow(X)
k <- ncol(X)
doSpace<-TRUE
if ((criterion=="I" || evaluateI) && !missing(space)) {
S<-model.matrix(frml,space)
B<-t(S)%*%S/nrow(S)
B<-B[lower.tri(B,diag=TRUE)]
doSpace<-TRUE
}
else {
B<-NULL
doSpace<-FALSE
}
nRound<-0
if (missing(nTrials) || nTrials==0) {
if (!augment && !missing(rows)) {
nTrials<-length(unique(rows))
}
else
nTrials<-k+5
}
else {
if (approximate) {
nRound<-nTrials # final approximate design will be rounded to this value
nTrials<-k+5 # the extra 5 is not really needed
}
}
if (nTrials<k)
stop("nTrials must be greater than or equal to the number of columns in expanded X")
if (approximate==FALSE && nTrials>N)
stop("nTrials must not be greater than the number of rows in data")
nTrials<-as.integer(nTrials) # to be safe
if (approximate==FALSE) {
proportions<-NULL
}
else {
proportions<-rep(0,N)
if (maxIteration<=100)
maxIteration<-1000
}
if (criterion=="D") crit<-0
else
if (criterion=="A") crit<-1
else
if (criterion=="I") crit<-2
else
stop("Did not recognize the criterion.")
RandomStart<-TRUE
if (missing(rows) || is.null(rows) || augment) {
if (augment) {
rows<-unique(rows)
augment<-length(rows)
if (augment>nTrials || augment>N)
stop("Number of non-duplicated elements in rows is too large.")
rows<-c(rows-1,rep(0,nTrials-augment))
RandomStart<-FALSE
}
else {
rows<-rep(0,nTrials)
if (nullify!=0)
RandomStart<-FALSE # this has no effect when approximate!=FALSE since nullify is
# always used in the C program
else
RandomStart<-TRUE
}
}
else {
RandomStart<-FALSE;
rows<-unique(rows)
rows<-rows-1
if (length(rows)!=nTrials)
stop("Number of non-duplicated elements in rows must equal nTrials")
}
value<-.Call("FederovOpt", X,as.integer(RandomStart),as.integer(rows),as.integer(nullify),
as.integer(crit),as.integer(evaluateI),as.integer(doSpace),B,as.integer(augment),as.integer(approximate),
as.double(proportions),as.integer(nTrials),as.integer(maxIteration),as.integer(nRepeats),
as.double(DFrac),as.double(CFrac),PACKAGE="AlgDesign")
if (value$error==12) {
stop("Singular design.") }
if (value$error==13) {
stop("Nullifcation failed to find a starting design.")
}
if (value$error!=0)
stop(value$error)
proportions<-0
if (approximate) {
proportions<-value$proportions;
if (nRound>0) {
RowNos<-(1:N)[proportions>(1/(2*maxIteration))]
if (length(RowNos)>nRound) { # in case nRound is less than the number of support points.
RowNos<-sort(proportions,index=TRUE,decreasing=TRUE)$ix
RowNos<-RowNos[1:nRound]
RowNos<-sort(RowNos)
}
proportions<-proportions[RowNos]
proportions<-proportions/sum(proportions)
proportions<-efficient.rounding(proportions,nRound)
RowNos<-RowNos[proportions>0]
proportions<-proportions[proportions>0]
}
else {
RowNos<-(1:N)[proportions>0]
proportions<-proportions[RowNos]
proportions<-round(proportions,4)
}
}
if (approximate==FALSE) {
RowNos<-sort(1+((value$rows[1:nTrials])%%N))
}
if (center) { # reverse centering for ouput
data[,numericColumn]<-sweep(data[,numericColumn,drop=FALSE],2,-means)
}
Design<-data[RowNos,,drop=FALSE]
if (approximate) {
Design<-cbind(proportions,Design)
if (nRound>0)
colnames(Design)[1]<-"Rep.."
else
colnames(Design)[1]<-"Proportion"
}
rownames(Design)<-RowNos
De<-exp(1-1/value$G)
output<-list(D = value$D, A = value$A)
if (criterion=="I" || evaluateI) {
output<-c(output,list( I = value$I))
}
output<-c(output,list(Ge = round(value$G,3),Dea = round(De,3),design=Design,rows=RowNos))
if (args)
output<-c(output,list(seed=seed),args=actuals(formals("optFederov")))
output
}
| /scratch/gouwar.j/cran-all/cranData/AlgDesign/R/FederovOpt.R |
# file MonteOpt.R
# copyright (C) 2002-2004 by Robert E. Wheeler
#
"optMonteCarlo" <-
function(frml,data,nTrials,approximate=FALSE,criterion="D",evaluateI=FALSE,space=NULL,mixtureSum=1,
constraints=NULL,RandomStart=TRUE,nRepeats=5,nCand,nCandNull,DFrac=1,CFrac=1,args=FALSE)
{
if (!exists(".Random.seed"))
set.seed(555111666)
seed<-.Random.seed
RandomLevels<-function(N,s) {
# returns a N element vector of uniform probabilities on s levels
s<-s-1
round(s*runif(N))/s
}
RandomMixture<-function(N) {
# Returns a vector of random Barycentric values.
v<-rexp(N)
v<-v/sum(v)
if (mixtureSum!=0) {
mixtureSum<-round(mixtureSum,mixRound)
v=v*mixtureSum
}
# Must make sure v sums to the rounded mixtureSum
v<-round(v,mixRound)
d<-mixtureSum-sum(v)
i<-sample(1:N)[1]
v[i]<-v[i]+d
v
}
RandomCand<-function (N,nTrials=100)
# Generates a random matrix of centered variable values using the limits in the first two columns of limits
# If the original limits on a variable are (a,b,c) with c the centering value. The limits input here
# should be (a,b-a,c). The Constraint() function expects non-centered values.
{
inside<-0
mat<-matrix(0,nTrials,N)
q<-rep(0,N)
while(inside<nTrials) {
if (N>nMixture)
q[noMixNos]<-Limits[noMixNos,1]+RandomLevels(N-nMixture,nLevels[noMixNos])*Limits[noMixNos,2]
if (doMixture)
q[mixNos]<-RandomMixture(nMixture)
if (is.null(constraints) || constraints(q)) {
inside<-inside+1
if (doCenter)
q[noMixNos]<-q[noMixNos]-Limits[noMixNos,3]
mat[inside,]<-q
}
}
for (i in noMixNos) {
mat[,i]<-round(mat[,i],roundDigits[i])
}
mat
}
randNullify<-function(N,nCand=100) {
# Nullify using random points
rc<-RandomCand(N,nCand)
j<-(sort(apply(rc*rc,1,sum),decreasing=TRUE,ind=TRUE)$ix)[1]
design<-matrix(rc[j,],1,N)
failure<-0
expdes<-t(expand(design))
while (nrow(design)<k && failure<5) {
cand<-RandomCand(N,nCand)
expcand<-t(expand(cand))
aa<-qr(expdes)
if (aa$rank==nrow(design)) {
failure<-0
j<-(sort(diag(t(expcand)%*%(expcand-expdes%*%qr.coef(aa,expcand))),decreasing=TRUE,ind=TRUE)$ix)[1]
design<-rbind(design,cand[j,])
expdes<-cbind(expdes,expcand[,j])
}
else
failure<-failure+1
}
if (failure==5)
stop("Singular Matrix in Nullify")
design
}
expand<-function(M){
colnames(M)<-varNames
v<-data.frame(M)
k<-ncol(v)
for (i in 1:k) {
if (isFactor[i]) {
cl<-v[,i]
v[,i]<-factor(cl,levels=1:nLevels[i])
}
}
frm<-expand.formula(frml,varNames)
model.matrix(frm,v)
}
more=TRUE
if (criterion=="D")
bestCrit<-(-1e8)
else
bestCrit<-1e8
getCenteredDesign<-function(N,nTrials,missTrials) {
design<-0
if (!RandomStart) {
# Uses nullification to find a random design
design<-randNullify(N,nCandNull)
q<-N
expdes<-expand(design)
M<-solve(t(expdes)%*%expdes)*q
# Continues adding points til nTrials is reached
while (q<nTrials) {
cand<-RandomCand(N,nCandNull)
expcand<-expand(cand)
w<-M%*%t(expcand)
d<-diag(expcand%*%w)
j<-sort(d,decreasing=TRUE,ind=TRUE)$ix[1]
design<-rbind(design,cand[j,])
M<-((q+1)/q)*(M-(w[,j]%*%t(w[,j]))/(q+d[j]))
q<-q+1
}
if (nTrials<q) {
return(list(D=0,A=0,I=0,G=0,design=0,iter=0,error=15))
}
}
iter<-0
D<-A<-I<-Ge<-De<-0
error<-NULL
maxIter<-nRepeats
aaBest<-NULL
nT<-nTrials
while(more){
cand<-RandomCand(N,nCand)
if (!RandomStart) {
cand<-rbind(design,cand)
rows<-1:nTrials
}
else
if (approximate) {
rows<-1:nTrials # optFedrov() will take nTrials from the length of rows whem missTrials is TRUE
if (missTrials)
nT<-0
else
nT<-nTrials # optFederov() will round proportions to nTrials
}
else {
rows=NULL
}
colnames(cand)<-varNames
aa<-optFederov(frml,cand,nTrials=nT,approximate=approximate,rows=rows,
criterion=criterion,evaluateI=evaluateI,space=space,
DFrac=DFrac,CFrac=CFrac)
save=FALSE
if ((criterion=="D") && (aa$D>bestCrit)) {
bestCrit<-aa$D
save<-TRUE
}else
if ((criterion=="A") && (aa$A<bestCrit)) {
bestCrit<-aa$A
save<-TRUE
}else
if ((criterion=="I") && (aa$I<bestCrit)) {
bestCrit<-aa$I
save<-TRUE
}
if (save) {
aaBest<-aa
}
else {
more=FALSE
}
iter<-iter+1
if (iter>maxIter) {
more=FALSE
}
}
aaBest
}
if (missing(frml))
stop("A formula is required.")
if (missing(data))
stop("data is required.")
if (criterion!="D" && criterion!="A" && criterion!="I")
stop("Incorrect criterion")
if (approximate && !RandomStart)
stop("Cannot use RandomStart==FALSE with approximate==TRUE")
N<-nrow(data)
isFactor<-as.vector(data[,7])
nLevels<-as.vector(data[,5])
for (i in 1:N) {
if (isFactor[i]) { # reset to produce integer levels, just in case
data[i,c(2,3,4,6)]<-c(1,nLevels[i],0,1)
}
}
varNames<-as.character(data[,1])
Limits<-data.matrix(data[,c(2,3,4)])
Limits[,2]<-Limits[,2]-Limits[,1]
roundDigits<-as.vector(data[,6])
if (ncol(data)==7) {
doMixture=FALSE
mixNos<-NULL
noMixNos<-1:N
nMixture<-0
}
else {
mixtureVariables<-as.logical(data[,8])
doMixture=any(mixtureVariables)
mixNos<-(1:N)[mixtureVariables]
nMixture<-length(mixNos)
noMixNos<-(1:N)[!mixtureVariables]
if (doMixture) {
Limits[mixNos,3]<-0 # just to be safe
mixRound<-max(roundDigits[mixNos],2)
}
}
if (doMixture) { # make sure there is no constant
frml<-deparse(frml,width.cutoff=500)
frml<-paste(frml,"+0",sep="")
frml<-as.formula(frml)
}
doCenter<-FALSE # to stop centering in this use of RandomCand
X<-expand(RandomCand(N,1))
k<-ncol(X)
doCenter <- any(as.logical(match(dimnames(X)[[2]],"(Intercept)", nomatch = 0)))
missTrials<-FALSE # used when approximate
if (missing(nTrials) || nTrials<=0) {
nTrials<-k+5
missTrials<-TRUE
}
if (missing(nCand))
nCand<-10*k
if (missing(nCandNull))
nCandNull<-nCand
output<-getCenteredDesign(N,nTrials,missTrials)
# remove centering
design<-output$design
nRows<-nrow(design)
if (doCenter)
output$design<-design+matrix(Limits[,3],nRows,N,byrow=TRUE)
rownames(output$design)<-1:nRows
# output the criterion values and the uncentered design
output<-output[names(output)!="rows"]
if (args)
output<-c(output,list(seed=seed),args=actuals(formals("optMonteCarlo")))
output
}
| /scratch/gouwar.j/cran-all/cranData/AlgDesign/R/MonteOpt.R |
# file Utility.R
# copyright (C) 2002-2004 by Robert E. Wheeler
#
"expand.formula"<-
function (frml, varNames, const = TRUE, numerics = NULL)
{
env <- environment(frml)
noNumerics <- missing(numerics)
nameargs <- function(...) {
dots <- as.list(substitute(list(...)))[-1]
nm <- names(dots)
fixup <- if (is.null(nm))
seq(along = dots)
else nm == ""
dep <- sapply(dots[fixup], function(x) deparse(x, width.cutoff = 500)[1])
if (is.null(nm))
nm <- dep
else {
nm[fixup] <- dep
}
if (!noNumerics) {
if ((nm[1] == "." && !all(numerics)) || !all(numerics[is.element(varNames,
nm)]))
stop("All arguments to special functions such as quad() must be numeric.")
}
nm
}
find.dot<-function (strng) {
# Returns location of dot in strng or -1 if not found
loc<-regexpr("([^0-9a-zA-Z_]+ *\\.)|(^ *\\.)",strng) #not variable followed by one or more spaces
locp<-loc[1]
if (locp!=-1) { # dot found
leng<-attr(loc,"match.length")
subs<-substring(strng,locp,locp+leng-1) # substring containing dot
locsub<-regexpr("\\.",subs) # loc of dot in substring
return(locp+locsub[1]-1)
}
locp
}
quad <- function(...) {
nms<-nameargs(...)
if (-1!=find.dot(nms)) {
nms <- varNames
nVars <- length(nms)
}
else nVars <- nargs()
strg <- paste(paste("(", paste("X", 1:nVars, sep = "",
collapse = "+"), ")^2", sep = ""), "+", paste("I(X",
1:nVars, "^2)", sep = "", collapse = "+"))
for (i in 1:nVars) {
ag <- paste("X", i, sep = "")
strg <- gsub(ag, nms[i], strg)
}
strg
}
cubic <- function(...) {
nms<-nameargs(...)
if (-1!=find.dot(nms)) {
nms <- varNames
nVars <- length(nms)
}
else nVars <- nargs()
strg <- paste(paste("(", paste("X", 1:nVars, sep = "",
collapse = "+"), ")^3", sep = ""), "+", paste("I(X",
1:nVars, "^2)", sep = "", collapse = "+"), "+", paste("I(X",
1:nVars, "^3)", sep = "", collapse = "+"))
for (i in 1:nVars) {
ag <- paste("X", i, sep = "")
strg <- gsub(ag, nms[i], strg)
}
strg
}
cubicS <- function(...) {
nms<-nameargs(...)
if (-1!=find.dot(nms)) {
nms <- varNames
nVars <- length(nms)
}
else nVars <- nargs()
strg <- paste("(", paste("X", 1:nVars, sep = "", collapse = "+"),
")^3", sep = "")
for (i in 1:(nVars - 1)) {
var <- paste("X", i, sep = "")
strg <- paste(strg, "+", paste(paste("I(", var, paste("*X",
(i + 1):nVars, sep = ""), sep = ""), paste("*(",
var, paste("-X", (i + 1):nVars, "))", sep = "")),
collapse = "+"), sep = "", collapse = "+")
}
for (i in 1:nVars) {
ag <- paste("X", i, sep = "")
strg <- gsub(ag, nms[i], strg)
}
strg
}
findFunction <- function(name, string) {
if (-1 == (strt <- regexpr(name, string)))
return(c(0, 0))
head <- substr(string, 1, strt - 1)
tail <- substr(string, strt, nchar(string))
if (-1 == (fin <- regexpr(")", tail)))
return(c(0, 0))
c(strt, strt + fin - 1)
}
frml <- deparse(frml, width.cutoff = 500)
while ((0 != (pos <- findFunction("quad", frml))[1]) || (0 !=
(pos <- findFunction("cubicS", frml))[1]) || (0 != (pos <- findFunction("cubic",
frml))[1])) {
prog <- substr(frml, pos[1], pos[2])
strHead <- substr(frml, 1, pos[1] - 1)
strTail <- substr(frml, pos[2] + 1, nchar(frml))
prog <- eval(parse(text = prog))
frml <- paste(strHead, prog, strTail, sep = "")
}
if (!const)
frml <- paste(frml, "+0", sep = "")
frml <- as.formula(frml)
environment(frml) <- env
frml
}
"actuals" <-
function(frmals){
# returns the actual argument list of a function
nargs<-length(frmals)
fnames<-names(frmals)
for (i in 1:nargs) {
if (i==1)
actuls=list(eval(parse(text=fnames[i]),sys.frame(-1)))
else
actuls<-c(actuls,list(eval(parse(text=fnames[i]),sys.frame(-1))))
}
names(actuls)<-fnames
actuls
}
"efficient.rounding" <-
function(proportions,n,random=TRUE){
# Efficient rounding, following Pulkesheim and Rieder, (1992). Efficient rounding of
# approximate designs. Biometrika. 79, 763-770
# proportions: a vector of proportions
# n: the integer sum of the rounded proportions
# random: if TRUE will randomly select the weight to change, otherwise the first available will be changed.
l<-length(proportions)
n<-as.integer(n)
if (n<l) # in case input is too small
n<-l
if (any(proportions<0))
stop("Negative weights are not allowed")
if (abs(sum(proportions)-1)>1e-12)
stop("proportions must sum to unity")
ni<-ceiling(proportions*(n-l/2))
N<-sum(ni)
while (N!=n) {
if (N<n) {
m<-ni/proportions
ee<-min(m)
}
else {
m<-(ni-1)/proportions
ee<-max(m)
}
v<-(abs(ee-m)<1e-8)
i<-(1:l)[v]
if (random) {
i<-sample(i)
}
if (N<n) {
ni[i[1]]<-ni[i[1]]+1
}
else {
found=FALSE
for (j in i) {
if (ni[j]>1) {
ni[j]<-ni[j]-1
found=TRUE
break
}
}
if (!found) # this will result in a zero frequency
ni[i[1]]<-ni[i[1]]-1
}
N<-sum(ni)
}
ni
}
"eval.blockdesign" <-
function(frml,design,blocksizes,rho=1,confounding=FALSE,center=FALSE){
# evaluates a blocked design.
# a formula
# a design
# a vector of blocksizes
# rho is a vector of variance component ratios.
# confounding=TRUE, returns the confounding matrix
# center=TRUE, the numeric columns will be centered before model expansion
rownames(design)<-1:nrow(design) # prevents warning messages in case of duplicate rownames
frml<-expand.formula(frml,colnames(design))
design<-data.frame(design)
numericColumns<-sapply(design,is.numeric)
if (center) {
means<-apply(design[,numericColumns,drop=FALSE],2,mean)
design[,numericColumns]<-sweep(design[,numericColumns,drop=FALSE],2,means)
}
des<-model.matrix(frml,design)
desBlkCtr<-des
if (missing(blocksizes))
stop("blocksizes must be specified")
if (any(rho<1e-10 || rho>1e10))
stop("Some rho's are too large or too small")
nB<-length(blocksizes)
fn<-0
S<-matrix(0,nB,ncol(des))
for (i in 1:nB) {
st<-fn+1
fn<-fn+blocksizes[i]
ad<-desBlkCtr[st:fn,]
S[i,]<-apply(ad,2,sum)
ad<-scale(ad,scale=FALSE)
desBlkCtr[st:fn,]<-ad
}
index<-apply((abs(desBlkCtr)<1e-10),2,all) # TRUE corresponds to constant or whole block vars
desUnblocked<-scale(des,scale=FALSE)
# the following combines uncenterd whole terms with centered within terms
desUnblocked<-cbind(des[,index,drop=FALSE],desUnblocked[,!index,drop=FALSE]) # rearrange columns
des<-cbind(des[,index,drop=FALSE],desBlkCtr[,!index,drop=FALSE]) # to conform to these
desBlkCtr<-cbind(desBlkCtr[,index,drop=FALSE],desBlkCtr[,!index,drop=FALSE])
S<-cbind(S[,index,drop=FALSE],S[,!index,drop=FALSE])
constantPosition<-match("(Intercept)",dimnames(des)[[2]],nomatch=0)
k.whole<-sum(index)
k.within<-sum(!index)
nB<-length(blocksizes)
wholeIndex<-c(rep(TRUE,k.whole),rep(FALSE,k.within))
N<-nrow(desUnblocked)
k<-ncol(desUnblocked)
output<-NULL
Mu<-(t(desUnblocked)%*%desUnblocked)/N
Mw<-(t(desBlkCtr[,!wholeIndex,drop=FALSE])%*%desBlkCtr[,!wholeIndex,drop=FALSE])/N
determinant<-det(Mu)
if (determinant<=0)
stop("Singular design")
determinant<-(determinant)^(1/k)
MI<-solve(Mu)
Mbc<-solve((t(des)%*%des)/N)
determinant.within<-det(Mw)
if (determinant.within<=0)
stop("Singular within design")
# If the model contains nesting, the determinant.within will differ
# from that reported by optBlock(), which uses multiplication instead
# of nesting. This is a constant shift of no importance to the optimization
determinant.within<-(determinant.within)^(1/k.within)
if (confounding == TRUE) {
Mbc<-solve((t(des)%*%des)/N)
dg<-diag(-1/diag(Mbc))
output <- list(confounding = round(Mbc%*%dg,4))
}
# calcualate the blocking efficiencies
T<-S[,wholeIndex,drop=FALSE]
S<-S[,!wholeIndex,drop=FALSE];
S<-scale(S,scale=FALSE)
Xa<-desUnblocked[,!wholeIndex,drop=TRUE]
Xa<-scale(Xa,scale=FALSE)
Xb<-desUnblocked[,wholeIndex,drop=TRUE]
M<-t(Xa)%*%Xa
Nb<-t(Xb)%*%Xb
H<-t(Xa)%*%Xb
D<-blocksizes
dM<-det(M)
trM<-sum(diag(solve(M)))
lambda<-matrix(0,3,length(rho))
lambda[1,]<-rho
colnames(lambda)<-rep(" ",length(rho))
rownames(lambda)<-c("rho","lambda.det","lambda.trace")
lambdaD<-lambdaT<-NULL
for (r in rho) {
G<-diag(1/((1/r)+D))
MM<-M-t(S)%*%G%*%S
A1<-H-t(S)%*%G%*%T
A2<-solve(Nb-t(T)%*%G%*%T)
MM<-MM-A1%*%A2%*%t(A1)
dMM<-det(MM)
lambdaD<-c(lambdaD,round((dMM/dM)^(1/k.within),3))
if (dMM>dM*1e-16) {
lambdaT<-c(lambdaT,round(trM/sum(diag(solve(MM))),3))
}
else {
lambdaT=c(lambdaT,0)
}
}
lambda[2,]<-lambdaD
lambda[3,]<-lambdaT
outs<-data.frame(constant=I(rep(" ",4)),whole=I(rep(" ",4)),within=I(rep(" ",4)))
rownames(outs)<-c("df","determinant","gmean.variance","gmean.efficiencies")
whIndex<-wholeIndex
if (constantPosition && k.whole>0) {
df<-k.whole-1
whIndex[constantPosition]<-FALSE
}
else
df<-k.whole
outs[1,]<-c(sprintf("1"),sprintf("%.0f",df),sprintf("%.0f",k.within))
outs[2,3]<-sprintf("%f",determinant.within)
output<-c(output,list(determinant.all.terms.within.terms.centered=determinant))
output<-c(output,list(within.block.efficiencies=lambda))
if (k>nB) {
output<-c(output,list(comment="Too few blocks to recover interblock information."))
}
# variances of blockcentered design
dg<-diag(Mbc)
if (k.whole>0) {
if (constantPosition) {
s<-dg[constantPosition]
outs[3,1]<-sprintf("%f",s)
}
if (sum(whIndex)>0) {
s<-dg[whIndex]
s<-exp(mean(log(s)))
outs[3,2]<-sprintf("%f",s)
}
}
t<-dg[!wholeIndex]
t<-exp(mean(log(t)))
outs[3,3]<-sprintf("%f",t)
# efficiencies of un-blockcentered to blockcentered designs
dg<-(diag(MI)/diag(Mbc))
if (k.whole>0) {
if (constantPosition) {
s<-dg[constantPosition]
outs[4,1]<-sprintf("%f",s)
}
if (sum(whIndex)>0) {
s<-dg[whIndex]
s<-exp(mean(log(s)))
outs[4,2]<-sprintf("%.3f",round(s,3))
}
}
t<-dg[!wholeIndex]
t<-exp(mean(log(t)))
outs[4,3]<-sprintf("%.3f",round(t,3))
output<-c(output,list(block.centered.properties=outs))
output
}
"eval.design" <-
function (frml, design, confounding = FALSE, variances = TRUE,
center = FALSE, X=NULL)
{
rownames(design)<-1:nrow(design) # prevents warning messages in case of duplicated rownames
proportions<-NULL
if (colnames(design)[1]=="Rep..") { # Expand data according to Rep.. from optFederov() output.
ND<-nrow(design)
reps<-design[,1]
design<-design[,-1,drop=FALSE]
design<-design[rep(1:ND,reps),]
rownames(design)<-1:nrow(design)
}
else
if (colnames(design)[1]=="Proportion") {
proportions<-design[,1]
design<-design[,-1,drop=FALSE]
}
frml <- expand.formula(frml, colnames(design))
design <- data.frame(design)
numericColumns <- sapply(design, is.numeric)
if (center) {
means <- apply(design[, numericColumns, drop = FALSE],
2, mean)
design[, numericColumns] <- sweep(design[, numericColumns,
drop = FALSE], 2, means)
}
des <- model.matrix(frml, design)
if (!missing(X)){
X<-data.frame(X)
if (center) {
means <- apply(X[, numericColumns, drop = FALSE],
2, mean)
X[, numericColumns] <- sweep(X[, numericColumns,
drop = FALSE], 2, means)
}
Xd <- model.matrix(frml, X)
}
output <- NULL
if (is.vector(proportions)) {
M<-t(des)%*%diag(proportions)%*%des
}
else {
M <- (t(des) %*% des)/nrow(des)
}
k<-ncol(M)
determinant<-det(M)
if (determinant<=0)
stop("Singular design")
determinant<-(determinant)^(1/k)
trac<-0
Ival<-0
Geff<-0
Deff<-0
orthog<-0
if (determinant>0) {
MI<-solve(M)
if (confounding == TRUE) {
dg<-diag(-1/diag(MI))
output <- list(confounding = round(MI%*%dg,4))
}
trac<-sum(diag(MI))/k
if (!missing(X)) {
CC<-t(Xd)%*%Xd/nrow(Xd)
Ival<-sum(diag(qr.solve(M,CC)))
Z<-t(qr.solve(M,t(Xd)))
Geff<-ncol(Xd)/max(apply(Z*Xd,1,sum))
Deff<-exp(1-1/Geff)
}
cp<-match("(Intercept)",dimnames(M)[[2]],nomatch=0)
if (cp>0) {
orthog<-exp((log(det(M[-cp,-cp]))-sum(log(diag(M)[-cp])))/(k-1))
}
else {
orthog<-exp(log(determinant)-sum(log(diag(M)))/k)
}
}
output <- c(output, list(determinant = determinant,A = trac))
if (!missing(X)) {
output<-c(output,list(I = Ival,Geff = round(Geff,3), Deffbound = round(Deff,3)))
}
output<-c(output,list(diagonality = round(orthog,3)))
if (variances) {
if (determinant > 0) {
t <- diag(solve(M))
if (cp>0)
t<-t[-cp]
t <- exp(mean(log(t)))
output <- c(output, list(gmean.variances = t))
}
}
output
}
"gen.factorial" <-
function(levels,nVars=0,center=TRUE,factors="none",varNames=NULL){
# Generates a full factorial design
# nVars: number of factors. May be missing if length(levels)>1
# levels: a vector of levels
# center: centers non-factorial variables
# factors: variable numbers of the factors or "all" if all are factors
# varNames: the names of the variables
if (length(levels)==1){
levels<-rep(levels,nVars)
if (missing(nVars))
stop("nVars is needed when levels is a scalar")
}
else {
nVars<-length(levels)
}
if (any(levels<1))
stop("All levels must be greater than 1")
N<-prod(levels)
factorVec<-rep(0,nVars)
if (missing(factors)) {
factors<-NULL
}
else
if (is.character(factors)) {
if (factors=="all") {
factors<-1:nVars
factorVec<-rep(1,nVars)
}
else
stop("factors error")
}
else {
nFactors<-length(factors);
for (i in factors)
factorVec[i]<-1
}
design<-matrix(0,N,nVars)
.Call("GetFactorial",design,as.integer(levels),as.integer(center),as.integer(factorVec),PACKAGE="AlgDesign")
design<-data.frame(design)
if (!missing(varNames) && length(varNames==nVars))
colnames(design)<-varNames
else
colnames(design)<-paste("X",1:nVars,sep="")
if (!missing(factors)) {
for (i in factors) {
design[,i]<-factor(design[,i])
}
}
design
}
"model.matrix.formula" <-
function(frml,data=sys.frame(sys.parent()),...){
if (!missing(data)) {
if (!inherits(data,"data.frame"))
stop("data must be a data.frame")
if (!inherits(frml,"formula"))
stop("frml must be a formula")
frml<-expand.formula(frml,colnames(data))
}
model.matrix.default(frml,data,...)
}
"model.matrix.terms"<-
function(...){
model.matrix.default(...)
}
"gen.mixture" <-
function(levels,vars) {
if (is.numeric(vars)) {
nvars<-vars
vars<-paste("X",1:nvars,sep="")
}
else {
nvars<-length(vars)
}
levels<-levels[1]-1
if (levels<1)
stop("levels error")
if (nvars<2)
stop("vars error")
N<-choose(levels+nvars-1,levels);
X<-matrix(0,N,nvars)
.Call("GetMixture", X,as.integer(levels),PACKAGE="AlgDesign")
X<-data.frame(X)
colnames(X)<-vars
X
}
| /scratch/gouwar.j/cran-all/cranData/AlgDesign/R/Utility.R |
# file blockOpt.R
# copyright (C) 2002-2004 by Robert E. Wheeler
#
"optBlock" <-
function (frml,withinData=sys.frame(sys.parent()),blocksizes,rows=NULL,
wholeBlockData=NULL,center=FALSE,nRepeats=5,criterion="D",args=FALSE)
{
if (!exists(".Random.seed"))
set.seed(555111666)
seed<-.Random.seed
contr.block<-function (n, contrasts = TRUE)
{
# makes a contrast matrix with all 1's
# makes the first row all zeros if the first level is zero
if (length(n) <= 1) {
if (is.numeric(n) && length(n) == 1 && n > 1)
levels <- 1:n
else stop("contrasts are not defined for 0 degrees of freedom")
}
else levels <- n
lenglev <- length(levels)
if (contrasts) {
cont <- array(1, c(lenglev, lenglev - 1), list(levels,
NULL))
if (levels[1]==0)
cont[1,]<-0
}
else {
cont <- array(0, c(lenglev, lenglev), list(levels, levels))
cont[col(cont) == row(cont)] <- 1
}
cont
}
set.factors<-function(A,B,indicator=FALSE) {
# Turns variables in A into factors corresponding to those in B
# A and B must have the same number of columns and be data.frames
# if indicator is true, makes the levels start with 0
x<-sapply(B,is.factor)
if (any(x)) {
n<-ncol(B)
for (i in (1:n)[x]) {
m<-length(levels(B[,i]))
if (indicator)
levels<-0:(m-1)
else
levels<-1:m
v<-factor(A[,i],levels=levels)
A[,i]<-C(v,contr.block(levels))
}
}
A
}
remove.nesting<-function(frml) {
# replaces / with *
frml<-deparse(frml)
frml<-gsub("/","*",frml)
frml<-gsub("%in%","*",frml)
frml<-as.formula(frml)
frml
}
######### Check the input and make withinData if necessary
if (missing(frml) || !inherits(frml,c("formula","character"))) {
if (missing(withinData))
stop("frml and withinData cannot both be missing.")
frml<-~.
}
if (missing(withinData)) { # Create a data matrix from the global variables in frml
frmla<-formula(paste("~-1+",paste(all.vars(frml),sep="",collapse="+"),sep=""))
withinData<-data.frame(model.matrix(frmla,withinData))
}
else {
if (!inherits(withinData,"data.frame")) {
withinData<-data.frame(withinData) # to insure the columns are named
if (ncol(withinData)==1)
colnames(withinData)<-"X1"
}
}
if (any(is.na(withinData)))
stop("Missing values are not allowed.")
if (colnames(withinData)[1]=="Rep..") { # Expand data according to Rep.. from optFederov() output.
ND<-nrow(withinData)
reps<-withinData[,1]
withinData<-withinData[,-1,drop=FALSE]
withinData<-withinData[rep(1:ND,reps),]
rownames(withinData)<-1:nrow(withinData)
}
########## Center if needed and prepare to expand the formula
withinBlock<-withinData # to preserve data for output in case of centering
varNames<-colnames(withinBlock)
if (!missing(wholeBlockData)) {
varNames<-c(colnames(wholeBlockData),varNames)
}
numericColumns<-sapply(withinBlock,is.numeric) # used to keep expand.formula honest
if (center) {
meansWithin<-apply(withinBlock[,numericColumns,drop=FALSE],2,mean)
withinBlock[,numericColumns]<-sweep(withinBlock[,numericColumns,drop=FALSE],2,meansWithin)
}
if (!missing(wholeBlockData)) {
if (!inherits(wholeBlockData,"data.frame"))
wholeBlockData<-data.frame(wholeBlockData)
if (colnames(wholeBlockData)[1]=="Rep$") { # Expand data according to Rep$ from optFederov() output.
ND<-nrow(wholeBlockData)
reps<-wholeBlockData[,1]
wholeBlockData<-wholeBlockData[,-1]
wholeBlockData<-wholeBlockData[rep(1:ND,reps),]
rownames(wholeBlockData)<-1:nrow(wholeBlockData)
}
wholeBlock<-wholeBlockData # to preserve wholeBlockData in case of centering
numericWhole<-sapply(wholeBlock,is.numeric)
if (center) {
meansWhole<-apply(wholeBlock[numericWhole],2,mean)
wholeBlock[,numericWhole]<-sweep(wholeBlock[,numericWhole,drop=FALSE],2,meansWhole)
}
numericColumns<-c(numericWhole,numericColumns)
}
if (criterion=="D") crit<-0
else
if (criterion=="Dpc") crit<-1
else
if (criterion=="Dp") crit<-2
else
if (criterion=="OB") crit<-3
else
if (criterion=="OBS") crit<-4
else
stop("Did not recognize the criterion.")
######## The formula
frml<-expand.formula(frml,varNames,numerics=numericColumns)
frml<-remove.nesting(frml)
######### Deal with the whole blocks if present
# Create matrices (Uwh,Within) and (Whole,Uw), where Uwh, and Uw are appropriately
# dimensioned matrices of 1's, in such a fashion that model.matrix() will produce x=xr*delta.
# (see the documentation). Note, the following does not work with nesting, but
# remove.nesting(), above, has changed this to multiplication. The nested and the
# multiplicative models are related by a non-singular linear transformation, with
# first column (1,0,...,0)', which ensures that the D criteria for the two will
# differ by a constant, and thus have no effect on the optimization.
if (!missing(wholeBlockData)) {
if (any(is.na(wholeBlock)))
stop("Missing values are not allowed.")
NW<-nrow(wholeBlock)
kW<-ncol(wholeBlock)
if (NW!=length(blocksizes))
stop("blocksizes and wholeBlock must indicate the same number of blocks")
nV<-length(all.vars(frml))
if (kW>=nV)
stop("All variables seem to be block variables")
ND<-nrow(withinBlock)
kD<-ncol(withinBlock)
wholeBlockNames<-colnames(wholeBlock)
# make NW by kD matrix of 1's to append to wholeBlock
dataW<-data.frame(matrix(1,NW,kD))
colnames(dataW)<-colnames(withinBlock)
dataW<-set.factors(dataW,withinBlock)
# make ND by kW matrix of 1's to preappend to data
wholeD<-data.frame(matrix(1,ND,kW))
colnames(wholeD)<-colnames(wholeBlock)
wholeD<-set.factors(wholeD,wholeBlock)
Z<-cbind(wholeBlock,dataW)
Z1<-data.frame(matrix(c(rep(1,kW),rep(0,kD)),1,(kW+kD)))
colnames(Z1)<-colnames(Z)
Z1<-set.factors(Z1,Z,TRUE)
Z<-model.matrix(frml,Z)
Z1<-model.matrix(frml,Z1) # 1's mark terms involving whole blocks only
# Note, Z1 contains 1 for the intercept
# After expansion, eliminate intercept and any term involving whole blocks only
Z<-Z[,!Z1,drop=FALSE]
withinBlock<-cbind(wholeD,withinBlock)
}
else {
Z<-NULL
}
######### Expand the model in X for within block data and remove any pure whole block terms
X<-model.matrix(frml,withinBlock)
if (!missing(wholeBlockData)) { # eliminate intercept and terms involving whole blocks only
X<-X[,!Z1,drop=FALSE]
}
else { # use this method of removing constant since -1 in the formula will cause
# problems when model.matrix() codes nesting factors.
constPosition<-match("(Intercept)",dimnames(X)[[2]],nomatch=0)
if (constPosition>0)
X<-X[,-constPosition,drop=FALSE]
}
N <- nrow(X)
k <- ncol(X)
nB<-length(blocksizes)
nBlock<-sum(blocksizes)
if (min(blocksizes)>N)
stop("The number of trials must be at least as large as the minimum blocksize.")
if (!missing(rows)) {
if (length(rows)!=nBlock)
stop("The length of rows must equal the sum of the blocksizes.")
if (max(rows)>N)
stop("Some element of rows is larger than the number of withinData rows.")
}
if (missing(wholeBlockData)) {
if (nBlock<(k+nB))
stop("The number of withinData rows is not large enough to support the blocked model.")
doWholeBlock<-FALSE; # used only by Call
}
else {
if (nBlock<(1+k+length(colnames(wholeBlockData))))
stop("The number of withinData rows is not large enough to support the blocked model.")
doWholeBlock<-TRUE; # used only by Call
}
initRows<-TRUE
if (!missing(rows)) {
rows<-rows-1
initRows<-TRUE # used only by Call
}
else
initRows<-FALSE # used only by Call
value <- .Call("BlockOpt", X,as.integer(initRows),as.integer(rows),as.integer(nB),as.integer(blocksizes),
as.integer(doWholeBlock),Z,as.integer(nRepeats),as.integer(crit),PACKAGE="AlgDesign")
if (value$error==13) {
stop("All repeats produced singular designs.")
}
if (value$error==27) {
stop("The Dp algorithimm has produced a singular design.")
}
if (value$error==21)
stop("Overrun maxArray. Please save setup and report this.")
if (value$error>0 && value$error<13)
stop("Memory allocation error.")
BlockArray<-value$BlockArray
Blocks<-list(1)
design<-NULL
fin<-0
rnames<-NULL
for (i in 1:nB) {
bs<-blocksizes[i]
strt<-fin+1
fin<-fin+bs
arr<-sort(BlockArray[strt:fin])
if (missing(wholeBlockData)) {
Blocks[i]<-list(withinData[arr,,drop=FALSE])
design<-rbind(design,withinData[arr,,drop=FALSE])
rnames<-c(rnames,rownames(withinData[arr,,drop=FALSE]))
}
else {
dta<-cbind(wholeBlockData[rep(i,bs),,drop=FALSE],withinData[arr,,drop=FALSE])
colnames(dta)<-varNames
rnames<-c(rnames,rownames(withinData[arr,,drop=FALSE]))
Blocks[i]<-list(dta)
design<-rbind(design,dta)
}
}
names(Blocks)<-paste("B",1:nB,sep="")
output<-list(D=value$D)
if (crit==1)
output<-c(output,list(Dpc=value$Dp))
else
if (crit==2)
output<-c(output,list(Dp=value$Dp))
else
if (crit==3 || crit==4)
output<-c(output,list(SS=value$diagonality))
else
output<-c(output,list(diagonality=round(value$diagonality,3)))
output<-c(output,list(Blocks=Blocks,design=design,rows=as.numeric(rnames)))
if (value$error==22)
print("No improvement over initial random design.")
if (args)
output<-c(output,list(seed=seed),args=actuals(formals("optBlock")))
output
}
| /scratch/gouwar.j/cran-all/cranData/AlgDesign/R/blockOpt.R |
cubic=function(A,B,C,D){
### Function that gets the 4 variables of the cubic equation startuing with the cubic x factor as A.
### All the values are real number.
e1=complex(1);
e2=complex(1);
a=numeric(1);
b=numeric(1);
c=numeric(1);
d=numeric(1);
p=numeric(1);
q=numeric(1);
Dis=complex(1);
u=complex(1);
v=complex(1);
gou=numeric(1);
gov=numeric(1);
test=complex(1);
z=c();
### It is checked wheter only a contstant is remaining.
### In this case the an empty numeric vector is returned.
if(A==0 & B==0 & C==0){
z[1]=0;
z[2]=0;
z[3]=0;
warning("ABC all zero should not be possible when e is not zero\n");
return(z);
};
### If the firts two factors are zero only a linear function remains.
### The solution is simple, because C is not zero. This case has been selected in the
### condition before.
if(A==0 & B==0){
z[1]=(-D)/C;
z[2]=z[1];
z[3]=z[2];
return(z);
};
### If the equatio is of degree 2 a closed solution is known.
### Please recognoze that B can not be zero becuase this case is solved above already.
if(A==0){
z[1]=(-C/(2*B))+sqrt((C/(2*B))**2-(D/B));
z[2]=(-C/(2*B))-sqrt((C/(2*B))**2-(D/B));
z[3]=z[2];
return(z);
}
### The coefficients are normalized to get a 1 infront of the cubic x.
### The coefficients are renamed to fit the names of the solution formular.
### Now a is infront of x square and d is not used any more.
d=A/A;
a=B/A;
b=C/A;
c=D/A;
### Linear transformation to get rid of the squared coefficient.
p=b-(1/3)*(a**2);
q=(2/27)*(a**3)-(1/3)*(a*b)+c;
Dis=(q/2)**2+(p/3)**3;
e1=-0.5+0.5*1i*sqrt(3);
e2=-0.5-0.5*1i*sqrt(3);
u=(-0.5*q+(sqrt(Dis+0i)))**(1/3);
v=(-0.5*q-(sqrt(Dis+0i)))**(1/3);
#print("Startwerte u und v und Dis");
#print(u);
#print(v);
#print(Dis);
#print(p);
#print(q);
### All three solutions are printed as a solution multiplied by a cubic unique root.
### Since 3*u*v+p=0 it is u*v=-(1/3)*p which is checked to be close to zero. This
### necesary for numerical stability.
### All alternativies are tested and the variables u and v are
### turned in the two dimensional space by a cubic untit root
### until this condition is fullfilled.
###
for(gou in c(1:3)){
for(gov in c(1:3)){
test=(u*v+(1/3)*p);
# print(p);
# print("Angfang")
# print(u);
# print(v);
# print(test);
# print("next");
if(abs(u*v-(-1)*(1/3)*p)<0.00001) break;
v=v*e1;
};
if(abs(u*v-(-1)*(1/3)*p)<0.00001) break;
u=u*e1;
};
#### t is the solution. Stored in z elements one two and three.
####
z[1]=u+v;
z[2]=u*e1+v*e2;
z[3]=u*e2+v*e1;
### Now the linear transformation is backwards used. Since a is b and the coefficent of cubic x is 1 t_untransposed=t -(a/3*d) and d=1.
### This leads numeric stable to the cubic roots.
### The solutions are eighter of rank one or rank two and complex roots are symmetric.
###
### linear Backtranformation after normalization of the cubic x coefficient
z=z-a/3;
z[10]=u*e1+v*e1;
z[11]=u*e2+v*e2;
z[4]=p;
z[5]=q;
z[6]=Dis;
return(z);
}
optimalfrequency=function(mm,mmorg){
### The mm is the 2x2 matrix and mmorg is the corresponding 3x3 matrix of the unsorted haplotypes.
### The result is an object of the class "optimalfrequency". The attributes are T value of the t distribution named "Testvalue".
### The propability of not being zero by change called: "prSimilarByChange"
D=det(mm);
r1=sum(mm[,1]);
r2=sum(mm[,2]);
r3=sum(mm[1,]);
r4=sum(mm[2,]);
n=sum(as.numeric(mm));
n2=sum(as.numeric(mmorg));
mmorg=matrix(as.numeric(as.matrix(mmorg))*(1/n2),nrow=length(mmorg[,1]));
LK=D/sqrt(r1*r2*r3*r4);
r11=r3/n;
r12=r4/n;
s11=r1/n;
s12=r2/n;
#n2=sum(as.numeric(mmorg));
rest=(((r11*r11*s11*s11-as.numeric(mmorg[1,1]))**2)/(r11*r11*s11*s11))+(((r11*r11*s11*s12-as.numeric(mmorg[1,2]))**2)/(r11*r11*s11*s12))+
(((r11*r11*s12*s12-as.numeric(mmorg[1,3]))**2)/(r11*r11*s12*s12))+
(((r11*r12*s11*s11-as.numeric(mmorg[2,1]))**2)/(r11*r12*s11*s11))+(((r11*r12*s11*s12-as.numeric(mmorg[2,2]))**2)/(r11*r12*s11*s12))+
(((r11*r12*s12*s12-as.numeric(mmorg[2,3]))**2)/(r11*r12*s12*s12))+
(((r12*r12*s11*s11-as.numeric(mmorg[3,1]))**2)/(r12*r12*s11*s11))+(((r12*r12*s11*s12-as.numeric(mmorg[3,2]))**2)/(r12*r12*s11*s12))+
(((r12*r12*s12*s12-as.numeric(mmorg[3,3]))**2)/(r12*r12*s12*s12));
rest2=rest*(n2); # theoretisch falsch tested chiquadrat verteilung gibt p wert von 1
#rest2=rest;
pr=pchisq(rest2,8);
pr=1-pr;
result=list();
class(result)="optimalfrequency";
result[["LK"]]=LK;
if(r1*r2*r3*r4==0){rest2=-999999999999999999;}
result[["Testvalue"]]=rest2;
result[["prSimilarByChange"]]=pr;
#return(LK,rest2,pr);
return (result);
}
findoptimal=function(A,B,C,D,mmorg,exact=0.00001){
### This programs gets the four element of the solution haplotype matrix and the original 3x3 matrix mmorg
###
###
###
goall=c();
ppall=list();
rest=c();
LK=list();
FitGo=c();
### limiting the number of results that will be returned or coerce to to a numeric contstant
genau=numeric(1);
AA=numeric(3);
BB=numeric(3);
CC=numeric(3);
DD=numeric(3);
genau=exact;
AA=-1;
BB=-1;
CC=-1;
DD=-1;
mm=matrix(rep(0,4),nrow=2)
pp=numeric(1);
p=numeric(3);
p=c();
pmax=numeric(1);
zeahler=c();
maxzaehler=numeric(1);
#class(result)=c("2 Snp with two cubic predicte haplotype counts");
for (go in c(1:length(A))){
### limit is exact paramter
### Handling the real part as almost zero
if(abs(Re(A[go]))<genau){A[go]=A[go]-Re(A[go]);};
if(abs(Re(B[go]))<genau){B[go]=B[go]-Re(B[go]);};
if(abs(Re(C[go]))<genau){C[go]=C[go]-Re(C[go]);};
if(abs(Re(D[go]))<genau){D[go]=D[go]-Re(D[go]);};
#
### Handling the imaginary part as almost zero
if(abs(Im(A[go]))<genau) { A[go]=Re(A[go])};
if(abs(Im(B[go]))<genau) { B[go]=Re(B[go])};
if(abs(Im(C[go]))<genau) { C[go]=Re(C[go])};
if(abs(Im(D[go]))<genau) { D[go]=Re(D[go])};
if(Im(A[go])==0){ AA[go]=A[go]};
if(Im(B[go])==0){ BB[go]=B[go]};
if(Im(C[go])==0){ CC[go]=C[go]};
if(Im(D[go])==0){ DD[go]=D[go]};
# if all values are negative by zero within on solution than the variables are set to zero
#
### If no sensfully result is avaible this case will be left. For example the cubic polynom contains only D.
if(Re(AA[go])>=0 & Re(BB[go])>=0 &Re(CC[go])>=0 & Re(DD[go])>=0 & ! is.na(AA[go]+BB[go]+CC[go]+DD[go])){
mm=matrix(c(Re(AA[go]),Re(BB[go]),Re(CC[go]),Re(DD[go])),nrow=2);
# ppall[[go]]=chisq.test(mm,simulate.p.value=TRUE,B=1000);
# pp=chisq.test(mm,simulate.p.value=TRUE,B=1000)$p.value;
# pp=ppall[[go]]$p.value;
ppall[[go]]=1;
pp=1;
p=c(p,pp);
goall=c(goall,go)
pmax=max(p);
zaehler=go;
# maxzaehler=goall[which(p==pmax)];
# print(AA);
LL=list();
class(LL)="optimalfrequency";
LL=optimalfrequency(mm,mmorg);
class(LK[go])="optimalfrequency";
LK[[go]]=LL;
FitGo[go]=LK[[go]]$Testvalue;
maxzaehler=max(maxzaehler,which(abs(LK[[go]]$Testvalue)==min(abs(FitGo),na.rm=TRUE))*go,na.rm=TRUE);
# rest[go]=LL[[2]];
};
};
#return (pmax,p,A,B,C,D,zaehler,maxzaehler);
output=list(AA[maxzaehler],BB[maxzaehler],CC[maxzaehler],DD[maxzaehler],pmax,p,LK,ppall,goall)
names(output)=c("AA","BB","CC","DD","pmax","p","LK","ppall","goall")
#return(AA[maxzaehler],BB[maxzaehler],CC[maxzaehler],DD[maxzaehler],pmax,p,LK,ppall,goall);
return(output)
}
haplotypeit=function(a,b,c,d,e,f,g,h,i){
### initialization of the variables
### AA,BB,CC,DD are the coefficients of the cubic polynom
### A1,B1,C1,D1 are the coefficients of the haplotype 2x2 matrix
A1=numeric(1);
B1=numeric(1);
C1=numeric(1);
D1=numeric(1);
A1=2*a+b+d;
B1=2*c+b+f;
C1=2*g+h+d;
D1=2*i+h+f;
AA=numeric(1);
BB=numeric(1);
CC=numeric(1);
DD=numeric(1);
A=complex(3);
B=complex(3);
C=complex(3);
D=complex(3);
AA=2*e*e;
BB=-e*e+A1*e+D1*e-B1*e-C1*e-2*e*e;
CC=(-1)*A1*e-D1*e+A1*D1+B1*C1+B1*e+C1*e+e*e;
DD=(-1)*A1*D1;
### Shotpath to the solution if the entry e in the 3x3 matrix is zero
if(e>0){
erg=cubic(AA,BB,CC,DD);
}else{erg=c();erg[1]=0;erg[2]=0;erg[3]=0;};
A[1]=A1+erg[1]*e;
A[2]=A1+erg[2]*e;
A[3]=A1+erg[3]*e;
D[1]=D1+erg[1]*e;
D[2]=D1+erg[2]*e;
D[3]=D1+erg[3]*e;
B[1]=B1+(1-erg[1])*e;
B[2]=B1+(1-erg[2])*e;
B[3]=B1+(1-erg[3])*e;
C[1]=C1+(1-erg[1])*e;
C[2]=C1+(1-erg[2])*e;
C[3]=C1+(1-erg[3])*e;
#### Four vectors are returned. Since the logic of R cahnged when switching version.
#### The routine returns a list named A,B,C,D of vectors
####
output=list(A,B,C,D)
names(output)=c("A","B","C","D")
#return(A,B,C,D)
return(output)
}
callhaplotype=function(dd){
### this functions gets a 3x3 data.frame
### temp3daten is the numeric data.frame of the 3x3 snip1, snip2 crossmatch.
tempbootobj=list();
tempbootci =list();
haplo=list();
resultvector=c();
temp2haplo =as.numeric(t(dd));
temphaplo =haplotypeit(temp2haplo[1],temp2haplo[2],temp2haplo[3],temp2haplo[4],temp2haplo[5],temp2haplo[6],temp2haplo[7],temp2haplo[8],temp2haplo[9]);
haplo=findoptimal(temphaplo[[1]],temphaplo[[2]],temphaplo[[3]],temphaplo[[4]],dd);
resultvector=Re(matrix(c(haplo[[1]],haplo[[2]],haplo[[3]],haplo[[4]]),ncol=2,nrow=2));
return(resultvector);
}
| /scratch/gouwar.j/cran-all/cranData/AlgebraicHaploPackage/R/AlgebraicHaplo.R |
### This tests the result of the first example of the article
print("##############################")
print("This tests the result of the first example of the article \n")
dd2=matrix(c(4,0,0,0,30,0,0,0,23),ncol=3,byrow=TRUE)
callhaplotype(dd2)
callhaplotype(dd2)/(2*57)
### This tests the cubic routine
print("##############################")
print("This tests the cubic routine")
haplotypeit(4,0,0,0,30,0,0,0,23)
### Formated of 4 digits
print("Formated of 4 digits")
round(as.numeric(Re(haplotypeit(4,0,0,0,30,0,0,0,23)$A)),digit=4)
round(as.numeric(Re(haplotypeit(4,0,0,0,30,0,0,0,23)$B)),digit=4)
round(as.numeric(Re(haplotypeit(4,0,0,0,30,0,0,0,23)$C)),digit=4)
round(as.numeric(Re(haplotypeit(4,0,0,0,30,0,0,0,23)$D)),digit=4)
### The second example
print("##############################")
print("The second example: \n")
dd=matrix(c(1212, 2, 0, 679, 0,0,75,0,0), byrow=TRUE, nrow=3)
colnames(dd)=c("CC","CT","TT")
rownames(dd)=c("CC","CT","TT")
callhaplotype(dd)
### Check the result of the cubic equation of the second example
print("##############################")
print("Check the result of the cubic equation of the second example: \n")
temp2haplo =as.numeric(t(dd));
haplotypeit(temp2haplo[1],temp2haplo[2],temp2haplo[3],temp2haplo[4],temp2haplo[5],temp2haplo[6],temp2haplo[7],temp2haplo[8],temp2haplo[9]);
rm(temp2haplo)
### Third example
print("##############################")
print("Third example : \n")
dd3=matrix(c(1030,678,123,1,1,0,0,0,0),ncol=3,byrow=TRUE)
colnames(dd3)=c("AA","AG","GG")
rownames(dd3)=c("CC","CT","TT")
callhaplotype(dd3)
### Check for alternative solutions
print("##############################")
print("Check for alternative solutions: \n")
temp2haplo =as.numeric(t(dd3));
haplotypeit(temp2haplo[1],temp2haplo[2],temp2haplo[3],temp2haplo[4],temp2haplo[5],temp2haplo[6],temp2haplo[7],temp2haplo[8],temp2haplo[9]);
rm(temp2haplo)
print("##############################")
| /scratch/gouwar.j/cran-all/cranData/AlgebraicHaploPackage/inst/testcalls.R |
#'@title Calculating Multiple Performance Metrics of a Prediction Model
#' @description This provides a function to calculate multiple performance metrics for actual and predicted values.
#' @param actual This is the actual time series values
#' @param predicted This is the predicted values of a time series using a model
#'
#' @return
#' \itemize{
#' \item AllMetrics - A data frame containing two columns with first column as the name of the eight metrics and second column as the corresponding values
#' }
#' @export
#'
#' @examples
#' actual <- c(1.5, 2.3, 25, 52, 14)
#' predicted <- c(1.2, 10, 3.5, 4.3, 5.6)
#' # Inside the function 1st specify actual then predicted
#' print(all_metrics(actual, predicted))
#' @references
#' \itemize{
#'\item Garai, S., & Paul, R. K. (2023). Development of MCS based-ensemble models using CEEMDAN decomposition and machine intelligence. Intelligent Systems with Applications, 18, 200202.
#'\item Garai, S., Paul, R. K., Kumar, M., & Choudhury, A. (2023). Intra-annual National Statistical Accounts Based on Machine Learning Algorithm. Journal of Data Science and Intelligent Systems. https://doi.org/10.47852/bonviewJDSIS3202870
#'\item Garai, S., Paul, R.K., Yeasin, M., Paul, A.K. (2024). CEEMDAN-Based Hybrid Machine Learning Models for Time Series Forecasting Using MARS Algorithm and PSO-Optimization. Neural Processing Letters, 56, 92. https://doi.org/10.1007/s11063-024-11552-w
#' }
# all metrics
all_metrics <- function(actual, predicted) {
residuals <- actual - predicted
abs_residuals <- abs(actual - predicted)
# Replace actual with 1e-10 where actual is exactly zero
actual[actual == 0] <- 1e-10
scaled_abs_residuals <- abs_residuals / actual
lag_frame <- data.frame(embed(actual, 2))
diff <- lag_frame[, 1] - lag_frame[, 2]
abs_diff <- abs(diff)
mse <- mean(residuals^2)
rmse <- sqrt(mse)
rrmse <- 100 * rmse / mean(actual)
mae <- mean(abs_residuals)
mape <- 100 * mean(scaled_abs_residuals)
mase <- mae / mean(abs_diff)
nse <- 1 - (mse / (mean(actual^2) - (mean(actual))^2))
wi <- 1 - (mse / mean((abs(actual - mean(actual)) + abs(predicted - mean(actual)))^2))
lme <- 1 - mae / mean(abs(actual - mean(actual)))
AllMetrics <- data.frame(cbind(c("RMSE", "RRMSE", "MAE", "MAPE", "MASE", "NSE", "WI", "LME"),
c(round(rmse, 3), round(rrmse, 3), round(mae, 3), round(mape, 3),
round(mase, 3), round(nse, 3), round(wi, 3), round(lme, 3))))
colnames(AllMetrics) <- c("Metrics", "Values")
dimnames(AllMetrics)
dim(AllMetrics)
return(AllMetrics)
}
| /scratch/gouwar.j/cran-all/cranData/AllMetrics/R/AllMetrics.R |
########################################################################
# Predict retention of a rare allele in a small, bottlenecked population
# Predict accumulation of inbreeding in the same population
# Author: Emily Weiser
# Portions of code drawn from R package 'mohuasim' written by Murray Efford
# 15 May 2012: fixed bug for polygynous systems with juvenile starters
# 1 June 2012: put allele frequency back into output; restructured to use less RAM
# 13 June 2012: added "printplots"
# 16 July 2012: changed abbreviated arguments to full (e.g. "TRUE" instead of "T", "ncol" instead of "nc")
# 20 August 2012: added "all" option to "startAge" argument
# 2 January 2013: Fixed pedigree.summary to work with new version of package pedigree
# 30 June 2013: Updated user manual to fix error in pdfinfo. No change to code or function.
# 21 Dec 2017:
# Added option for harvesting individuals (arguments harvN, harvAge, harvyrs).
# Allowed inisurv and sex ratios to vary among starters, additional releases, and migrants.
# Fixed bug so that if no starters/additional individuals survive initially, the simulation still continues.
# Changed fecundity to draw from a binomial distribution limited to the indicated maximum, rather than an artificially truncated poisson.
# Added new summary functions to output information about reproductive success of individuals (LRS.summary) and age of reproductive individuals (agerepro.summary).
# 11 Jan 2018: minor fix to pass CRAN checks - no change to code functionality
########################################################################
## Define functions used in package "pedigree" to avoid those getting flagged by CRAN checks:
utils::globalVariables(c("calcInbreeding", "orderPed", "pedigree"))
##### Functions needed to run aRetain: ####
## Test for whether a value is a whole number
is.wholenumber<-function(testme, tol=.Machine$double.eps^0.5) abs(testme - round(testme)) < tol
pad <- function (x, l, fill=0) c(x,rep(fill, l-length(x))) ## pad to length l
Blcl <- function (p, n, alpha=0.05)
## Binomial confidence interval
## Wilson score interval with continuity correction after Newcombe (1998)
## Newcombe, Robert G. "Two-Sided Confidence Intervals for the Single Proportion:
## Comparison of Seven Methods," Statistics in Medicine, 17, 857-872 (1998).
{
z <- qnorm(1-alpha/2)
L <- (2*n*p + z^2 - 1 - z * (z^2 - 2 -1/n + 4 * p *(n*(1-p) + 1))^0.5) / (2 * (n + z^2))
ifelse (p == 0, 0, L)
}
Bucl <- function (p, n, alpha=0.05)
## Binomial confidence interval
## Wilson score interval with continuity correction after Newcombe (1998)
## Newcombe, Robert G. "Two-Sided Confidence Intervals for the Single Proportion:
## Comparison of Seven Methods," Statistics in Medicine, 17, 857-872 (1998).
{
z <- qnorm(1-alpha/2)
U <- (2*n*p + z^2 + 1 + z * (z^2 + 2 -1/n + 4 * p *(n*(1-p) - 1))^0.5) / (2 * (n + z^2))
ifelse (p == 1, 1, U)
}
pairoff <- function (ID, sex, maxpairs)
## ID is vector of ID numbers of single birds
## sex is vector of sex codes, one per ID
# e.g. pairoff (ID = 1:20, sex = sample(1:2, 20, replace=TRUE), 6)
{
if ((length(ID) < 2) | (maxpairs < 0.1)) {
mated <- matrix(nrow=0, ncol=2)
unmated <- ID
}
else {
temp <- split(ID, sex)
n <- max(sapply(temp, length))
if (length(temp)==1)
temp <- cbind(temp[[1]], rep(0,n)) # only one sex
else
temp <- sapply(temp, pad, n)
unmated <- getsingles(temp)
mated <- dropsingles(temp)
npair <- nrow(mated)
if (npair > maxpairs) {
unmated <- c(unmated, mated[(maxpairs+1):npair,])
mated <- mated[1:maxpairs,]
}
}
list (mated = mated, unmated = unmated)
}
polypair <- function(males, females, maleLRS)
# All females will gain a mate.
# maleLRS is a list of the average lifetime reproductive success of each corresponding male
{
if (length(females) < 1 | length(males) < 1) {
mated <- matrix(nrow=0, ncol=2)
unmated <- c(males, females)
}
else {
maleprob <- maleLRS / sum(maleLRS) # percent chance of any male being chosen, relative to other males in the current list
matedmales <- rep(NA, length(females))
if(length(males) == 1){
if(maleLRS > 0) { # all females will mate with the only male
mated <- matrix(cbind(females, rep(males, length(females))), ncol=2)
unmated <- matrix(nrow=0, ncol=2)
}
else { # no males with prob mating > 0; no females mate.
mated <- matrix(nrow=0, ncol=2)
unmated <- females
}
}
else {
for(i in 1:length(females)){ matedmales[i] <- sample(males, size=1, prob=maleprob)}
mated <- matrix(cbind(females, matedmales), ncol=2) # list of mated pairs (males may be listed more than once)
unmated <- males[!(males %in% mated)]
}
}
list (mated = mated, unmated = unmated)
}
getsingles <- function (prs) {
if (length(prs)>2) {
unmated <- prs[apply(prs,1,prod) < 0.1,, drop=FALSE]
as.numeric(unmated[unmated > 0.1])
}
else if ((length(prs)==2) & (prod(prs) < 0.1))
as.numeric(prs[prs>0])
else
numeric(0)
}
dropsingles <- function (prs) {
if (length(prs)>2) {
stillpaired <- apply(prs,1,prod) > 0.1 ## otherwise one or other has died
prs[stillpaired,, drop=FALSE]
}
else if ((length(prs)==2) & (prod(prs) > 0.1))
matrix(prs, ncol=2)
else
matrix(nrow=0, ncol=2)
}
breed <- function (prs, genes, jppr, MAXypF, ypFsex, youngSR) {
## Generate juveniles from the birds in prs at the rate of 'jppr' per pair
## parental genes are sampled as appropriate
## sex ratio is proportion (male)
## Input -
## prs 2-column matrix with ID numbers of pair on each row
## genes 2-column matrix with lookup list of parental alleles; rows indexed by ID
## jppr average juveniles per pair...
## youngSR proportion male among juveniles (at end of natal breeding season)
offspring <- matrix(nrow=0, ncol=5)
dimnames(prs) <- NULL
prlist <- c(prs) # listed in same order as genes, jppr
for(i in 1:nrow(prs)){
maleID <- prs[i,2]
femaleID <- prs[i,1]
if(ypFsex=="male") jp <- jppr[which(prlist==maleID)] ## avg num offspring/yr produced by this male
if(ypFsex=="female") jp <- jppr[which(prlist==femaleID)]
if(ypFsex=="both") jp <- mean(c(jppr[which(prlist==maleID)], jppr[which(prlist==femaleID)]))
if(jp > MAXypF) jp <- MAXypF
nrecruit <- rbinom(1,MAXypF,jp/MAXypF) ## randomly draw offspring produced this year, constrained to the maximum allowed
if(nrecruit > MAXypF) nrecruit <- MAXypF # This should no longer be necessary, but include in case.
if (nrecruit == 0) temp <- matrix(nrow=0, ncol=5)
else {
temp <- cbind (sample( c(1,2), nrecruit,
prob = c(1-youngSR, youngSR), replace = TRUE), ## sex, 1=female
sample(genes[which(prlist==femaleID),], nrecruit, replace = TRUE), ## maternal allele
sample(genes[which(prlist==maleID),], nrecruit, replace = TRUE), ## paternal allele
femaleID, maleID) ## dam and sire IDs
dimnames(temp) <- NULL
}
offspring <- rbind(offspring, temp)
}
matrix(offspring, ncol=5)
}
addnew <- function (N, inisurv, SR, exactSR, sourceN, q0) {
## Add new individuals (starters, migrants) with sex and genotypes for each
## Input -
## N number to add
## All other input values are as specified for "aRetain."
newadded <- matrix(nrow=0, ncol=3)
N <- rbinom (1, size = N, prob = inisurv)
if(N > 0) {
if (exactSR) {
nfemale <- round(N*(1-SR))
nmale <- N - nfemale
sex <- rep (c(1,2), c(nfemale, nmale))
}
else sex <- sample (c(1,2), N, prob = c(1-SR, SR), replace = TRUE) ## 1 = female
if (!is.finite(sourceN)) {
genes <- sample (c(0,1), N*2, prob = c(1-q0, q0),
replace = TRUE) ## 1 = rare allele
genes <- matrix(genes, ncol=2)
}
else {
n0 <- round(2*sourceN*(1-q0), digits=0)
n1 <- 2*sourceN - n0
sourcegenes <- c(rep(0,n0), rep(1,n1))
sourcegenes <- sourcegenes[sample (2*sourceN)] ## randomly permute genes HWE
sampled <- sample (1:sourceN, N, replace = FALSE)
genes <- matrix(sourcegenes,ncol=2)[sampled,]
genes <- matrix(genes, ncol=2)
}
newadded <- cbind(sex, genes[,1], genes[,2])
dimnames(newadded) <- NULL ## tidier to leave unlabelled
}
newadded
}
newinfo <- function (new, type, startAge, youngperF, SDypF, MAXypF, meanMLRS, sdMLRS, firstID, y, adsurvival, nonbrsurv, mature, SenesAge, MaxAge, matingSys) {
## Get information for each new individual added to the population
## Input -
## type type of individual to add (1 = initial founder, 2 = additional founder, 4 = migrant)
## firstID number at which to start the list of unique IDs for the new individuals
## y current year
## All other input values are as specified for "aRetain."
n <- nrow(new)
info <- matrix(nrow=0, ncol=12)
if(nrow(new) > 0) {
typeL <- rep(type, n)
if (startAge == "juvenile") year <- rep(y, n) # These will be one year old at year 1 (they are added in year 0)
if (startAge == "young adult") year<-rep((y-mature),times=n) # birth year for young adults
if(startAge == "adult" | startAge == "all") {
# randomly select age of each individual based on the probability of selecting an adult of each age
ages1 <- mature:MaxAge # adult ages
if(startAge == "all") ages1 <- 1:MaxAge # all ages
adsurvivalList <- rep(adsurvival, length(ages1)) # list of survival rate for each adult age
for(i in 1:length(ages1)) { # adjust survival rate for age
if(ages1[i] > SenesAge) adsurvivalList[i] <- adsurvival - (adsurvival / (MaxAge - SenesAge)) * (ages1[i] - SenesAge)
if(ages1[i] <= mature) adsurvivalList[i] <- nonbrsurv
}
indivList <- rep(NA, length(ages1)) # list to fill of proportion of individuals alive at each age
indivList[1] <- 1
for(i in 2:length(indivList)) indivList[i] <- indivList[i-1]*adsurvivalList[i-1] # proportion of individuals alive at each age. This is used as the list of probabilities of an individual of each age being selected to add to the population.
ages <- sample(x=ages1, size=n, prob=indivList, replace=TRUE) # current ages
year <- y - ages # year of birth
}
ypF <- rnorm(n = n, mean = youngperF, sd = SDypF)
indivID <- firstID:(firstID + n - 1)
damsire <- rep(NA, length(indivID))
yrs <- rep(0, length(indivID))
if(length(ypF) > 0){ for(i in 1:length(ypF)) {
if(ypF[i] < 0 ) ypF[i] <- 0 ## remove any negatives
if(ypF[i] > MAXypF ) ypF[i] <- MAXypF ## cannot average more than the maximum annual repro output
} }
if(matingSys == "monogamy") mates <- rep(1, n)
else {
if(sdMLRS == 0) mates <- rep(meanMLRS, n)
else mates <- round(rgamma(n=n, shape = meanMLRS^2 / sdMLRS^2, scale = sdMLRS^2 / meanMLRS), digits=2) # round to ensure that some will be straight 0s, not just very tiny numbers
if(length(mates) > 0){ for(i in 1:length(mates)) {
if(mates[i] < 0) mates[i] <- 0 ## remove any negatives
}}
}
info <- matrix(cbind(indivID, damsire, damsire, new[,1], new[,2], new[,3], typeL, year, ypF, mates, yrs, yrs), ncol=12)
dimnames(info) <- NULL ## tidier to leave unlabelled
}
info
}
##############################################
###########################################################################################
aRetain <- function (q0 = 0.05, sourceN = Inf,
startN = 20, startAge = "juvenile", startSR = 0.5, exactSSR= FALSE, inisurv = c(1,1,1),
addN = 0, addyrs = c(0), addSR = 0.5, exactASR = FALSE,
migrN = 0, migrfreq = 1, migrSR = 0.5, exactMSR = FALSE, mpriority = FALSE, removeL = FALSE,
harvN = 0, harvAge = "all", harvyrs = 0,
K = 100, Klag = 0, KAdults = FALSE, reprolag = 0, mature = 1, matingSys = "monogamy", matingLength = "seasonal", meanMLRS = 1, sdMLRS = 0, reproAgeM = c(1:200), AgeOnMLRS = "age/age", nMatings = 1, retainBreeders = "male", MaxAge = 25, SenesAge = 10, adsurvivalF = 0.80, adsurvivalM = 0.80, nonbrsurv = 0.80, nonbrsurvK = 0.80, juvsurv = 0.80, juvsurvK = 0.80, youngperF = 1.5, SDypF = 0.25, ypF1 = 1, ypF1yr = 1, MAXypF = 2, MAXypFK = 2, ypFsex = "female", youngSR = 0.5, trackall = TRUE, GeneCount = "adult", nyears = 50, nrepl = 100, nreplprint = 10, printplots = FALSE)
{
## Simulate frequency of rare neutral allele in a two-allele system
##
## Calls functions: polypair, pairoff, getsingles, dropsingles, breed, addnew, newinfo, is.wholenumber
##
## Inputs :
##
## q0 Frequency of rare allele in the source population (range 0-1); defaults to 0.05.
## sourceN Size of source population; must be > startN; defaults to Inf (infinite).
## startN Number of starters (or size of bottleneck); not all will become genetic founders. Minimum 2.
## startAge Age class ("juvenile", "young adult", "adult", or "all") of starters and supplemental individuals. If "juvenile", all individuals added are assigned age 0; if "young adult", all are assigned age at maturity; if "adult", ages are selected randomly based on the proportion of individuals in the source population expected to be of each age (based on the survival rates and senescence specified below).
## startSR Sex ratio (proportion male) of starters; defaults to 0.5 (must be between 0 and 1).
## exactSSR Whether startSR gives the exact sex ratio of starters (TRUE) or sexes are assigned randomly based on the probability given by startSR (FALSE); defaults to FALSE.
## inisurv Initial survival rate, as a proportion (range 0-1), of individuals released. Given as a vector, where the first value is for starters, the second is for additional releases, and third is for migrants. Annual mortality applies after this value is used. Defaults to 1 for all three groups.
## addN Vector of numbers of individuals to release in years soon after population establishment ("supplementals"); defaults to 0.
## addyrs Vector of years in which to release supplementals. Each year corresponds to the number of individuals in the same position in the addN vector. Defaults to 0.
## addSR Sex ratio (proportion male) of supplementals; defaults to 0.5 (must be between 0 and 1). This can be either a single value, or a vector, with each element in the vector corresponding to each instance of supplementation (must be the same length as addN).
## exactASR Whether addSR gives the exact sex ratio of individuals released (TRUE) or sexes are assigned randomly based on the probability given by addSR (FALSE); defaults to FALSE. This can be either a single value, or a vector, with each element in the vector corresponding to each instance of supplementation (must be the same length as addN).
## migrN Number of migrants to add (must be a whole number); defaults to 0.
## migrfreq Interval (number of years) at which to add migrN migrants; must be between 1 and nyears, below; defaults to 1.
## migrSR Sex ratio (proportion male) of supplementals; defaults to 0.5 (must be between 0 and 1).
## exactMSR Whether addSR gives the exact sex ratio of individuals released (TRUE) or sexes are assigned randomly based on the probability given by migrSR (FALSE); defaults to FALSE.
## mpriority TRUE or FALSE: whether migrants are given priority over locally produced offspring to recruit into any available breeding vacancies; defaults to FALSE.
## removeL TRUE or FALSE: whether to remove the corresponding number of locally produced adults to make room for migrants in the population; only necessary if retainBreeders = "both"/"female"/"male"; occurs even when population is below K. Defaults to FALSE.
## harvN Number to be removed in each harvest year
## harvAge Age of individuals to be harvested (as for 'startAge'). If not enough individuals of this age are available, the harvest quota (harvN) will not be filled.
## harvyrs Vector of years in which harvest occurs
## K Carrying capacity (population ceiling); defaults to 100.
## Klag Number of years for which population is held at or below initial size (breeding still occurs); indicates a prolonged bottleneck. Defaults to 0.
## KAdults TRUE (K = number of adults) or FALSE (K = total individuals; subadults, nonbreeders, helpers are also subjected to the limit of K). Defaults to FALSE.
## reprolag Number of years after establishment for which no reproduction occurs. Defaults to 0.
## mature Average age (in years) at sexual maturity (first breeding); defaults to 1.
## matingSys Mating system: "monogamy", "polygyny", or "polygynandry". In any case, pairs are formed and breed. With polygyny, each male can be part of more than one pair. With polygynandry, females mate and reproduce multiple times each year. To model a polyandrous system, set to "polygyny" and then input female values for the "male" parameters (and male values for the "female" parameters) in the model. Defaults to "monogamy".
## matingLength "seasonal" or "lifelong". Determines whether individuals retain the same mate from year to year or divorce. Note that if set to "lifelong" with polygyny/polygynandry, males will not obtain any new mates until ALL of their previous mates have died (probably not realistic in most cases). Defaults to "seasonal".
## meanMLRS Mean lifetime reproductive success (LRS), in terms of number of matings that produce young (NOT number of offspring) a male gets over his lifetime. This is a population average for all males, including those that never reproduce, and may be a fraction. Each male will be assigned an individual average from a gamma distribution with this mean and sdMLRS (the shape of the gamma function = (meanMLRS^2)/(sdMLRS^2); scale = (sdMLRS^2)/meanMLRS; see help for R function "rgamma" for more information). The gamma distribution was chosen because of its flexibility in shape appropriate to polygynous mating systems (from strongly right-skewed to nearly symmetrical). The SD:mean ratio is more important than the magnitude of the mean. This individual mean indicates the male's "quality" and will be used to assess his chance of mating, relative to other males present, each year (does not translate directly into actual LRS experienced by that male). Not used if matingSys = "monogamy". Defaults to 1.
## sdMLRS Among-male standard deviation in LRS. Used with meanMLRS as described above. If sdMLRS = 0, all males will have the same chance of breeding each year. Not used if matingSys = "monogamy". Defaults to 0.
## reproAgeM Vector of ages at which males are able to mate successfully. If males may mate at all ages, use 0:maximum possible lifespan. This maximum cannot be set to Inf (unlike MaxAge) but you can use a really high number if unsure of lifespan. Defaults to c(1:200).
## AgeOnMLRS Expression describing the proportion of LRS achieved by a male at a particular age (for ages contained within reproAgeM). The user specifies the form of this expression; it must include "age" (the individual's current age) and no other undefined variables. Example: "-5.4 + 1.5*age - 0.08*age^2" describes a parabolic relationship between age and mating success (proportion of LRS achieved at each age). If there is no effect of age, use the default value of "age/age" (equals 1 so all ages will be assigned the same average, given by meanMLRS). If a given age is not included in reproAgeM, reproductive output at that age will be set to 0 regardless of the value calculated by this equation.
## nMatings Average number of matings per female each year. Only used when matingSys = "polygynandry". Each female mates and breeds the corresponding number of times each year. Repeat matings with the same male are not prohibited and may occur by chance. Where there are multiple matings by females, the value entered for youngperF (below) is interpreted as the average number of offspring produced from each of these matings. Defaults to 1; must be a whole number.
## retainBreeders Should established breeders retain their breeding status from year to year, and prevent young individuals from recruiting if the population is at K? Specify which sex should be retained: "none", "both", "male", or "female". Only used when matingSys = "monogamy." When "none", all new recruits are added to the breeding population; individuals are randomly removed from that pool to truncate the population at K (so new recruits may randomly replace established breeders). When adults will likely survive and prevent new individuals from recruiting, e.g. with territorial species, set this at one of the other values as appropriate for your species. When pairing off widowed or divorced individuals, those of the retained sex(es) that bred previously will be guaranteed a new mate (if available); non-retained adults will compete with new recruits to mate with available adults. If the population is at K, new recruits will only fill vacancies left by adults that died (they will not replace any surviving adults, including females when retainBreeders = "male" and vice versa; i.e. "both" functions the same as "male" and "female" in this part of the model). Defaults to "male".
## MaxAge Maximum allowable lifespan (in years); can be Inf.
## SenesAge Age (in years) after which annual survival will be reduced by senescence. Through this age, adult survival values are set according to adsurvivalF and adsurvivalM (below). After this age, annual survival decreases linearly until MaxAge (at which it is 0): new survival = survival - (survival / (MaxAge - SenesAge)) * (age - SenesAge).
## adsurvivalF Annual survival rate of adult females. All survival rates are given as a proportion (e.g. 0.85).
## adsurvivalM Annual survival rate of adult males.
## nonbrsurv Annual survival rate of nonbreeders (subadults or adults that have never reproduced). Chronologically mature individuals remain in the nonbreeding pool until they die or recruit and are subject to this survival rate.
## nonbrsurvK Annual survival rate of nonbreeders when population is at K (used instead of nonbrsurv). If given, subadult survival probability in each year depends on density of the population at the beginning of that year, according to the Beverton-Holt function for density dependence in survival (as in Morris & Doak 2002, Quantitative Conservation Biology): S(E(t)) = S(0)/(1 + beta * E(t)), where S(E(t)) is survival rate at population density E in year t, S(0) is survival when density is near 0, beta is the decline in survival as density increases, and E(t) is population density at time t. "Density" is defined in our model as the proportion of K that has been filled, as there is no spatial information in the model. The model solves for beta according to the user-specified values for nonbrsurv (S(0)) and nonbrsurvK (S at carrying capacity, where E = 1), then uses beta and S(0) to calculate density-dependent survival probability in each year.
## juvsurv First year survival (from the stage described by youngperF, below, to the beginning of the next breeding season) when population is below K.
## juvsurvK First year survival when population is at K (used instead of juvsurv). Can be equal to juvsurv. Otherwise, juvenile survival is density-dependent as for nonbrsurvK.
## youngperF Average number of offspring produced per mating each year (averaged over all pairs in population). For a polygynandrous female, this is the average number of offspring produced each time she mates with a male (each year): youngperF * nMatings = total average offspring per year. youngperF can be calculated for any reproductive stage (eggs, chicks, independent juveniles) as long as juvsurv indicates the proportion of individuals that survive from this stage to the beginning of the following breeding season. Given as offspring per pair, e.g. 1.5 or 0.75.
## SDypF Among-individual standard deviation of youngperF, e.g. 0.50 or 2.
## ypF1 Where younger breeders have reduced reproductive rates, this can be used to define the reproductive success for first reproductive stage (length of that stage is determined by ypF1yr, below). Given as a proportion of youngperF. E.g. if youngperF = 2 and ypF1 = 0.5, mean reproductive success during the first stage will be 1 offspring per female. Will be < 1 if inexperienced females experience lower reproductive success than older females; but can be > 1 to indicate higher reproductive success for younger females than for older females, e.g. with senescence (youngperF always applies after the age indicated by ypF1yr, below).
## ypF1yr Age after which ypF1 changes to youngperF (e.g. 1 if ypF1 applies to one-year-olds only, or 5 if it applies for the first 5 years and then increases to youngperF from age 6 onward).
## MAXypF Maximum annual number of offspring per individual (e.g. based on biological constraints such as clutch size/renesting). Note that if ypF1 > 1, this value may be exceeded by some individuals.
## MAXypFK Maximum annual number of offspring per individual when population is at K (if different from MAXypF).
## ypFsex Which member of a pair limits the reproductive output for the year, based on the biology of the species of interest. Can be "male", "female", or "both" (the last will average the male's and female's values).
## youngSR Proportion of offspring that are male (range 0-1, defaults to 0.5).
## trackall Whether to track all individuals from the population through the whole simulation (TRUE or FALSE). Must be TRUE if you wish to use indiv.summary or pedigree.summary after running the simulation (see Model Output, next page). The simulations will be noticeably slower (and require more RAM) if this is set to TRUE, especially with larger carrying capacity, higher fecundity, more iterations, and longer simulation periods. Defaults to FALSE.
## GeneCount Which alleles to count as retained: those in the "adult" population only, or those in "all" individuals (including subadults/nonbreeders).
## nyears Number of years to run the simulation. Consider setting a value that corresponds to 10 generations of your study-species.
## nrepl Number of iterations (replicates) to run. More iterations will take longer to run, but will produce narrower confidence limits for allele retention, inbreeding coefficients, and population size. Defaults to 100, but 1000 may be more useful.
## nreplprint Interval (number of replicates) at which to print a message with the current system time. Allows the user to gauge model progress and to estimate time to completion. Defaults to 10.
## printplots logical: whether to plot the population growth (number of individuals, as defined by KAdults, present each year) and allele frequency (in the pool defined by GeneCount) as they change over time. (TRUE or FALSE) One line will be plotted for each replicate immediately after it runs. Can be used to immediately gauge the demographics of the population (e.g. if it will grow as expected); will slow down the simulation by ~ 10-20%. Defaults to FALSE.
##
## CHECK INPUT VALUES
if (q0<=0 | q0>=1) stop ('Initial gene frequency must be between 0 and 1')
if (startN > sourceN) stop ("'startN' cannot exceed 'sourceN'")
if (startN < 2) stop ("'startN' must be at least 2")
if (startAge != "juvenile" & startAge != "adult" & startAge != "young adult" & startAge != "all") stop ("'startAge' must be 'juvenile', 'young adult', 'adult', or 'all'")
if (startSR<=0 | startSR>=1 | addSR[1]<=0 | addSR[1]>=1 | migrSR<=0 | migrSR>=1 | youngSR<=0 | youngSR>=1) stop ("Sex ratios must be between 0 and 1")
if(length(inisurv)!=3) stop("'inisurv' must be a vector of three values, corresponding to starters, additional releases, and immigrants.")
if (inisurv[1] <=0 | inisurv[1] > 1 | nonbrsurv <=0 | nonbrsurv > 1 | nonbrsurvK <=0 | nonbrsurvK > 1 | juvsurv <=0 | juvsurvK > 1 | adsurvivalF <=0 | adsurvivalF > 1) stop ("Survival rates must be between 0 and 1")
for(i in 1:length(addN)) { if (!is.wholenumber(addN[i])) stop ("'addN' must be a vector of whole numbers")}
for(i in 1:length(addyrs)){if (!is.wholenumber(addyrs[i])) stop ("'addyrs' must be a vector of whole numbers")}
if(length(addN) != length(addyrs)) stop ("'addN' and 'addyrs' must be vectors of the same length")
if(length(addSR) > 1) if(length(addSR) != length(addN)) stop("If 'addSR' is a vector, it must be the same length as 'addN'")
if(length(exactASR) > 1) if(length(exactASR) != length(addSR)) stop("If 'exactASR' is a vector, it must be the same length as 'addSR'")
if (!is.wholenumber(migrN)) stop ("'migrN' must be a whole number")
if (!is.wholenumber(migrfreq)) stop ("'migrfreq' must be a whole number")
if (migrN > 0) if (migrfreq > nyears) stop ("'migrfreq' > 'nyears' so no migration will occur during this simulation; 'migrfreq' must be < 'nyears' or equal to 0.")
if (!is.wholenumber(K)) stop ("'K' must be a whole number")
if (!is.wholenumber(Klag)) stop ("'Klag' must be a whole number (# years)")
if (!is.wholenumber(mature)) stop ("'mature' must be a whole number (# years)")
if(MaxAge != Inf) if (!is.wholenumber(MaxAge)) stop ("'MaxAge' must be a whole number")
if(SenesAge != Inf) if (!is.wholenumber(SenesAge)) stop ("'SenesAge' must be a whole number")
if (!is.wholenumber(reprolag)) stop ("'reprolag' must be a whole number")
if (!is.wholenumber(nyears)) stop ("'nyears' must be a whole number")
if (matingLength != "seasonal") if (matingLength != "lifelong") stop("'matingLength' must be 'seasonal' or 'lifelong'")
if (retainBreeders != "none") if (retainBreeders != "both") if (retainBreeders != "male") if (retainBreeders != "female") stop ("'retainBreeders' must be 'none', 'both', 'male', or 'female'")
if (ypFsex != "female") if (ypFsex != "male") if (ypFsex != "both") stop ("'ypFsex' must be 'male', 'female', or 'both'")
if (trackall != TRUE) if(trackall != FALSE) stop("'trackall' must be TRUE or FALSE")
if (matingSys != "polygyny") if (matingSys != "monogamy") if (matingSys != "polygynandry") stop ("'matingSys' must be 'polygyny', 'polygynandry', or 'monogamy'")
if (meanMLRS < 0) stop ("'meanMLRS' must be > 0")
if (sdMLRS < 0) stop ("'sdMLRS' must be a positive value")
if (nMatings > 1) if (matingSys != "polygynandry" | matingLength == "lifelong") stop ("'matingSys' must be set to 'polygynandry' and 'matingLength' must be 'seasonal' if 'nMatings' > 1. Pairs are re-shuffled for each of nMatings matings per season.")
if (!is.wholenumber(nMatings)) stop ("'nMatings' must be whole number")
if (GeneCount != "adult") if (GeneCount != "all") stop ("'GeneCount' must be 'all' or 'adult'")
##########################################
## SET UP REPLICATE FUNCTION
run.one.repl <- function (r) {
## SET UP EMPTY OBJECTS NEEDED LATER
out <- list() # empty list for output for this replicate (one matrix will be added to the list for each year)
census <- matrix(nrow=nyears, ncol=9)
indivdata <- matrix(nrow=0, ncol=7)
numpresent <- 0
population <- matrix(nrow=0, ncol=14)
nonbreeders <- matrix(nrow = 0, ncol=13)
migrants <- matrix(nrow = 0, ncol=13)
startersinfo <- matrix(nrow=0, ncol=13)
juveniles <- matrix(nrow=0, ncol=13)
oldpairs <- matrix(nrow=0, ncol=2)
firstpairs <- matrix(nrow=0, ncol=2)
newadded <- matrix(nrow=0, ncol=13)
indivID <- 0
pairs <- matrix(nrow=0, ncol=2)
singles <- numeric(0)
reprostats <- matrix(nrow=0, ncol=5)
## ADD STARTERS TO ESTABLISH POPULATION
## Individuals are added as if at the end of a breeding season (autumn). They will not breed this year, and will be subject to annual mortality (on top of initial mortality) before breeding next year.
starters <- addnew(startN, inisurv[1], startSR, exactSSR, sourceN, q0)
startersinfo <- matrix(cbind(newinfo(starters, type = 1, startAge, youngperF, SDypF, MAXypF, meanMLRS, sdMLRS, firstID = 1, y=1, adsurvival = mean(adsurvivalF, adsurvivalM), nonbrsurv=nonbrsurv, mature, SenesAge, MaxAge, matingSys), rep(0, nrow(starters))), ncol=13)
indivID <- startersinfo[,1]
## LOOP OVER YEARS
for (y in 1:nyears) {
if(nrow(startersinfo) > 0){
if(startAge == "juvenile") juveniles <- matrix(startersinfo, ncol=13) # put initial starters into juveniles matrix
else nonbreeders <- matrix(startersinfo, ncol=13)
indivID <- startersinfo[,1]
startersinfo <- matrix(nrow=0, ncol=13)
}
else juveniles <- matrix(nrow=0, ncol=13) # reset each year (after year 1)
newID2 <- numeric(0)
oldpairs <- pairs # last year's pairs to assess with retainBreeders this year
numpresent <- length(unique(c(pairs, singles))) # num live adults to be used in density dependence later
## BREEDING
if (nrow(pairs) > 0) {
if(y > reprolag) { # do not breed if within reprolag period
prs <- c(pairs)
parentypp <- rep(NA, length(prs))
parentgenes <- matrix(cbind(rep(NA, length(prs)), rep(NA, length(prs))), ncol=2)
for(i in 1:length(prs)){
parentypp[i] <- population[which(population[,1]==prs[i]),9] # indiv average repro output listed in same order as prs
parentgenes[i,1] <- population[which(population[,1]==prs[i]),5] # genes listed in same order as prs
parentgenes[i,2] <- population[which(population[,1]==prs[i]),6]
}
if(ypF1 != 1){
for(i in 1:length(parentypp)){
if((y - population[which(population[,1]==prs[i]),8]) <= ypF1yr) parentypp[i] <- parentypp[i]*ypF1 # reduce young per pair for individuals in first repro stage
}
}
if(length(unique(c(pairs, singles))) > (K-1)) Mjpp <- MAXypFK
else Mjpp <- MAXypF
# If this is last year of simulation, set up matrix to record number of matings and number of offspring for each individual
if(y==nyears){
live <- matrix(population[which(population[,1] %in% c(pairs,singles,nonbreeders[,1])),], ncol=ncol(population))
if(nrow(live > 0)){
reprostats <- matrix(cbind(live[,1], live[,4], (y - live[,8]), rep(0, nrow(live)), rep(0, nrow(live))), ncol=5)
colnames(reprostats) <- c('ID','sex','age','NMates','NOffspring') # note the last two are just for this year
for(m in 1:nrow(reprostats)) reprostats[m,4] <- reprostats[m,4] + length(prlist[which(prlist==reprostats[m,1])]) # tally pairs that were formed at end of last year
}
}
for(i in 1:nMatings){
new <- breed (pairs, parentgenes, parentypp, Mjpp, ypFsex, youngSR) ## offspring
newinf <- matrix(cbind(newinfo(matrix(new[,1:3], ncol=3), type=3, startAge = "juvenile", youngperF, SDypF, MAXypF, meanMLRS, sdMLRS, firstID=(max(indivID)+1), y, adsurvival = mean(adsurvivalF, adsurvivalM), nonbrsurv, mature, SenesAge, MaxAge, matingSys), rep(y, nrow(new))), ncol=13)
newinf[,2] <- new[,4] # dam ID known for offspring
newinf[,3] <- new[,5] # sire ID known for offspring
juveniles <- matrix(rbind(juveniles, newinf), ncol=13)
indivID <- c(indivID, newinf[,1])
if (i < nMatings) { # still more breeding left for this season; re-form all pairs
singles <- sort(unique(c(singles, pairs))) # split up all pairs if seasonal monogamy
pairs <- matrix(nrow=0, ncol=2)
popalive <- matrix(subset(population, population[,1] %in% singles), ncol=14)
males <- subset(popalive, popalive[,4]==2)
males <- subset(males, males[,8] %in% c(y - reproAgeM)) # males that are of reproductive age
females <- subset(popalive, popalive[,4]==1)
maleID <- males[,1] # everything below is sorted by this order
femaleID <- females[,1]
malemates <- rep(NA, nrow(males))
maleages <- y - males[,8]
# Apply user-specified expression to determine each male's chance of breeding this year, based on his age:
nMatesAtAge <- function(age) {}
body(nMatesAtAge) <- parse(text = AgeOnMLRS)
for(i in 1:length(maleages)){
malemates[i] <- nMatesAtAge(maleages[i])*males[i,9]
if(malemates[i] < 0) malemates[i] <- 0
}
if(sum(malemates) > 0){ # if all males have 0 chance of breeding, no pairs formed
newpairs <- polypair(maleID, femaleID, malemates)
pairs <- matrix(newpairs$mated, ncol=2)
singles <- singles[!(singles %in% pairs)]
}
# Tally the number of mates for each individual (cumulative over all re-pairing events in this loop, AND over all years), for both sexes. Tallied in new column 14 of population object.
prlist <- c(pairs)
for(m in 1:nrow(population)) population[m,14] <- population[m,14] + length(prlist[which(prlist==population[m,1])])
# If this is final year of simulation, tally number of mates for each individual
if(y==nyears) if(nrow(matrix(population[which(population[,1] %in% c(pairs,singles)),], ncol=ncol(population))) >0) if(nrow(reprostats) > 0){
for(m in 1:nrow(reprostats)) reprostats[m,4] <- reprostats[m,4] + length(prlist[which(prlist==reprostats[m,1])])
}
}
}
}
}
# Tally offspring per individual, if last year of simulation:
if(y==nyears) if(nrow(matrix(population[which(population[,1] %in% c(pairs,singles)),],ncol=ncol(population))) >0)if(nrow(reprostats) > 0){
for(m in 1:nrow(reprostats)) reprostats[m,5] <- length(juveniles[,2][which(juveniles[,2]==reprostats[m,1])]) + length(juveniles[,3][which(juveniles[,3]==reprostats[m,1])])
}
# Add juveniles to the age structure output
if(y==nyears) if(nrow(matrix(population[which(population[,1] %in% c(pairs,singles)),], ncol=ncol(population))) >0) reprostats <- rbind(reprostats, matrix(cbind(matrix(juveniles[,c(1,4)], ncol=2), rep(0, nrow(juveniles)), rep(0, nrow(juveniles)),rep(0, nrow(juveniles))), ncol=5))
# Add nonbreeders to the age structure output
if(y==nyears) if(nrow(matrix(population[which(population[,1] %in% c(pairs,singles)),], ncol=ncol(population))) >0) reprostats <- rbind(reprostats, matrix(cbind(matrix(nonbreeders[,c(1,4)],ncol=2), y-nonbreeders[,8], rep(0, nrow(nonbreeders)),rep(0, nrow(nonbreeders))), ncol=5))
## ADD ANY ADDITIONAL FOUNDERS (will not breed until next year)
if (sum(addN) > 0) { if (y %in% addyrs) {
addNy <- addN[which(addyrs==y)]
if(length(addSR) > 1){
addSRy <- addSR[which(addyrs==y)]
eASRy <- exactASR[which(addyrs==y)]
}
else{
addSRy <- addSR
eASRy <- exactASR
}
addstarters <- addnew(addNy, inisurv[2], addSRy, eASRy, sourceN, q0)
if(length(indivID > 0)) mID <- max(indivID)
else mID <- 0
addinfo <- matrix(nrow=0, ncol=13)
addinfo <- matrix(cbind(newinfo(addstarters, type = 2, startAge, youngperF, SDypF, MAXypF, meanMLRS, sdMLRS, firstID = (mID + 1), y, adsurvival = mean(adsurvivalF, adsurvivalM), nonbrsurv, mature, SenesAge, MaxAge, matingSys), rep(y, nrow(addstarters))), ncol=13)
if(length(indivID > 0)) indivID <- c(indivID, addinfo[,1])
else indivID <- addinfo[,1]
if (startAge == "juvenile") juveniles <- matrix(rbind(juveniles, addinfo), ncol=13)
else nonbreeders <- matrix(rbind(nonbreeders, addinfo), ncol=13) # adults go into nonbreeders matrix until they recruit to breed (or die)
}}
## IF y IS MIGRATION YEAR, ADD MIGRANTS.
if (migrN > 0) if(migrfreq > 0) {
if (is.wholenumber(y/migrfreq)){ # migration occurs this year
migrants <- addnew(migrN, inisurv[3], migrSR, exactMSR, sourceN, q0)
migrinfo <- matrix(cbind(newinfo(migrants, type = 4, startAge, youngperF, SDypF, MAXypF, meanMLRS, sdMLRS, firstID = (max(indivID) + 1), y, adsurvival = mean(adsurvivalF, adsurvivalM), nonbrsurv, mature, SenesAge, MaxAge, matingSys), rep(y, nrow(migrants))), ncol=13)
indivID <- c(indivID, migrinfo[,1])
if (startAge == "juvenile") juveniles <- matrix(rbind(juveniles, migrinfo), ncol=13)
else nonbreeders <- matrix(rbind(nonbreeders, migrinfo), ncol=13) # adults go into nonbreeders matrix until they recruit to breed (or die)
if (removeL == TRUE) { # remove local adults to make room for migrants
adultslive <- c(pairs, singles)
adultslive <- adultslive[!(adultslive == 0)]
popalive <- matrix(population[which(population[,1] %in% adultslive),], ncol=14)
poplocals <- subset(popalive, popalive[,7]==3)
if(nrow(poplocals) > migrN) Lremove <- sample(poplocals[,1], size=migrN) # locals to remove
else Lremove <- poplocals[,1] # remove ALL locals
pairs[pairs %in% Lremove] <- 0 # set flag for later removal
singles <- singles[!(singles %in% Lremove)]
}
}}
## HARVEST. Only locally produced individuals will be removed.
if(harvN > 0) if(y %in% harvyrs){ # harvest occurs this year
if(harvAge=="adult"){
adultslive <- c(pairs, singles)
adultslive <- adultslive[!(adultslive == 0)]
popalive <- matrix(population[which(population[,1] %in% adultslive),], ncol=14)
poplocals <- subset(popalive, popalive[,7]==3)
if(nrow(poplocals) > harvN) Lremove <- sample(poplocals[,1], size=harvN) # locals to remove
else Lremove <- poplocals[,1] # remove ALL locals
pairs[pairs %in% Lremove] <- 0 # set flag for later removal
singles <- singles[!(singles %in% Lremove)]
}
if(harvAge=="juvenile"){
juvlocal <- subset(juveniles, juveniles[,7]==3)
if(nrow(juvlocal) > harvN) Lremove <- sample(juvlocal[,1], size=harvN) # locals to remove
else Lremove <- juvlocal[,1] # remove ALL locals
juveniles <- juveniles[which(!(juveniles[,1] %in% Lremove)),] # these will NOT be recorded in population.
}
if(harvAge=="all"){ # does NOT include nonbreeders for simplicity's sake.
adultslive <- c(pairs, singles)
adultslive <- adultslive[!(adultslive == 0)]
popalive <- matrix(population[which(population[,1] %in% adultslive),], ncol=14)
poplocals <- subset(popalive, popalive[,7]==3)
juvlocal <- subset(juveniles, juveniles[,7]==3)
allIDs <- c(poplocals[,1], juvlocal[,1])
if(length(allIDs) > harvN) Lremove <- sample(allIDs, size=harvN)
else Lremove <- allIDs # remove ALL adults and juveniles
pairs[pairs %in% Lremove] <- 0 # set flag for later removal
singles <- singles[!(singles %in% Lremove)]
juveniles <- juveniles[which(!(juveniles[,1] %in% Lremove)),] # these will NOT be recorded in population.
}
}
if(class(juveniles)!="matrix") juveniles <- as.matrix(rbind(juveniles), ncol=13)
## SURVIVAL
# Adults. Some may have been removed by removeL or harvest above, but that will not affect the probability of other individuals surviving.
adultslive <- unique(c(pairs, singles))
adultslive <- adultslive[!(adultslive == 0)]
popalive <- matrix(population[which(population[,1] %in% adultslive),], ncol=14)
if (nrow(popalive) > 0) {
fem <- subset(popalive, popalive[,4]==1) # females
mal <- subset(popalive, popalive[,4]==2) # males
survF <- rep(adsurvivalF, nrow(fem)) # female survival
survM <- rep(adsurvivalM, nrow(mal)) # male survival
ageF <- y - fem[,8] # female ages
ageM <- y - mal[,8] # male ages
if(length(ageF) > 0) for(i in 1:length(ageF)) { # Individual survival probabilities based on age for females
if (ageF[i] >= MaxAge) survF[i] <- 0
else if (ageF[i] >= SenesAge) survF[i] <- adsurvivalF - (adsurvivalF / (MaxAge - SenesAge)) * (ageF[i] - SenesAge)
}
if(length(ageM) > 0) for(i in 1:length(ageM)) { # Individual survival probabilities based on age for males
if (ageM[i] >= MaxAge) survM[i] <- 0
else if (ageM[i] >= SenesAge) survM[i] <- adsurvivalM - (adsurvivalM / (MaxAge - SenesAge)) * (ageM[i] - SenesAge)
}
survs <- c(survF, survM)
IDs <- c(fem[,1], mal[,1])
ages <- c(ageF, ageM)
for (i in 1:length(survs)) if (survs[i] < 0) survs[i]<-0
live <- rep(NA, length(survs))
for (n in 1:length(live)) live[n] <- sample(c(0,1), size=1, prob=c(1-survs[i], survs[i]))
for (i in 1:length(live)) if(ages[i] >= MaxAge) live[i] <- 0 # force mortality of old individuals )
liveID <- IDs * live
liveID <- liveID[liveID != 0]
pairs[!(pairs %in% liveID)] <- 0 # set flag for later removal
singles <- singles[singles %in% liveID]
}
if(sum(pairs)==0) pairs <- matrix(nrow=0, ncol=2)
# Subadults/nonbreeders. Those that die are put into "population" to be recorded as dead individuals.
# Note that nonbreeders were previously referred to as "subadults" so some of the nomenclature below will reflect that (SA/subad = subadult)
if (nrow(nonbreeders) > 0) {
subadindex <- (1:nrow(nonbreeders))
if(nonbrsurvK != nonbrsurv){
beta <- nonbrsurv/nonbrsurvK - 1
pden = numpresent/K
sas <- nonbrsurv/(1 + beta*pden)
}
else sas <- nonbrsurv
ss<-sample(c(0,1), size=length(subadindex), replace=TRUE, prob=c(1-sas, sas))
alive <- subadindex * ss
subadindex <- subadindex[subadindex %in% alive]
nonbrdead <- matrix(nonbreeders[-subadindex,], ncol=13)
nonbreeders <- matrix(nonbreeders[subadindex,], ncol=13)
population <- rbind(population, cbind(nonbrdead, rep(0, nrow(nonbrdead))))
}
# Juveniles. Those that die are put into "population" to be recorded as dead individuals.
if(juvsurvK < juvsurv){
beta <- juvsurv/juvsurvK - 1
pden = numpresent/K
jsv <- juvsurv/(1 + beta*pden)
}
else jsv <- juvsurv
mort <- 1-jsv
if (nrow(juveniles) > 0) {
juvindex <- 1:nrow(juveniles)
js <- sample (c(0,1), size=length(juvindex), replace=TRUE, prob=c(mort,jsv))
alive <- juvindex * js
juvindex <- juvindex[juvindex %in% alive]
juvdead <- matrix(juveniles[-juvindex,], ncol=13)
juveniles <- matrix(juveniles[juvindex,], ncol=13)
population <- matrix(rbind(population, cbind(juvdead, rep(0,nrow(juvdead)))), ncol=14)
}
nonbreeders <- matrix(rbind(nonbreeders, juveniles), ncol=13)
juveniles <- matrix(nrow=0, ncol=13)
## RECRUIT INDIVIDUALS old enough to breed NEXT year.
## If retaining breeders, add only enough to replace adults that die (the rest remain in nonbreeders).
## If mpriority=TRUE, choose migrants type "4" over locals "3".
nonbreeders3 <- matrix(nrow=0, ncol=13)
if (nrow(nonbreeders) > 0) {
x<-((y+1)-mature) # birth year of individuals old enough to breed NEXT year
if(length(subset(nonbreeders, nonbreeders[,8]<=x)) > 0) nonbreeders3<-matrix(subset(nonbreeders, nonbreeders[,8]<=x), ncol=13) # nonbreeders old enough to breed
staySA <- matrix(subset(nonbreeders, nonbreeders[,8]>x), ncol=13) # nonbreeders not old enough
if(retainBreeders == "none" | !KAdults) san <- nrow(nonbreeders3) # allow all mature nonbreeders to recruit and potentially breed. If specified, migrants will be prioritized later (during truncation).
else {
allad <- unique(c(pairs, singles))
allad <- allad[allad != 0]
san <- K - length(c(allad)) # Num subads needed to make up to K
if (san < 0) san <- 0
if (san > 0) {
if(migrN > 0) if (mpriority == TRUE) { # Take maturing nonbreeders from previous migrants:
subadmigr <- matrix(subset(nonbreeders3, nonbreeders3[,7]==4), ncol=13) # nonbreeders old enough to breed that came in as migrants
subadlocal <- matrix(subset(nonbreeders3, nonbreeders3[,7]!=4), ncol=13)
if (nrow(subadmigr) > 0) {
if(san >= nrow(subadmigr)) { # all mature migrants recruit
SAbreed <- matrix(subadmigr, ncol=13)
san <- san - nrow(SAbreed) # Num subads still needed after migrants added
nonbreeders3 <- matrix(subadlocal, ncol=13) # All migrants used so only locals remain as nonbreeders
}
else {
subadMindex <- 1:nrow(subadmigr)
sel <- sample(subadMindex, san) # Select from previous migrants if not all needed
SAbreed <- matrix(subadmigr[sel,], ncol=13)
SAMstay <- matrix(subadmigr[-sel,], ncol=13)
nonbreeders3 <- matrix(rbind(subadlocal, SAMstay), ncol=13) # Remaining mature nonbreeders
san <- 0 # No more subads needed
}
if (nrow(SAbreed) > 0) {
newID2 <- SAbreed[,1]
population <- matrix(rbind(population, cbind(SAbreed, rep(0,nrow(SAbreed)))), ncol=14)
SAbreed <- matrix(nrow=0, ncol=13)
}
}
}
}
}
nonbreeders <- matrix(rbind(staySA, nonbreeders3), ncol=13) # remaining nonbreeders that did not recruit (before final recruitment phase below; if no additional recruitment below, these will carry over to next year)
# If no previous migrants available (or not enough), or if mpriority == FALSE, take from remaining mature subadult pool (nonbreeders3).
if (san > 0) {
if (nrow(nonbreeders3) > 0){
subadindex3<-1:nrow(nonbreeders3)
if (san < length(subadindex3)) subadindex3 <- sample(subadindex3, size=san)
SAmature <- matrix(nonbreeders3[subadindex3,],ncol=13)
if (nrow(SAmature) > 0) nonbreeders3 <- matrix(nonbreeders3[-subadindex3,],ncol=13) # left over nonbreeders that do not mature
else nonbreeders3 <- matrix(nrow=0, ncol=13) # no nonbreeders left over
}
else SAmature <- matrix(nrow=0,ncol=13)
if (nrow(SAmature) > 0){
newID2 <- c(newID2, SAmature[,1])
population <- matrix(rbind(population, cbind(SAmature, rep(0,nrow(SAmature)))), ncol=14) # add to population
dimnames(population) <- NULL
nonbreeders <- matrix(rbind(staySA, nonbreeders3), ncol=13)
SAmature <- matrix(nrow=0, ncol=13)
}
}
}
# Add new recruits to singles (already in population):
if(length(newID2) > 0) singles <- c(singles, newID2)
## TRUNCATE AT CARRYING CAPACITY. This occurs only when KAdults = FALSE and/or when retainBreeders = "none". When KAdults = true AND retainBreeders != "none", recruitment will have been limited so that K is not exceeded (and truncation does not occur).
if (y < (Klag+0.1)) k <- startN
else k <- K
adults2 <- unique(c(singles, pairs))
adults <- adults2[adults2 != 0] # live adults. live subadults/nonbreeders are in "nonbreeders".
## If !KAdults, nonbreeders are included in the grand total. Subadult migrants will also get priority if indicated.
## If KAdults, only adults are included.
ALL <- adults
if(!KAdults) if(nrow(nonbreeders) > 0 ) ALL <- c(adults, nonbreeders[,1])
if(nrow(population) > 0) { if(length(ALL) > k) {
adultslive <- c(pairs, singles)
adultslive <- adultslive[!(adultslive == 0)]
popalive <- matrix(population[which(population[,1] %in% adultslive),], ncol=14) # only live individuals can be selected
mig <- matrix(subset(popalive, popalive[,7]==4), ncol=14)
miga <- mig[,1]
if(KAdults) { ## only adults are limited to K
# Truncation with KAdults will be necessary only when retainBreeders == none; so established breeders get no priority here. Migrants get first priority; then all other adults compete to remain here.
if(migrN > 0) if (mpriority == TRUE){
# migrants that are established breeders get first priority for staying in population
if (length(miga) > k) alive <- sample(miga, k) # enough migrants to make up K by themselves
else {
nm <- ALL[!(ALL %in% miga)] # locally produced adults ID
n <- k - length(miga) # number of locals needed to supplement migrants
if(n > 0) {
if(n < length(nm)) nma <- sample(nm, n) # keep number needed to make up K
if(n > length(nm)) nma <- nm
}
else nma <- numeric(0)
alive <- c(miga, nma) # ID numbers of individuals to keep
}
}
if(migrN == 0 | mpriority == FALSE) alive <- sample (ALL, k) ## retain random sample of k adults
singles <- singles[singles %in% alive]
pairs[!(pairs %in% alive)] <- 0
}
else { ## all individuals are limited to K (including nonbreeders, if any)
# Truncation will be used regardless of retainBreeders; so give any retained adults first priority (as indicated). Then select migrants from those remaining (adults and subadults/nonbreeders). Then select randomly from any other available individuals to fill K.
sbk <- numeric(0)
if(length(ALL) > k) {
n <- k # number needed (to be updated as prioritized individuals are added)
keep <- numeric(0)
left <- numeric(0)
# Keep retained breeders in population (and calculate how many more are needed)
if(retainBreeders == "both"){
keep <- ALL[ALL %in% pairs] # K is never reduced, so ALL birds that bred this year will breed next year (don't truncate any).
left <- ALL[!(ALL %in% keep)] # individuals not yet chosen (including nonbreeders, if any, and non-retained sex, if any)
n <- n - length(keep)
}
if(retainBreeders == "female"){
keep <- ALL[ALL %in% pairs[,1]]
left <- ALL[!(ALL %in% keep)]
n <- n - length(keep)
}
if(retainBreeders == "male"){
keep <- ALL[ALL %in% pairs[,2]]
left <- ALL[!(ALL %in% keep)]
n <- n - length(keep)
}
if(retainBreeders == "none") left <- ALL
# Keep migrants in population, if mpriority = true (and calculate how many more are needed)
if(migrN > 0) if (mpriority == TRUE) {
miga <- miga[miga %in% left] # only adult migrants that have NOT already been selected as retained adults
if(nrow(nonbreeders) > 0) {
sbm <- matrix(subset(nonbreeders, nonbreeders[,7]==4), ncol=13) # migrants
sm <- sbm[,1] # live subadult migrant ID
asm <- c(miga, sm) # all live migrant ID
}
else asm <- miga
if (length(asm) > n){
alive <- sample(asm, n) # enough migrants to make up rest of K by themselves
n <- 0 # no more needed to meet K
}
else{
alive <- asm # all migrants are kept
n <- n - length(alive) # number still needed to meet K
}
ak <- miga[miga %in% alive] # adult migrants to keep
keep <- c(keep, ak)
if(nrow(nonbreeders) > 0) sbk <- sm[sm %in% alive] # subadult migrants to keep
}
n <- k - length(c(keep, sbk)) # number still needed to make up K
# If only some migrants were kept, we have no room for the rest (or any locals).
# If ALL retained breeders and ALL migrants are kept (or no immigrant priority) and we still need more, choose more to keep from locals:
if(n > 0){
if(length(adults[!(adults %in% keep)]) > 0) anm <- adults[!(adults %in% keep)] # adults not already selected to keep (local non-retained)
else anm <- 0
if(nrow(nonbreeders) > 0) {
sbn <- matrix(subset(nonbreeders, nonbreeders[,7]!=4), ncol=13) # local nonbreeders
sbnID <- sbn[,1] # IDs of local nonbreeders = row number in "nonbreeders"
nm <- c(anm, sbnID) # all nonmigrant IDs
}
else nm <- anm
if(length(nm) > n) nma <- sample(nm, n) # keep number of locals needed to make up K
else nma <- nm # keep all locals if room for them all in K
anmk <- anm[anm %in% nma] # adult locals to keep
keep <- c(anmk, keep) # adults to keep
if(nrow(nonbreeders) > 0) {
sblk <- sbnID[sbnID %in% nma] # subadult locals to keep
sk <- c(sblk, sbk) # nonbreeders to keep
nonbreeders <- matrix(nonbreeders[which(nonbreeders[,1] %in% sk),], ncol=13) # nonbreeders still in the population
}
}
singles <- singles[singles %in% keep]
pairs[!(pairs %in% keep)] <- 0
} }
} }
## PAIRING
# length(unique(c(pairs))) is the number of live paired individuals
# oldpairs gives the list of pairs from end of last year (before mortality etc this year)
# reassign all adults to pairs (or leave as singles) when seasonal mating; otherwise retain pairs from last year.
# population truncation to K has already occurred, so the number of pairs that can form is not limited.
adultslive <- c(pairs, singles)
adultslive <- adultslive[!(adultslive == 0)]
popalive <- matrix(population[which(population[,1] %in% adultslive),], ncol=14)
if (nrow(popalive) > 0) {
if (matingSys != "monogamy"){
singles <- unique(c(singles, getsingles(pairs))) # add newly widowed to 'singles'
pairs <- dropsingles(pairs) ## drop widowed birds from pair list
singles <- sort(singles[!(singles %in% pairs)]) # male that lost one female will be put into 'singles' above, but may still have other females, so is not actually single - take him out here.
if (matingLength == "seasonal") {
singles <- sort(unique(c(singles, pairs))) # split up all pairs if seasonal monogamy
pairs <- matrix(nrow=0, ncol=2)
} # if mating is lifelong, previous pairs remain and only single individuals will be paired off
if(length(singles) > 1) { # if not, cannot make new pairs
livesingles <- matrix(subset(population, population[,1] %in% singles), ncol=14)
males <- subset(livesingles, livesingles[,4]==2)
reproyrs <- (y+1) - reproAgeM # birth years of males that will be of reproductive age next year
males <- subset(males, males[,8] %in% reproyrs) # males that will be of reproductive age
females <- subset(livesingles, livesingles[,4]==1)
if(nrow(males) > 1) if(nrow(females) > 1){ # if not, cannot make new pairs
maleID <- males[,1]
femaleID <- females[,1]
malemates <- rep(NA, nrow(males))
maleages <- y+1 - males[,8] # age NEXT year
# Apply user-specified expression to determine each male's chance of breeding NEXT year, based on his age NEXT year:
nMatesAtAge <- function(age) {}
body(nMatesAtAge) <- parse(text = AgeOnMLRS)
for(i in 1:length(maleages)){
malemates[i] <- nMatesAtAge(maleages[i])*males[i,10]
if(malemates[i] < 0) malemates[i] <- 0
}
if(sum(malemates) > 0){ # if all males have 0 chance of breeding, no new pairs formed this year
newpairs <- polypair(maleID, femaleID, malemates)
pairs <- rbind(pairs, newpairs$mated)
singles <- singles[!(singles %in% pairs)]
}
# Tally the number of mates for each individual (cumulative over all years), for both sexes. Tallied in new column 14 of population object.
prlist <- c(pairs)
for(m in 1:nrow(population)) population[m,14] <- population[m,14] + length(prlist[which(prlist==population[m,1])])
}
}
}
else { # retainBreeders only comes into play with monogamy.
if (retainBreeders=="none"){
singles <- sort(c(singles, getsingles(pairs))) # add newly widowed to 'singles'
pairs <- dropsingles(pairs) ## drop widowed birds from pair list
if (matingLength == "seasonal") {
singles <- sort(c(singles, pairs)) # all pairs are split up
pairs <- matrix(nrow=0, ncol=2)
} # otherwise pairs remain as they were, and only single/widowed birds are paired up now.
livesingles <- matrix(subset(population, population[,1] %in% singles), ncol=14)
newpairs <- pairoff(livesingles[,1], livesingles[,4], Inf) # new pairs from all adults
pairs <- rbind(pairs, newpairs$mated)
singles <- newpairs$unmated
}
else {
fwid <- matrix(nrow=0, ncol=14)
mwid <- matrix(nrow=0, ncol=14)
fwidID <- numeric(0)
mwidID <- numeric(0)
mprID <- numeric(0)
fprID <- numeric(0)
msinID <- numeric(0)
fsinID <- numeric(0)
pd <- c(oldpairs)
pd <- sort(pd[pd %in% pairs]) # do not include previously paired adults that have died
prs <- matrix(subset(population, population[,1] %in% pd), ncol=14) # Previously paired adults that are still alive
mpr <- subset(prs, prs[,4]==2) # males previously paired
fpr <- subset(prs, prs[,4]==1) # females previously paired
if(nrow(mpr) > 0) mprID <- c(mpr[,1]) # male paired ID
if(nrow(fpr) > 0) fprID <- c(fpr[,1]) # female paired ID
widows <- sort(getsingles(pairs))
pairs <- dropsingles(pairs) # drop widowed birds
newpairs <- matrix(pairs[!(pairs %in% oldpairs)], ncol=2) # not including indiv paired last year
if (length(widows) > 0) {
wid <- matrix(subset(population, population[,1] %in% widows), ncol=14)
mwid <- matrix(subset(wid, wid[,4]==2), ncol=14) # Select male widow
fwid <- matrix(subset(wid,wid[,4]==1), ncol=14) # Select female widows
if(nrow(mwid)>0) mwidID <- c(mwid[,1]) # male widow ID
if(nrow(fwid)>0) fwidID <- c(fwid[,1]) # female widow ID
}
newsingles <- sort(singles[!(singles %in% oldpairs)]) # does not included paired indiv from last year that are now single
sing <- matrix(subset(population, population[,1] %in% newsingles), ncol=14)
fsin <- subset(sing,sing[,4]==1) # single females
msin <- subset(sing,sing[,4]==2) # single males
if(nrow(fsin) > 0) fsinID <- c(fsin[,1]) # single female ID
if(nrow(msin) > 0) msinID <- c(msin[,1]) # single male ID
if (retainBreeders == "both"){
if (matingLength == "lifelong") {
toprm <- c(mwidID, fsinID) # widowed males and single females to pair off
toprf <- c(fwidID, msinID) # widowed females and single males to pair off
toprmpop <- matrix(subset(population, population[,1] %in% toprm), ncol=14)
toprfpop <- matrix(subset(population, population[,1] %in% toprf), ncol=14)
mp <- pairoff(toprmpop[,1], toprmpop[,4], Inf) # pair off single females with established males
fp <- pairoff(toprfpop[,1], toprfpop[,4], Inf) # pair off single males with established females
singles <- c(mp$unmated, fp$unmated)
singpop <- matrix(subset(population, population[,1] %in% singles), ncol=14)
mf <- pairoff(singpop[,1], singpop[,4], Inf) # pair off any remaining singles
singles <- mf$unmated
pairs <- matrix(rbind(pairs, newpairs, mp$mated, fp$mated, mf$mated), ncol=2)
}
if (matingLength == "seasonal") {
pdpop <- matrix(subset(population, population[,1] %in% pd), ncol=14)
pp <- pairoff(pdpop[,1], pdpop[,4], Inf) # pairoff previous pairs first
pairs <- pp$mated
ps <- pp$unmated # previously paired individuals left single
pspop <- matrix(subset(population, population[,1] %in% ps), ncol=14)
psf <- subset(pspop, pspop[,4]==1)
psfID <- psf[,1] # previously paired females left single
psm <- subset(pspop, pspop[,4]==2)
psmID <- psm[,1] # previously paired males left single
if(nrow(pairs) < Inf) {
if (length(psfID) > 0) { # pair off previously paired females
topr <- c(psfID, msinID)
toprpop <- matrix(subset(population, population[,1] %in% topr), ncol=14)
pf <- pairoff(toprpop[,1], toprpop[,4], Inf)
pairs <- rbind(pairs, pf$mated)
}
if (length(psmID) > 0) { # pair off previously paired males
topr <- c(psmID, fsinID)
toprpop <- matrix(subset(population, population[,1] %in% topr), ncol=14)
pm <- pairoff(toprpop[,1], toprpop[,4], Inf)
pairs <- rbind(pairs, pm$mated)
}
}
fsinID <- fsinID[!(fsinID %in% pairs)]
msinID <- msinID[!(msinID %in% pairs)]
sinID <- c(msinID, fsinID) # remaining single individuals to pair
sinpop <- matrix(subset(population, population[,1] %in% sinID), ncol=14)
pn <- pairoff(sinpop[,1], sinpop[,4], Inf)
if(nrow(pairs) > 0) pairs <- rbind(pairs, pn$mated)
else pairs <- pn$mated
singles <- singles[!(singles %in% pairs)]
}
}
if (retainBreeders == "male") {
if (matingLength == "lifelong") if(nrow(mwid) > 0){
singles <- sort(c(singles, fwidID)) # Intact pairs remain; widowed females join singles
sing <- matrix(subset(population, population[,1] %in% singles), ncol=14)
fsin <- matrix(subset(sing,sing[,4]==1), ncol=14)
if(nrow(fsin) > 0) fsinID <- c(fsin[,1]) # single female ID
topr <- c(mwidID, fsinID) # widowed males and single females to pair off
toprpop <- matrix(subset(population, population[,1] %in% topr), ncol=14)
mp <- pairoff(toprpop[,1], toprpop[,4], Inf) # pair off single females with established males
singles <- singles[!(singles %in% mp$mated)]
if(length(mp$mated)>0){
if(length(pairs)>0) pairs <- matrix(rbind(pairs, mp$mated),ncol=2)
else pairs <- matrix(mp$mated,ncol=2)
}
}
if (matingLength == "seasonal"){
singles <- sort(c(singles, fprID)) # when no long-term mating, all females put into singles to re-pair
sing <- matrix(subset(population, population[,1] %in% singles), ncol=14)
fsin <- matrix(subset(sing,sing[,4]==1), ncol=14)
if(nrow(fsin) > 0) fsinID <- c(fsin[,1]) # single female ID
topr <- c(mprID, fsinID) # previously paired males and all females
toprpop <- matrix(subset(population, population[,1] %in% topr), ncol=14)
prs <- pairoff(toprpop[,1], toprpop[,4], Inf) # pair off females with established males
singles <- singles[!(singles %in% prs$mated)]
if(length(prs$mated)>0) pairs <- prs$mated
else pairs <- matrix(nrow=0, ncol=2)
}
}
if (retainBreeders=="female") {
if (matingLength == "lifelong") if(length(fwidID)>0){
singles <- sort(c(singles, mwidID)) # Intact pairs remain; widowed males join singles
sing <- matrix(subset(population, population[,1] %in% singles), ncol=14)
msin <- matrix(subset(sing,sing[,4]==2), ncol=14)
if(nrow(msin) > 0) msinID <- c(msin[,1]) # single male ID
topr <- c(fwidID, msinID) # widowed females and single males to pair off
toprpop <- matrix(subset(population, population[,1] %in% topr), ncol=14)
fp <- pairoff(toprpop[,1], toprpop[,4], Inf) # pair off single males with established females
singles <- singles[!(singles %in% fp$mated)]
if(length(fp$mated)>0){
if(length(pairs)>0) pairs <- matrix(rbind(pairs, fp$mated),ncol=2)
else pairs <- matrix(fp$mated,ncol=2)
}
}
if (matingLength == "seasonal") {
singles <- sort(c(singles, mprID)) # when no long-term mating, all males put into singles to re-pair
sing <- matrix(subset(population, population[,1] %in% singles), ncol=14)
msin <- matrix(subset(sing,sing[,4]==2),ncol=14)
if(nrow(msin) > 0) msinID <- c(msin[,1]) # single male ID
topr <- c(fprID, msinID) # previously paired females and all males
toprpop <- matrix(subset(population, population[,1] %in% topr), ncol=14)
prs <- pairoff(toprpop[,1], toprpop[,4], Inf) # pair off any males with established females
singles <- singles[!(singles %in% prs$mated)]
if(length(prs$mated)>0) pairs <- matrix(prs$mated,ncol=2)
else pairs <- matrix(nrow=0, ncol=2)
}
}
if(length(singles) > 0) { # If still singles left, make more pairs
sing <- matrix(subset(population, population[,1] %in% singles), ncol=14)
more <- pairoff(sing[,1], sing[,4], Inf)
pairs <- matrix(rbind(pairs, more$mated),ncol=2)
singles <- singles[!(singles %in% more$mated)]
}
}
# Tally the number of mates for each individual (cumulative over all years), for both sexes. Tallied in new column 14 of population object.
prlist <- c(pairs)
for(m in 1:nrow(population)) population[m,14] <- population[m,14] + length(prlist[which(prlist==population[m,1])])
}
}
## UPDATE LIVE INDIVIDUALS; # YEARS ALIVE, # YEARS BRED FOR EACH
singles <- singles[!(singles==0)]
liveadults <- unique(c(pairs, singles))
if(nrow(population) > 0){
# Drop dead individuals if specified:
if(!trackall) population <- matrix(population[which(population[,1] %in% liveadults),], ncol=14)
numpresent <- length(liveadults)
if(!KAdults) numpresent <- numpresent + nrow(nonbreeders) # nonbreeders are included in K
# Add 1 year to col 11 in population/nonbreeders for all individuals alive (in nonbreeders or liveadults):
if(nrow(nonbreeders) > 0) {
tally <- c(nonbreeders[,11] + 1)
nonbreeders <- matrix(cbind(nonbreeders[,1:10, drop=FALSE], tally, nonbreeders[,12:13, drop=FALSE]), ncol=13)
}
popalive <- matrix(population[which(population[,1] %in% liveadults),], ncol=14)
tally <- c(popalive[,11] + 1)
popalive <- matrix(cbind(popalive[,1:10, drop=FALSE], tally, popalive[,12:14, drop=FALSE]), ncol=14)
popdead <- matrix(population[-(which(population[,1] %in% liveadults)),], ncol=14)
population <- rbind(popdead, popalive)
# Add 1 year bred to col 12 for individuals in pairs:
popprs <- matrix(population[which(population[,1] %in% pairs),], ncol=14)
if(nrow(popprs) > 0) {
tally <- popprs[,12] + 1
popprs <- matrix(cbind(popprs[,1:11, drop=FALSE], tally, popprs[,13:14, drop=FALSE]), ncol=14)
popunpr <- matrix(population[-(which(population[,1] %in% pairs)),], ncol=14)
population <- matrix(rbind(popprs, popunpr), ncol=14)
}
}
## CENSUS
adults <- unique(c(pairs,singles)) # list of IDs of all live adults
allID <- c(adults, nonbreeders[,1]) # unique IDs of all live individuals
if(nrow(nonbreeders) == 0) nnb <- 0
else nnb <- nrow(nonbreeders)
if(length(pairs) == 0) npr <- 0
else npr <- nrow(pairs)
if (length(allID)==0) break
census[y,1] <- length(adults) # number of adults
census[y,2] <- length(unique(c(pairs[,1]))) # number of breeding females
census[y,3] <- length(unique(c(pairs[,2]))) # number of breeding males
popprs <- matrix(population[which(population[,1] %in% unique(c(pairs))),], ncol=14)
popalive <- matrix(population[which(population[,1] %in% adults),], ncol=14) # live adults
if(GeneCount == "adult"){
census[y,4] <- sum(popprs[,5:6]) # number of rare alleles in breeding adult population
counted <- popprs
}
else{
census[y,4] <- sum(popalive[,5:6]) + sum(nonbreeders[,5:6]) # number of rare alleles in whole population
counted <- rbind(popalive, cbind(nonbreeders, rep(0, nrow(nonbreeders))))
}
census[y,5] <- npr # number of pairs
census[y,6] <- nnb # number of nonbreeders
census[y,7] <- nrow(subset(popalive,popalive[,7]==1 | popalive[,7]==2)) + nrow(subset(nonbreeders, nonbreeders[,7]==1 | nonbreeders[,7]==2)) # number of starters remaining, including supplementals (from addN)
census[y,8] <- nrow(subset(popalive,popalive[,7]==4)) + nrow(subset(nonbreeders, nonbreeders[,7]==4)) # number of migrants in population
census[y, 9] <- mean((y+1) - popprs[,8]) # mean age of breeding adults in population NEXT yr
# translate NAs into 0s (for summary purposes)
for(i in 1:nrow(census)){
for(j in 1:ncol(census)){
if(is.na(census[i,j])) census[i,j] <- 0
}
}
if(printplots){
if(KAdults) nindiv <- census[,1]
else nindiv <- c(census[,1] + census[,6])
afreqs <- c(census[,4]/(nrow(counted)*2))
plotlim <- q0*5
if (plotlim > 1) plotlim <- 1
if(r == 1)if(y==1){ # set up empty plots
split.screen(c(2,1))
close.screen(n=c(1,2), all.screens=TRUE)
split.screen(c(2,1))
screen(1)
plot(nindiv ~ c(1:nyears), type="n", ylim=c(0, K + K*0.05), ylab="number of individuals", xlab = "year", main = "Population growth")
screen(2)
plot(afreqs ~ c(1:nyears), type="n", ylim=c(0, plotlim), ylab="frequency of rare allele", xlab = "year", main = "Allele frequency")
}
if(y == nyears){
screen(1)
plot(nindiv ~ c(1:nyears), type="l", ylab=" ", xlab=" ", ylim = c(0, K + K*0.05), xaxt="n", yaxt = "n", main = NULL)
screen(2)
plot(afreqs ~ c(1:nyears), type="l", ylab=" ", xlab=" ", ylim=c(0, plotlim), xaxt="n", yaxt = "n", main = NULL)
}
}
## INDIVIDUAL INFORMATION - from last year of simulation only (contains all individuals from all years, if trackall = TRUE)
if(y == nyears) {
totalpop <- rbind(population, cbind(nonbreeders, rep(0, nrow(nonbreeders))))
indivdata <- totalpop[,c(1,2,3,7,8,11,12,13,14,4)] # only keep relevant information (ncol=10)
}
} # End year loop
out[[1]] <- census
out[[2]] <- indivdata
out[[3]] <- reprostats
rm(census, indivdata, population, nonbreeders, reprostats)
if(is.wholenumber(r/nreplprint)) cat("Replicate #", r, "finished at", paste(Sys.time()), sep=" ", "\n")
flush.console()
out
} # End replicate function
#############
## RUN EACH REPLICATE:
result <- lapply (1:nrepl, run.one.repl)
# This is a list of sub-lists... one sub-list for each replicate, containing 1) census summary matrix and 2) indiv data from last year of the replicate.
result
} ## End aRetain function
######################################################################################
aRetain.summary <- function (adata, GeneCount, alpha=0.05, dropextinct = FALSE) {
## summarize output from aRetain (object called adata) across replicates, for an overall average for each year of the simulation.
## GeneCount should be as specified in aRetain.
## use alpha = 0.05 for 95% confidence limits
SE <- function(x) sqrt(var(x, na.rm=TRUE)/sum(!is.na(x)))
# pull out just the census information (drop indivdata), from adata[[r]][[1]] where r = each replicate
nrepl <- length(adata)
nyears <- dim(adata[[1]][[1]])[1]
censusdata1 <- array(dim = c(nyears, 9, nrepl))
for(r in 1:nrepl){
censusdata1[,,r] <- matrix(adata[[r]][[1]], ncol=9)
}
if (dropextinct){
# all data will be summarized only for replicates in which the population did not go extinct. P.extant (proportion of replicates in which population did not go extinct) and P.xLCL/P.xUCL are the only summaries that include replicates in which the population did go extinct.
censusdata <- censusdata1[,,(censusdata1[nyears,1,] > 0)]
if (is.matrix(censusdata)){
print(censusdata)
stop('Error: The population survived to the end of the period in only one replicate (shown above); this output is not averaged over multiple replicates. Multiple replicates are needed to obtain output from aRetain.summary.')
}
cat("Note: The population persisted to the end of the simulation (did not go extinct) in", dim(censusdata)[3], "of", nrepl, "replicates. Information is summarized for these replicates.\n")
}
else{
censusdata <- censusdata1 # ALL replicates will be included in all of the above summaries.
cat("Note: All replicates, including those in which the population went extinct, are included in the summary. This will affect the estimates of population size/composition, mean age, and probability of allele retention given here.\n")
}
nyears2 <- dim(censusdata)[1]
nrepl2 <- dim(censusdata)[3]
num <- censusdata[,1,] # number of adults present
if(GeneCount == "all"){
numnb <- censusdata[,6,] # number of nonbreeders present
numall <- matrix(nrow=nyears2, ncol=nrepl2)
for(i in 1:nyears2){
for(j in 1:nrepl2){
numall[i,j] <- numnb[i,j] + num[i,j]
}
}
num <- numall # all individuals were counted toward allele retention
}
else if(GeneCount != "adult") stop('GeneCount must equal "adult" or "all".')
alleles <- censusdata[,4,]
freqs <- matrix(nrow = nyears2, ncol = nrepl2)
for(i in 1:nyears2) {
for(j in 1:nrepl2) {
freqs[i,j] <- alleles[i,j]/(2*num[i,j])
}
}
MeanNAd <- apply(censusdata[,1,], 1, mean, na.rm = TRUE)
SEN <- apply(censusdata[,1,], 1, SE)
n <- apply(censusdata[,1,], 1, function(x) sum(!is.na(x)))
P.retain <- apply(censusdata[,4,]>0, 1, mean, na.rm = TRUE)
P.LCL <- Blcl(P.retain, n, alpha)
P.UCL <- Bucl(P.retain, n, alpha)
n1 <- apply(censusdata1[,1,], 1, function(x) sum(!is.na(x)))
P.extant <- apply(censusdata1[,1,]>0, 1, mean, na.rm = TRUE)
P.xLCL <- Blcl(P.extant, n1, alpha)
P.xUCL <- Bucl(P.extant, n1, alpha)
MeanBrF <- apply(censusdata[,2,], 1, mean, na.rm = TRUE)
SEBrF <- apply(censusdata[,2,], 1, SE)
MeanBrM <- apply(censusdata[,3,], 1, mean, na.rm = TRUE)
SEBrM <- apply(censusdata[,3,], 1, SE)
MeanNNonbr <- apply(censusdata[,6,], 1, mean, na.rm = TRUE)
MeanNFound <- apply(censusdata[,7,], 1, mean, na.rm = TRUE)
MeanNMigr <- apply(censusdata[,8,], 1, mean, na.rm = TRUE)
MeanAge <- apply(censusdata[,9,], 1, mean, na.rm = TRUE)
A.Freq <- apply(freqs, 1, mean, na.rm = TRUE)
A.SE <- apply(freqs, 1, SE)
cbind (MeanNAd, SEN, MeanNNonbr, MeanBrF, SEBrF, MeanBrM, SEBrM, MeanNFound, MeanNMigr, MeanAge, P.extant, P.xLCL, P.xUCL, P.retain, P.LCL, P.UCL, A.Freq, A.SE)
}
########################################################################
indiv.summary <- function(adata, genlength, alpha=0.05){
## Summarize individual data. Input:
# adata: object returned by aRetain
# genlength: mean age of simulated breeding individuals, after stabilizing from any founder age effects (as derived from census output).
# alpha: significance level for confidence limits
nrepl <- length(adata)
nyears <- dim(adata[[1]][[1]])[1]
indivOUT <- array(dim = c(4, 9, nrepl))
colnames(indivOUT) <- c("n", "pbreed", "pbreed.LCL", "pbreed.UCL", "YrsBred", "YrsBredBr", "lifespan", "effectivegen", "NMatings")
rownames(indivOUT) <- c("starters", "supplements", "locals", "migrants")
for(r in 1:nrepl) {
me <- matrix(adata[[r]][[2]], ncol=10) # individual data
# cols: ("ID", "dam", "sire", "origin", "birthyr", "NYrAlive", "NYrBred", "NMatings")
if(nrow(me) > 0){ # population did not go extinct
for (i in 1:4){ # for each origin
chosen <- matrix(me[me[,4]==i,], ncol=10) # indiv of origin i
chosen <- matrix(chosen[which(chosen[,9] < (nyears - genlength)),], ncol=10) # take out those added during the last generation (unequal chance of breeding)
indivOUT[i,1,r] <- nrow(chosen) # total number of origin i
bred <- matrix(chosen[chosen[,7] > 0,], ncol=10)
pbred <- round(nrow(bred) / nrow(chosen), digits=2) # proportion that bred at some point
indivOUT[i,2,r] <- pbred
indivOUT[i,3,r] <- Blcl(pbred, nrow(chosen), alpha)
indivOUT[i,4,r] <- Bucl(pbred, nrow(chosen), alpha)
indivOUT[i,5,r] <- round(mean(chosen[,7]), digits=2) # mean num breeding seasons each
indivOUT[i,6,r] <- round(mean(bred[,7]), digits=2) # mean num breeding seasons for those that DID breed
indivOUT[i,7,r] <- round(mean(chosen[,6]), digits=2) # mean lifespan
effgen <- (nrow(chosen)*nrow(bred) / nrow(chosen)) / (nyears/genlength) # average number of effective individuals per generation
indivOUT[i,8,r] <- effgen
if(i < 3) indivOUT[i,8,r] <- NA # founders not added in every generation so don't calculate this
indivOUT[i,9,r] <- round(mean(chosen[,9], digits=2)) # mean number of matings (across males and females)
}
}
else indivOUT[,,r] <- matrix(NA, nrow=4, ncol=9) # population had already gone extinct
}
### AVERAGE EACH CELL ACROSS REPLICATES
indivinfo <- matrix(nrow=4, ncol=9)
for(j in 1:nrow(indivOUT)){ for(c in 1:ncol(indivOUT)){
indivinfo[j, c] <- mean(as.numeric(indivOUT[j,c,]), na.rm=TRUE) # averaged across replicates (with any NA values, from replicates in which population went extinct, removed)
}}
colnames(indivinfo) <- c("n", "pbreed", "pbreed.LCL", "pbreed.UCL", "YrsBred", "YrsBredBr", "lifespan", "effectivegen", "NMatings")
rownames(indivinfo) <- c("starters", "supplement", "locals", "migrants")
indivinfo
}
########################################################################
# List of number of matings for each individual of the specified sex, over whole lifetime and all years
LRS.summary <- function(adata, sex){
nrepl <- length(adata)
nyears <- dim(adata[[1]][[1]])[1]
msOUT <- matrix(nrow=0, ncol=2)
colnames(msOUT) <- c("ID","NMatings")
for(r in 1:nrepl) {
me <- matrix(adata[[r]][[2]], ncol=10) # individual data
# cols: ("ID", "dam", "sire", "origin", "birthyr", "NYrAlive", "NYrBred", "NMatings", "Sex")
if(nrow(me) > 0){ # population did not go extinct
if(sex=="female") chosen <- subset(me, me[,10]==1)
if(sex=="male") chosen <- subset(me, me[,10]==2)
msOUT <- rbind(msOUT, cbind(chosen[,1], chosen[,9]))
}
}
msOUT
}
########################################################################
# Average reproductive success of each sex, by age, in final year of simulation
agerepro.summary <- function(adata, maxage, sex){
nrepl <- length(adata)
nalive <- nmatings <- noffspring <- matrix(NA, nrow=maxage+1, ncol=nrepl) # store the values to average across replicates
arOUT <- matrix(nrow=maxage+1, ncol=7)
arOUT[,1] <- c(0:maxage)
for(r in 1:nrepl){
me <- matrix(adata[[r]][[3]], ncol=5) # repro success data
# cols: ID, sex, age, num matings, num offspring (last two are just for final year of simulation)
if(nrow(me) > 0){
if(sex=="female") chosen <- subset(me, me[,2]==1)
if(sex=="male") chosen <- subset(me, me[,2]==2)
if(nrow(chosen) > 0) for(a in 1:(maxage+1)){
if((a-1) %in% chosen[,3]){
nalive[a,r] <- nrow(matrix(chosen[which(chosen[,3]==(a-1)),],ncol=ncol(chosen)))
nmatings[a,r] <- mean(chosen[which(chosen[,3]==(a-1)),4])
noffspring[a,r] <- mean(chosen[which(chosen[,3]==(a-1)),5])
}
}
}
}
for(a in 1:(maxage+1)){
arOUT[a,2] <- mean(nalive[a,], na.rm=TRUE)
arOUT[a,3] <- sd(nalive[a,], na.rm=TRUE)
arOUT[a,4] <- mean(nmatings[a,], na.rm=TRUE)
arOUT[a,5] <- sd(nmatings[a,], na.rm=TRUE)
arOUT[a,6] <- mean(noffspring[a,], na.rm=TRUE)
arOUT[a,7] <- sd(noffspring[a,], na.rm=TRUE)
}
colnames(arOUT) <- c('age','alive.mean','alive.sd','matings.mean','matings.sd','offspring.mean','offspring.sd')
arOUT
}
# Note the SDs shown are across, not within, replicates.
pedigree.summary <- function(adata){
## Get mean and variance of inbreeding coefficient for each year, across replicates
## Requires package pedigree (which requires Matrix, lattice, HaploSim, reshape)
requireNamespace(pedigree)
nrepl <- length(adata)
nyears <- dim(adata[[1]][[1]])[1]
outF <- array(dim = c(nyears, 2, nrepl))
for(r in 1:nrepl) {
me <- matrix(adata[[r]][[2]], ncol=10) # individual data (ID, dam, sire, origin, birthyr, nyrsalive, nyrsbred)
if(nrow(me) > 0){ # population exists
IDdamsire <- data.frame(me[,1], me[,2], me[,3])
colnames(IDdamsire) <- c("ID", "dam", "sire")
if(nrow(IDdamsire) > 0){
ord <- orderPed(IDdamsire) # Order to work with new requirements for calcInbreeding
IDdamsire <- IDdamsire[order(ord),]
Fvalues <- calcInbreeding(IDdamsire) # calculate F of each individual
}
else Fvalues <- numeric(0)
meF <- matrix(cbind(me, c(Fvalues)), ncol=ncol(me)+1) # attach F values to individual information
avgF <- rep(NA, nyears)
varF <- rep(NA, nyears)
for(y in 1:nyears) { # subset the individuals alive during that year
added <- subset(meF, meF[,8] <= y) # individuals added before or during year y
alive <- subset(added, (added[,8] + added[,6]) > y) # individuals that were still alive at end of year y
if(nrow(alive) > 0){
avgF[y] <- mean(alive[,9], na.rm=TRUE) # average Fs across individuals alive now
varF[y] <- var(alive[,9], na.rm=TRUE) # across-individual variance in F for each year
}
}
outF[,,r] <- cbind(avgF, varF)
}
else outF[,,r] <- matrix(NA, nrow=1, ncol=2) # population had already gone extinct
}
avgF2 <- rep(NA, nyears)
varF2 <- rep(NA, nyears)
indvarF2 <- rep(NA, nyears)
for(y in 1:nyears){
avgF2[y] <- mean(outF[y,1,], na.rm=TRUE) # average F across replicates
varF2[y] <- var(outF[y,1,], na.rm=TRUE) # variance of F across replicates
indvarF2[y] <- mean(outF[y,2,], na.rm=TRUE) # mean inter-individual variance of F (across replicates)
}
pedsum <- cbind(avgF2, varF2, indvarF2)
yrs <- 1:nrow(pedsum)
pedsum <- cbind(yrs, pedsum)
colnames(pedsum) <- c("year", "meanF", "varF", "indivVarF")
pedsum
}
########################################################################
| /scratch/gouwar.j/cran-all/cranData/AlleleRetain/R/AlleleRetain.R |
VIF.subset <- function(
data, VIF.max=20,
keep=NULL, silent=FALSE,
cor.plot=TRUE
)
{
R2 <- 1- 1/VIF.max
if (is.null(keep) == FALSE) {
cor1 <- stats::cor(data)
cor1[cor1 > R2] <- 100
exclude.vars <- c()
keep.vars <- c()
for (i in 1:length(keep)) {
exclude.vars <- c(exclude.vars,
which(cor1[, keep[i]] >= 100))
}
exclude.vars <- unique(exclude.vars)
exclude.vars <- names(data)[exclude.vars]
for (i in 1:ncol(data)) {
if ((names(data)[i] %in% exclude.vars) == FALSE) {
keep.vars <- c(keep.vars, i)
}
}
keep.vars <- unique(keep.vars)
keep.vars <- names(data)[keep.vars]
keep.vars <- unique(c(keep, keep.vars))
cat(paste("Step 1: Keeping these vars:", "\n"))
print(keep.vars)
data <- data[, which(names(data) %in% keep.vars)]
}
VIF.result <- BiodiversityR::ensemble.VIF.dataframe(data, VIF.max=VIF.max,
keep=keep, silent=silent)
if (cor.plot == TRUE) {
data <- data[, which(names(data) %in% VIF.result$vars.included)]
cp <- GGally::ggcorr(data, nbreaks=8, palette="RdGy",
label=TRUE, label_size=5, digits=3, label_color="white")
return(list(VIF=VIF.result, cp=cp))
}else{
return(VIF.result)
}
} | /scratch/gouwar.j/cran-all/cranData/AlleleShift/R/VIF.subset.R |
amova.rda <- function(
x, x.data
)
{
message("Calculation of AMOVA for a balanced design")
rda.terms <- attributes(x$terms)$term.labels
if (length(rda.terms) > 2) {stop("Calculations only shown for maximum 2 levels")}
if (length(rda.terms) == 1) {
message("No higher hierarchical level")
anova.result <- vegan::anova.cca(x, by="terms", permutations=0)
print(anova.result)
Df.all <- c(anova.result$Df, sum(anova.result$Df))
Variance.all <- c(anova.result$Variance, sum(anova.result$Variance))
table1 <- data.frame(cbind(Df.all, Variance.all))
names(table1) <- c("Df", "Variance")
rownames(table1) <- c(rda.terms, "within.Samples", "Total")
table1$SumSq <- table1$Variance * (table1[3, "Df"])
table1$MeanSq <- table1$SumSq / table1$Df
message(paste("\n", "Sums-of-Squares are calculated by multiplying variance with (number of individuals - 1)"))
print(table1)
message("Mean population size:")
n1 <- mean(table(x.data[, rda.terms[1]]))
print(n1)
table2 <- table1[, c(1:2)]
names(table2) <- c("Covariance", "Percent")
table2[2, 1] <- table1[2, "MeanSq"]
table2[1, 1] <- (table1[1, "MeanSq"] - table2[2, 1]) / n1
table2[3, 1] <- sum(table2[1:2, 1])
table2[1, 2] <- 100* table2[1, 1] / table2[3, 1]
table2[2, 2] <- 100 * table2[2, 1] / table2[3, 1]
table2[3, 2] <- 100
print(table2)
}
if (length(rda.terms) == 2) {
message("Population level of '", rda.terms[2], "' nested within higher level of '", rda.terms[1], "'")
anova.result <- vegan::anova.cca(x, by="terms", permutations=0)
print(anova.result)
Df.all <- c(anova.result$Df, sum(anova.result$Df))
Variance.all <- c(anova.result$Variance, sum(anova.result$Variance))
table1 <- data.frame(cbind(Df.all, Variance.all))
names(table1) <- c("Df", "Variance")
rownames(table1) <- c(rda.terms, "within.Samples", "Total")
table1$SumSq <- table1$Variance * (table1[4, "Df"])
table1$MeanSq <- table1$SumSq / table1$Df
message(paste("\n", "Sums-of-Squares are calculated by multiplying variance with (number of individuals - 1)"))
message(paste("The (number of individuals - 1) is also the Df for the total Sum-of-Squares."))
print(table1)
message("Mean population size:")
n1 <- mean(table(x.data[, rda.terms[2]]))
print(n1)
message("Mean sizes of higher level:")
n2 <- mean(table(x.data[, rda.terms[1]]))
print(n2)
table2 <- table1[, c(1:2)]
names(table2) <- c("Covariance", "Percent")
table2[3, 1] <- table1[3, "MeanSq"]
table2[2, 1] <- (table1[2, "MeanSq"] - table2[3, 1]) / n1
table2[1, 1] <- (table1[1, "MeanSq"] - table2[3, 1] - n1*table2[2, 1]) / n2
table2[4, 1] <- sum(table2[1:3, 1])
table2[1, 2] <- 100* table2[1, 1] / table2[4, 1]
table2[2, 2] <- 100 * table2[2, 1] / table2[4, 1]
table2[3, 2] <- 100 * table2[3, 1] / table2[4, 1]
table2[4, 2] <- 100
message(paste("\n", "Calculation of covariance"))
print(table2)
PHI <- numeric(length=3)
names(PHI) <- c("Samples-Total",
"Samples-Pop",
"Pop-Total")
PHI[1] <- (table2[1, 1] + table2[2, 1]) / table2[4, 1]
PHI[2] <- table2[2, 1] / (table2[2, 1] + table2[3, 1])
PHI[3] <- table2[1, 1] / (table2[4, 1])
message(paste("\n", "Phi statistics"))
print(PHI)
}
} | /scratch/gouwar.j/cran-all/cranData/AlleleShift/R/amova.rda.R |
count.model <- function(
genpop.data, env.data, permutations=99,
ordistep=FALSE, cca.model=FALSE
)
{
gen.comm <- data.frame(genpop.data@tab)
gen.freq <- data.frame(adegenet::makefreq(genpop.data))
row.ratios <- rowSums(gen.comm) / max(rowSums(gen.comm))
gen.comm.b <- gen.comm
for (i in 1:nrow(gen.comm)) {gen.comm.b[i,] <- gen.comm[i, ] / row.ratios[i]}
rda.baseline <- vegan::rda(gen.comm.b ~ ., data=env.data)
print(summary(rda.baseline))
if (permutations > 0){
print(vegan::anova.cca(rda.baseline, permutations=permutations))
print(vegan::anova.cca(rda.baseline, by="terms", permutations=permutations))
print(vegan::anova.cca(rda.baseline, by="margin", permutations=permutations))
}
if (ordistep == TRUE) {
rda.null <- vegan::rda(gen.comm.b ~ 1, data=env.data)
rda.reduced <- vegan::ordistep(rda.null,
scope=stats::formula(rda.baseline),
direction = "both")
cat(paste("Reduced model:", "\n"))
print(vegan::anova.cca(rda.reduced, permutations=permutations))
print(vegan::anova.cca(rda.reduced, by="terms", permutations=permutations))
print(vegan::anova.cca(rda.reduced, by="margin", permutations=permutations))
# rda.baseline <- rda.reduced
}
if (cca.model == TRUE) {
c.index <- seq(from=1, to=(ncol(gen.comm)-1), by=2)
gen.freq.c <- gen.freq[, c.index]
cca.baseline <- vegan::cca(gen.freq.c ~ ., data=env.data)
print(summary(cca.baseline))
if (ordistep == TRUE) {
cca.null <- vegan::cca(gen.freq.c ~ 1, data=env.data)
cca.reduced <- ordistep(cca.null,
scope=stats::formula(cca.baseline),
direction = "both")
cat(paste("Reduced model (CCA):", "\n"))
print(vegan::anova.cca(cca.reduced, permutations=permutations))
print(vegan::anova.cca(cca.reduced, by="terms", permutations=permutations))
print(vegan::anova.cca(cca.reduced, by="margin", permutations=permutations))
}
}else{
cca.baseline <- NULL
}
result <- list(rda.model=rda.baseline,
row.ratios=row.ratios,
gen.comm=gen.comm,
gen.freq=gen.freq,
cca.model=cca.baseline)
return(result)
}
count.pred <- function(
count.modeled, env.data
)
{
predict.rda2 <- utils::getS3method("predict", "rda")
comm.pred <- predict.rda2(count.modeled$rda.model, newdata=env.data)
comm.pred2 <- comm.pred
row.ratios <- count.modeled$row.ratios
for (i in 1:nrow(comm.pred2)) {comm.pred2[i, ] <- comm.pred[i, ] * row.ratios[i]}
if (is.null(count.modeled$cca.model) == FALSE) {
predict.cca2 <- utils::getS3method("predict", "cca")
freq.pred2 <- predict.cca2(count.modeled$cca.model, newdata=env.data)
}
actual <- count.modeled$gen.comm
np <- nrow(actual)
actual$N <- rowSums(actual) / ncol(actual)
gen.freq <- count.modeled$gen.freq
c.index <- seq(from=1, to=(ncol(actual)-1), by=2)
for (c in c(1:length(c.index))){
allc.res <- data.frame(Pop=rownames(actual),
Pop.label=as.character(c(1:np)),
Pop.index=as.numeric(c(1:np)),
N=2*actual$N, # diploid
Allele=rep(names(actual)[c.index[c]], np),
Allele.freq=gen.freq[, c.index[c]],
A=actual[, c.index[c]],
B=actual[, c.index[c]+1],
Ap=comm.pred2[, c.index[c]],
Bp=comm.pred2[, c.index[c]+1])
if (is.null(count.modeled$cca.model) == FALSE) {
c1 <- (c+1)/2
allc.res$Freq.Blumstein <- freq.pred2[, c1]
}
if (c == 1) {
all.res <- allc.res
}else{
all.res <- rbind(all.res, allc.res)
}
}
all.res$N.e1 <- all.res$Ap + all.res$Bp
all.res$Freq.e1 <- (all.res$Ap) / all.res$N.e1
return(all.res)
}
freq.model <- function(
count.predicted
)
{
mgcv.model <- mgcv::gam(formula= cbind(A, B) ~ s(Freq.e1),
data=count.predicted,
family=stats::binomial(link="logit"))
print(summary(mgcv.model))
return(mgcv.model)
}
freq.pred <- function(
freq.modeled, count.predicted
)
{
predsx <- mgcv::predict.gam(freq.modeled,
newdata=count.predicted,
type="response",
se.fit=TRUE)
np <- length(unique(count.predicted$Pop))
count.predicted$Freq.e2 <- predsx$fit
count.predicted$LCL <- predsx$fit - stats::qt(0.95, df=(np-1))*predsx$se.fit
count.predicted$UCL <- predsx$fit + stats::qt(0.95, df=(np-1))*predsx$se.fit
count.predicted[count.predicted$LCL < 0.0, "LCL"] <- 0.0
count.predicted[count.predicted$UCL > 1.0, "UCL"] <- 1.0
count.predicted$increasing <- count.predicted$Freq.e2 > count.predicted$Allele.freq
return(count.predicted)
}
| /scratch/gouwar.j/cran-all/cranData/AlleleShift/R/count.model.R |
environmental.novel <- function(
baseline.env.data, future.env.data
)
{
np <- nrow(baseline.env.data)
out <- data.frame(array(dim=c(np, 9)))
names(out) <- c("Pop", "Var", "Min", "Mean", "Max", "SD",
"Future.val", "Novel", "Novel.stat")
out$Novel <- FALSE
out$Novel.stat <- Inf
for (i in c(1:np)) {
out[i, 1] <- rownames(baseline.env.data)[i]
for (j in c(1:ncol(baseline.env.data))) {
var.f <- names(baseline.env.data)[j]
base.data <- baseline.env.data[, which(names(baseline.env.data) == var.f)]
base.min <- min(base.data)
base.mean <- mean(base.data)
base.max <- max(base.data)
base.SD <- stats::sd(base.data)
fut.val <- future.env.data[i, which(names(future.env.data) == var.f)]
if (fut.val < base.min) {
out[i, "Novel"] <- TRUE
stat1 <- stats::pnorm(fut.val, mean=base.mean, sd=base.SD)
if (stat1 < out[i, "Novel.stat"]) {
out[i, "Var"] <- var.f
out[i, "Min"] <- base.min
out[i, "Mean"] <- base.mean
out[i, "Max"] <- base.max
out[i, "SD"] <- base.SD
out[i, "Future.val"] <- fut.val
out[i, "Novel.stat"] <- stat1
}
}
if (fut.val > base.max) {
out[i, "Novel"] <- TRUE
stat1 <- 1 - stats::pnorm(fut.val, mean=base.mean, sd=base.SD)
if (stat1 < out[i, "Novel.stat"]) {
out[i, "Var"] <- var.f
out[i, "Min"] <- base.min
out[i, "Mean"] <- base.mean
out[i, "Max"] <- base.max
out[i, "SD"] <- base.SD
out[i, "Future.val"] <- fut.val
out[i, "Novel.stat"] <- stat1
}
}
}
}
return(out)
}
| /scratch/gouwar.j/cran-all/cranData/AlleleShift/R/environmental.novel.R |
freq.ggplot <- function(
freq.predicted, plot.best=TRUE, threshold=0.50,
colour.Pop=TRUE, manual.colour.values=NULL,
xlim=c(0.0, 1.0), ylim=c(0.0, 1.0)
)
{
np <- length(unique(freq.predicted$Pop))
manual.colour <- data.frame(values=manual.colour.values)
lm.Rsq <- data.frame(Pop=freq.predicted[1:np, "Pop"],
Pop.label=as.character(c(1:np)),
N=freq.predicted[1:np, "N"]/2,
GAM.rsq=numeric(np))
for (p1 in 1:np) {
Pop.focal <- freq.predicted[p1, "Pop"]
long.p <- freq.predicted[freq.predicted$Pop == Pop.focal, ]
m <- stats::lm(Freq.e2 ~ Allele.freq, data=long.p)
lm.Rsq[p1, "GAM.rsq"] <- round(summary(m)$r.squared, 2)
}
message("Populations ordered by R2")
print(lm.Rsq[order(lm.Rsq$GAM.rsq, decreasing=TRUE), ])
lm.Rsq$Pop.legend <- paste0(lm.Rsq$Pop, " (P",
lm.Rsq$Pop.label, ") : ",
format(lm.Rsq$GAM.rsq, digits=2))
freq.predicted <- dplyr::left_join(freq.predicted,
lm.Rsq[, c("Pop.label", "Pop.legend")],
by= "Pop.label")
if (plot.best == TRUE) {
good.pops <- lm.Rsq[lm.Rsq$GAM >= threshold, "Pop"]
}else{
good.pops <- lm.Rsq[lm.Rsq$GAM <= threshold, "Pop"]
}
message("selected populations")
print(good.pops)
sqrt.data <- data.frame(x=seq(from=0, to=1, by=0.001))
sqrt.data$y <- sqrt.data$x
sqrt.data$y1 <- sqrt.data$x+0.05
sqrt.data$y2 <- sqrt.data$x-0.05
BioR.theme <- ggplot2::theme(
panel.background = ggplot2::element_blank(),
panel.border = ggplot2::element_blank(),
panel.grid = ggplot2::element_blank(),
axis.line = ggplot2::element_line("gray25"),
text = ggplot2::element_text(size = 12),
axis.text = ggplot2::element_text(size = 10, colour = "gray25"),
axis.title = ggplot2::element_text(size = 10, colour = "gray25"),
legend.title = ggplot2::element_text(size = 10),
legend.text = ggplot2::element_text(size = 10),
legend.key = ggplot2::element_blank())
if (colour.Pop == TRUE) {
ggplotx <- ggplot2::ggplot() +
ggplot2::scale_x_sqrt(limits=xlim) +
ggplot2::scale_y_continuous(limits=ylim,
sec.axis = ggplot2::dup_axis(labels=NULL, name=NULL)) +
ggplot2::geom_line(data=sqrt.data,
ggplot2::aes(x=sqrt.data$x, y=sqrt.data$y),
color = "darkolivegreen4", linetype = 1, size=2) +
ggplot2::geom_line(data=sqrt.data,
ggplot2::aes(x=sqrt.data$x, y=sqrt.data$y1),
color = "darkolivegreen4", linetype = 2, size=1) +
ggplot2::geom_line(data=sqrt.data,
ggplot2::aes(x=sqrt.data$x, y=sqrt.data$y2),
color = "darkolivegreen4", linetype = 2, size=1) +
ggplot2::geom_hline(yintercept = c(0.1), color = "black", linetype = 2) +
ggplot2::geom_vline(xintercept = c(0.000000000000001), color = "black", linetype = 2) +
ggplot2::geom_vline(xintercept = c(0.1), color = "black", linetype = 2) +
ggplot2::geom_point(data=subset(freq.predicted, freq.predicted$Pop %in% good.pops),
ggplot2::aes(x=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Allele.freq,
y=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Freq.e2,
colour=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Pop.legend),
size=4, alpha=0.8) +
ggplot2::geom_errorbar(data=subset(freq.predicted, freq.predicted$Pop %in% good.pops),
ggplot2::aes(x=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Allele.freq,
ymin=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$LCL,
ymax=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$UCL,
colour=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Pop.legend),
width=0.02, show.legend=FALSE) +
ggplot2::geom_text(data=subset(freq.predicted, freq.predicted$Pop %in% good.pops),
ggplot2::aes(x=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Allele.freq,
y=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Freq.e2,
label=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Pop.label),
colour="black", size=2.5, alpha=1.0, show.legend=FALSE) +
ggplot2::xlab("Actual allele frequency") +
ggplot2::ylab("Predicted allele frequency") +
ggplot2::labs(colour=expression("Population : R"^2)) +
BioR.theme
}else{
ggplotx <- ggplot2::ggplot() +
ggplot2::scale_x_sqrt(limits=xlim) +
ggplot2::scale_y_continuous(limits=ylim,
sec.axis = ggplot2::dup_axis(labels=NULL, name=NULL)) +
ggplot2::geom_line(data=sqrt.data,
ggplot2::aes(x=sqrt.data$x, y=sqrt.data$y),
color = "darkolivegreen4", linetype = 1, size=2) +
ggplot2::geom_line(data=sqrt.data,
ggplot2::aes(x=sqrt.data$x, y=sqrt.data$y1),
color = "darkolivegreen4", linetype = 2, size=1) +
ggplot2::geom_line(data=sqrt.data,
ggplot2::aes(x=sqrt.data$x, y=sqrt.data$y2),
color = "darkolivegreen4", linetype = 2, size=1) +
ggplot2::geom_hline(yintercept = c(0.1), color = "black", linetype = 2) +
ggplot2::geom_vline(xintercept = c(0.000000000000001), color = "black", linetype = 2) +
ggplot2::geom_vline(xintercept = c(0.1), color = "black", linetype = 2) +
ggplot2::geom_point(data=subset(freq.predicted, freq.predicted$Pop %in% good.pops),
ggplot2::aes(x=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Allele.freq,
y=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Freq.e2,
colour=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Allele),
size=4, alpha=0.8) +
ggplot2::geom_errorbar(data=subset(freq.predicted, freq.predicted$Pop %in% good.pops),
ggplot2::aes(x=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Allele.freq,
ymin=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$LCL,
ymax=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$UCL,
colour=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Allele),
width=0.02, show.legend=FALSE) +
ggplot2::geom_text(data=subset(freq.predicted, freq.predicted$Pop %in% good.pops),
ggplot2::aes(x=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Allele.freq,
y=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Freq.e2,
label=subset(freq.predicted, freq.predicted$Pop %in% good.pops)$Pop.label),
colour="black", size=2.5, alpha=1.0, show.legend=FALSE) +
ggplot2::xlab("Actual allele frequency") +
ggplot2::ylab("Predicted allele frequency") +
ggplot2::labs(colour=expression("Population : R"^2)) +
BioR.theme
}
if(is.null(manual.colour.values) == FALSE) {
ggplotx <- ggplotx +
ggplot2::scale_colour_manual(values=as.character(manual.colour$values))
}
return(ggplotx)
}
| /scratch/gouwar.j/cran-all/cranData/AlleleShift/R/freq.ggplot.R |
population.shift <- function(
baseline.env.data, future.env.data, option=c("PCA", "RDA"),
vector.multiply=1
)
{
message("Checking data sets with BiodiversityR::check.datasets")
BiodiversityR::check.datasets(baseline.env.data, future.env.data)
pca.input <- rbind(baseline.env.data, future.env.data)
np <- nrow(baseline.env.data)
pca.env <- data.frame(climate=factor(c(rep("baseline", np),
rep("future", np))))
if (option == "PCA") {
message("Fitting PCA with vegan::rda and no explanatory variables")
pca.result <- vegan::rda(pca.input, scale=TRUE)
summary(pca.result)
axis.long1 <- BiodiversityR::axis.long(pca.result, choices=c(1, 2))
plot1 <- vegan::ordiplot(pca.result)
}
if (option == "RDA") {
# scaling important as variables now used as response, not important with those variables as explanatory
message("Fitting RDA with vegan::rda and time period (baseline / future) as explanatory variable")
rda.result <- vegan::rda(pca.input ~ climate, data=pca.env, scale=TRUE)
summary(rda.result)
axis.long1 <- BiodiversityR::axis.long(rda.result, choices=c(1, 2))
plot1 <- vegan::ordiplot(rda.result)
}
species.long1 <- BiodiversityR::species.long(plot1)
pca.env <- cbind(pca.input, pca.env)
sites.long1 <- BiodiversityR::sites.long(plot1, env.data=pca.env)
segment.long1 <- sites.long1[sites.long1$climate == "baseline", c("labels", "axis1", "axis2")]
segment.long2 <- sites.long1[sites.long1$climate == "future", c("labels", "axis1", "axis2")]
segment.long3 <- data.frame(cbind(segment.long1, segment.long2))
BioR.theme <- ggplot2::theme(
panel.background = ggplot2::element_blank(),
panel.border = ggplot2::element_blank(),
panel.grid = ggplot2::element_blank(),
axis.line = ggplot2::element_line("gray25"),
text = ggplot2::element_text(size = 12),
axis.text = ggplot2::element_text(size = 10, colour = "gray25"),
axis.title = ggplot2::element_text(size = 10, colour = "gray25"),
legend.title = ggplot2::element_text(size = 10),
legend.text = ggplot2::element_text(size = 10),
legend.key = ggplot2::element_blank())
plotggx <- ggplot2::ggplot() +
ggplot2::geom_vline(xintercept = c(0), color = "grey70", linetype = 2) +
ggplot2::geom_hline(yintercept = c(0), color = "grey70", linetype = 2) +
ggplot2::xlab(axis.long1[1, "label"]) +
ggplot2::ylab(axis.long1[2, "label"]) +
ggplot2::scale_x_continuous(sec.axis = ggplot2::dup_axis(labels=NULL, name=NULL)) +
ggplot2::scale_y_continuous(sec.axis = ggplot2::dup_axis(labels=NULL, name=NULL)) +
ggforce::geom_mark_ellipse(data=sites.long1,
ggplot2::aes(x=sites.long1$axis1, y=sites.long1$axis2, colour=sites.long1$climate),
fill=ggplot2::alpha("grey50", 0.3), expand=0, size=0.2, show.legend=FALSE) +
ggplot2::geom_point(data=sites.long1,
ggplot2::aes(x=sites.long1$axis1, y=sites.long1$axis2, colour=sites.long1$climate, shape=sites.long1$climate),
alpha=0.7, size=5) +
ggplot2::geom_segment(data=species.long1,
ggplot2::aes(x=0, y=0, xend=species.long1$axis1*vector.multiply, yend=species.long1$axis2*vector.multiply),
colour="black", size=0.7, arrow=ggplot2::arrow()) +
ggplot2::geom_segment(data=segment.long3,
ggplot2::aes(x=segment.long3$axis1, y=segment.long3$axis2, xend=segment.long3$axis1.1, yend=segment.long3$axis2.1),
colour="darkolivegreen4", size=0.7, arrow=ggplot2::arrow()) +
ggplot2::geom_label(data=species.long1,
ggplot2::aes(x=species.long1$axis1*vector.multiply, y=species.long1$axis2*vector.multiply, label=species.long1$labels),
colour="black", fill="grey90", alpha=0.4, fontface="bold", show.legend=FALSE) +
ggplot2::geom_label(data=subset(sites.long1, sites.long1$climate=="baseline"),
ggplot2::aes(x=subset(sites.long1, sites.long1$climate=="baseline")$axis1,
y=subset(sites.long1, sites.long1$climate=="baseline")$axis2,
label=subset(sites.long1, sites.long1$climate=="baseline")$labels,
colour=subset(sites.long1, sites.long1$climate=="baseline")$climate),
alpha=0.7, size=3, nudge_y=0.1, show.legend=FALSE) +
BioR.theme +
ggplot2::scale_colour_manual(values=rev(ggsci::pal_npg()(2))) +
ggplot2::labs(shape="Climate", colour="Climate", fill="Climate") +
ggplot2::coord_fixed(ratio=1)
return(plotggx)
}
| /scratch/gouwar.j/cran-all/cranData/AlleleShift/R/population.shift.R |
shift.dot.ggplot <- function(
freq.future,
mean.change=FALSE, change.FUN=stats::median,
baseline.colour="black",
future.colour="dodgerblue3",
manual.colour.values=c("firebrick3", "chartreuse4")
)
{
np <- length(unique(freq.future$Pop))
if (mean.change == TRUE) {
freq.columns <- cbind(freq.future$Allele.freq,
freq.future$Freq.e2,
freq.future$LCL,
freq.future$UCL)
freq.means <- stats::aggregate(freq.columns ~ freq.future$Pop, FUN=change.FUN)
names(freq.means)[1] <- "Pop"
freq.means <- dplyr::left_join(freq.future[, c("Pop", "Allele.freq")],
freq.means,
by="Pop")
# print(freq.means)
freq.future$Allele.freq <- freq.means$V1
freq.future$Freq.e2 <- freq.means$V2
freq.future$LCL <- freq.means$V3
freq.future$UCL <- freq.means$V4
freq.future <- freq.future[1:np, ]
freq.future$increasing <- freq.future$Freq.e2 > freq.future$Allele.freq
freq.future$Allele <- factor(rep("Alleles aggregated", np))
}
freq.future$increasing <- factor(freq.future$increasing,
levels=c("TRUE", "FALSE"))
ggdotx <- ggplot2::ggplot(data=freq.future) +
ggplot2::geom_errorbar(ggplot2::aes(x=freq.future$Pop, ymin=freq.future$LCL, ymax=freq.future$UCL),
colour="grey30", width=0.9, show.legend=FALSE) +
ggplot2::geom_segment(ggplot2::aes(x=freq.future$Pop, y=freq.future$Allele.freq, xend=freq.future$Pop, yend=freq.future$Freq.e2, colour=freq.future$increasing),
size=1.2) +
ggplot2::geom_point(ggplot2::aes(x=freq.future$Pop, y=freq.future$Allele.freq),
colour=baseline.colour, size=6, alpha=0.7) +
ggplot2::geom_point(ggplot2::aes(x=freq.future$Pop, y=freq.future$Freq.e2),
colour=future.colour, size=6, alpha=0.7) +
ggplot2::coord_flip() +
ggplot2::xlab(ggplot2::element_blank()) +
ggplot2::ylab("Allele frequencies") +
ggplot2::theme(panel.grid.minor = ggplot2::element_blank()) +
ggplot2::labs(colour="Predicted change in allele frequencies") +
ggplot2::scale_colour_manual(values=manual.colour.values,
breaks=c("FALSE", "TRUE"),
labels=c("decreasing", "increasing")) +
ggplot2::theme(axis.text.x=ggplot2::element_text(angle=90, vjust=0.5, size=10)) +
ggplot2::theme(legend.position="top")
if (length(unique(freq.future$Allele)) > 1 ){
ggdotx <- ggdotx +
ggplot2::facet_grid( ~ Allele, scales="free")
}
return(ggdotx)
}
| /scratch/gouwar.j/cran-all/cranData/AlleleShift/R/shift.dot.ggplot.R |
moon.waxer <- function(
freq.in = NULL, sort.index = "Pop.index",
mean.change=FALSE, change.FUN=stats::median,
freq.focus="Allele.freq",
ypos=0, right=TRUE
)
{
np <- length(unique(freq.in$Allele))
if (mean.change == TRUE) {
freq.columns <- cbind(freq.in$Allele.freq,
freq.in$Freq.e2,
freq.in$LCL,
freq.in$UCL)
freq.means <- stats::aggregate(freq.columns ~ freq.in$Pop, FUN=change.FUN)
names(freq.means)[1] <- "Pop"
freq.means <- dplyr::left_join(freq.in[, c("Pop", "Allele.freq")],
freq.means,
by="Pop")
freq.in$Allele.freq <- freq.means$V1
freq.in$Freq.e2 <- freq.means$V2
freq.in$LCL <- freq.means$V3
freq.in$UCL <- freq.means$V4
freq.in <- freq.in[1:np, ]
freq.in$increasing <- freq.in$Freq.e2 > freq.in$Allele.freq
freq.in$Allele <- factor(rep("Alleles aggregated", np))
}
for (i in 1:nrow(freq.in)) {
rowsi <- data.frame(Pop=rep(freq.in[i, "Pop"], 2),
sort.index=rep(as.numeric(freq.in[i, sort.index]), 2),
Allele=rep(freq.in[i, "Allele"], 2),
increasing=rep(freq.in[i, "increasing"], 2),
ypos=rep(ypos, 2),
state=c("A", "B"),
ratio=c(freq.in[i, freq.focus],
(1-freq.in[i, freq.focus])),
right=c(TRUE, FALSE),
colour=c("baseA", "baseB"))
if (i == 1) {
result <- rowsi
}else{
result <- rbind(result, rowsi)
}
}
result$change.colour <- as.character(result$colour)
for (i in 1:nrow(result)) {
if (result[i, "state"] == "A") {
if (result[i, "increasing"] == TRUE) {
result[i, "change.colour"] <- c("change A increase")
}
if (result[i, "increasing"] == FALSE) {
result[i, "change.colour"] <- c("change A decrease")
}
}
}
result$colour <- factor(result$colour,
levels=c("baseA",
"baseB",
"change A increase",
"change A decrease"))
result$change.colour <- factor(result$change.colour,
levels=c("baseA",
"baseB",
"change A increase",
"change A decrease"))
return(result)
}
shift.moon.ggplot <- function(
baseline.moon, future.moon,
manual.colour.values=c("white", "grey", "firebrick3", "chartreuse4"),
manual.colour.codes=c("A baseline ", "B", "A decreasing", "A increasing")
)
{
np <- length(unique(baseline.moon$Pop))
ggmoonx <- ggplot2::ggplot() +
ggplot2::scale_x_continuous(limits=c(0.5, np+0.5),
breaks=seq(from=1, to=np, by=1),
labels=levels(baseline.moon$Pop)) +
ggplot2::scale_y_continuous(limits=c(-0.5, 1.5)) +
gggibbous::geom_moon(data=baseline.moon,
ggplot2::aes(x=baseline.moon$sort.index, y=baseline.moon$ypos, ratio=baseline.moon$ratio, right=baseline.moon$right, fill=baseline.moon$colour),
size=10, stroke=0.03, col="black") +
gggibbous::geom_moon(data=future.moon,
ggplot2::aes(x=future.moon$sort.index, y=future.moon$ypos, ratio=future.moon$ratio, right=future.moon$right,
fill=future.moon$change.colour),
size=10, stroke=0.03, col="black") +
ggplot2::geom_point(data=subset(future.moon, future.moon$state == "A"),
ggplot2::aes(x=subset(future.moon, future.moon$state == "A")$sort.index,
y=subset(future.moon, future.moon$state == "A")$ypos,
fill=subset(future.moon, future.moon$state == "A")$change.colour),
size=3, shape=21, stroke=0.03, show.legend=FALSE) +
#ggplot2::geom_point(data=subset(future.moon, future.moon$increasing==TRUE),
# ggplot2::aes(x=subset(future.moon, future.moon$increasing==TRUE)$sort.index, y=subset(future.moon, future.moon$increasing==TRUE)$ypos),
# size=3, shape=21, fill=manual.colour.values[4], stroke=0.03, show.legend=FALSE) +
#ggplot2::geom_point(data=subset(future.moon, future.moon$increasing==FALSE),
# ggplot2::aes(x=subset(future.moon, future.moon$increasing==FALSE)$sort.index, y=subset(future.moon, future.moon$increasing==FALSE)$ypos),
# size=3, shape=21, fill=manual.colour.values[3], stroke=0.03, show.legend=FALSE) +
ggplot2::coord_flip() +
ggplot2::xlab(ggplot2::element_blank()) +
ggplot2::ylab(ggplot2::element_blank()) +
ggplot2::labs(fill=" ") +
ggplot2::scale_fill_manual(values=manual.colour.values,
breaks=c("baseA", "baseB", "change A decrease", "change A increase"),
labels=c("A baseline ", "B", "A decreasing", "A increasing")) +
ggplot2::theme(panel.grid = ggplot2::element_blank()) +
ggplot2::theme(axis.text.x= ggplot2::element_blank()) +
ggplot2::theme(axis.ticks.x = ggplot2::element_blank())
if (length(unique(baseline.moon$Allele)) > 1 ){
ggmoonx <- ggmoonx +
ggplot2::theme(legend.position="top") +
ggplot2::facet_grid( ~ Allele, scales="free")
}
return(ggmoonx)
}
| /scratch/gouwar.j/cran-all/cranData/AlleleShift/R/shift.moon.ggplot.R |
pie.baker <- function(
freq.in = NULL, sort.index = "Pop.index",
mean.change=FALSE, change.FUN=stats::median,
freq.focus="Allele.freq", ypos=0,
r0=0.1, r=0.5, focus=0.2
)
{
np <- length(unique(freq.in$Pop))
if (mean.change == TRUE) {
freq.columns <- cbind(freq.in$Allele.freq,
freq.in$Freq.e2,
freq.in$LCL,
freq.in$UCL)
freq.means <- stats::aggregate(freq.columns ~ freq.in$Pop, FUN=change.FUN)
names(freq.means)[1] <- "Pop"
freq.means <- dplyr::left_join(freq.in[, c("Pop", "Allele.freq")],
freq.means,
by="Pop")
freq.in$Allele.freq <- freq.means$V1
freq.in$Freq.e2 <- freq.means$V2
freq.in$LCL <- freq.means$V3
freq.in$UCL <- freq.means$V4
freq.in <- freq.in[1:np, ]
freq.in$increasing <- freq.in$Freq.e2 > freq.in$Allele.freq
freq.in$Allele <- factor(rep("Alleles aggregated", np))
}
for (i in 1:nrow(freq.in)) {
rowsi <- data.frame(Pop=rep(freq.in[i, "Pop"], 2),
sort.index=rep(as.numeric(freq.in[i, sort.index]), 2),
Allele=rep(freq.in[i, "Allele"], 2),
increasing=rep(freq.in[i, "increasing"], 2),
ypos=rep(ypos, 2),
state=c("A", "B"),
amount=c(freq.in[i, freq.focus],
(1-freq.in[i, freq.focus])),
start=c(0, (freq.in[i, freq.focus]*2*pi)),
end=c((freq.in[i, freq.focus]*2*pi), 2*pi),
r0=rep(r0, 2),
r=rep(r, 2),
focus=c(focus, 0),
colour=c("baseA", "baseB"))
if (i == 1) {
result <- rowsi
}else{
result <- data.frame(rbind(result, rowsi))
}
}
result$change.colour <- as.character(result$colour)
for (i in 1:nrow(result)) {
if (result[i, "state"] == "A") {
if (result[i, "increasing"] == TRUE) {
result[i, "change.colour"] <- c("change A increase")
}
if (result[i, "increasing"] == FALSE) {
result[i, "change.colour"] <- c("change A decrease")
}
}
}
result$colour <- factor(result$colour,
levels=c("baseA",
"baseB",
"change A increase",
"change A decrease"))
result$change.colour <- factor(result$change.colour,
levels=c("baseA",
"baseB",
"change A increase",
"change A decrease"))
return(result)
}
shift.pie.ggplot <- function(
baseline.pie, future.pie,
manual.colour.values=c("black", "grey", "firebrick3", "chartreuse4"),
manual.colour.codes=c("A baseline ", "B", "A decreasing", "A increasing")
)
{
np <- length(unique(baseline.pie$Pop))
ggpiex <- ggplot2::ggplot() +
ggplot2::scale_x_continuous(limits=c(0.5, np+0.5),
breaks=seq(from=1, to=np, by=1),
labels=levels(baseline.pie$Pop)) +
ggforce::geom_arc_bar(data=baseline.pie,
ggplot2::aes(x0=baseline.pie$sort.index, y0=baseline.pie$ypos, r0=baseline.pie$r0, r=0.4,
start=baseline.pie$start, end=baseline.pie$end, fill=baseline.pie$colour),
size=0.04, alpha=1, colour="snow1") +
ggforce::geom_arc_bar(data=future.pie,
ggplot2::aes(x0=future.pie$sort.index, y0=future.pie$ypos, r0=future.pie$r0, r=0.4,
start=future.pie$start, end=future.pie$end, fill=future.pie$change.colour),
size=0.04, alpha=1, colour="snow1") +
ggplot2::geom_point(data=subset(future.pie, future.pie$increasing==TRUE),
ggplot2::aes(x=subset(future.pie, future.pie$increasing==TRUE)$sort.index, y=subset(future.pie, future.pie$increasing==TRUE)$ypos),
size=5, shape=21, fill=manual.colour.values[4], stroke=0.03, show.legend=FALSE) +
ggplot2::geom_point(data=subset(future.pie, future.pie$increasing==FALSE),
ggplot2::aes(x=subset(future.pie, future.pie$increasing==FALSE)$sort.index, y=subset(future.pie, future.pie$increasing==FALSE)$ypos),
size=5, shape=21, fill=manual.colour.values[3], stroke=0.03, show.legend=FALSE) +
ggplot2::coord_flip() +
ggplot2::xlab(ggplot2::element_blank()) +
ggplot2::ylab(ggplot2::element_blank()) +
ggplot2::labs(fill=" ") +
ggplot2::scale_fill_manual(values=manual.colour.values,
breaks=c("baseA", "baseB", "change A decrease", "change A increase"),
labels=c("A baseline ", "B", "A decreasing", "A increasing")) +
ggplot2::theme(panel.grid = ggplot2::element_blank()) +
ggplot2::theme(axis.text.x= ggplot2::element_blank()) +
ggplot2::theme(axis.ticks.x = ggplot2::element_blank())
if (length(unique(baseline.pie$Allele)) > 1 ){
ggpiex <- ggpiex +
ggplot2::theme(legend.position="top") +
ggplot2::facet_grid( ~ Allele, scales="free")
}
return(ggpiex)
}
| /scratch/gouwar.j/cran-all/cranData/AlleleShift/R/shift.pie.ggplot.R |
shift.surf.ggplot <- function(
freq.future,
Allele.focus=unique(freq.future$Allele)[1],
freq.focus="Allele.freq",
xcoord="LON", ycoord="LAT",
mean.change=FALSE, change.FUN=stats::median,
manual.colour.values=c("firebrick3", "chartreuse4"),
...
)
{
np <- length(unique(freq.future$Pop))
freq.future$xcoord <- freq.future[, xcoord]
freq.future$ycoord <- freq.future[, ycoord]
if (mean.change == TRUE) {
freq.columns <- cbind(freq.future$Allele.freq,
freq.future$Freq.e2,
freq.future$LCL,
freq.future$UCL)
freq.means <- stats::aggregate(freq.columns ~ freq.future$Pop, FUN=change.FUN)
names(freq.means)[1] <- "Pop"
freq.means <- dplyr::left_join(freq.future[, c("Pop", "Allele.freq")],
freq.means,
by="Pop")
# print(freq.means)
freq.future$Allele.freq <- freq.means$V1
freq.future$Freq.e2 <- freq.means$V2
freq.future$LCL <- freq.means$V3
freq.future$UCL <- freq.means$V4
freq.future <- freq.future[1:np, ]
freq.future$increasing <- freq.future$Freq.e2 > freq.future$Allele.freq
freq.future$Allele <- factor(rep("Alleles aggregated", np))
Allele.focus <- paste("Alleles aggregated")
}else{
freq.future <- freq.future[freq.future$Allele == Allele.focus, ]
}
freq.future$freq.focus <- freq.future[, freq.focus]
plotLONLAT <- vegan::ordiplot(freq.future[, c("xcoord", "ycoord")])
surfAllele <- BiodiversityR::ordisurfgrid.long(vegan::ordisurf(plotLONLAT, y=freq.future$freq.focus, ...))
ggsurfx <- ggplot2::ggplot() +
ggplot2::geom_contour_filled(data=surfAllele,
ggplot2::aes(x=surfAllele$x, y=surfAllele$y, z=surfAllele$z)) +
ggplot2::geom_point(data=freq.future,
ggplot2::aes(x=freq.future$xcoord, y=freq.future$ycoord, size=freq.future$freq.focus, colour=freq.future$increasing, shape=freq.future$increasing),
alpha=0.8, stroke=2, show.legend=FALSE) +
ggplot2::geom_point(data=freq.future,
ggplot2::aes(x=freq.future$xcoord, y=freq.future$ycoord, size=freq.future$freq.focus, shape=freq.future$increasing),
colour="black", alpha=0.8, stroke=0.5, show.legend=FALSE) +
ggplot2::geom_point(data=freq.future,
ggplot2::aes(x=freq.future$xcoord, y=freq.future$ycoord, colour=freq.future$increasing),
shape="square", alpha=0.8, stroke=0.5, show.legend=FALSE) +
ggplot2::xlab(ggplot2::element_blank()) +
ggplot2::ylab(ggplot2::element_blank()) +
ggplot2::labs(fill=Allele.focus) +
ggplot2::scale_fill_viridis_d() +
ggplot2::scale_colour_manual(values=manual.colour.values,
guide=FALSE) +
ggplot2::scale_size_area(max_size=6) +
ggplot2::scale_shape_manual(values=c(6, 2)) +
ggplot2::theme(panel.grid = ggplot2::element_blank()) +
ggplot2::theme(axis.text= ggplot2::element_blank()) +
ggplot2::theme(axis.ticks = ggplot2::element_blank()) +
ggplot2::theme(legend.title = ggplot2::element_text(size=9)) +
ggplot2::theme(legend.text = ggplot2::element_text(size=8)) +
ggplot2::coord_fixed()
return(ggsurfx)
}
| /scratch/gouwar.j/cran-all/cranData/AlleleShift/R/shift.surf.ggplot.R |
waffle.baker <- function(
freq.in = NULL, sort.index = "Pop.index",
mean.change=FALSE, change.FUN=stats::median
)
{
np <- length(unique(freq.in$Allele))
if (mean.change == TRUE) {
freq.columns <- cbind(freq.in$Allele.freq,
freq.in$Freq.e2,
freq.in$LCL,
freq.in$UCL)
freq.means <- stats::aggregate(freq.columns ~ freq.in$Pop, FUN=change.FUN)
names(freq.means)[1] <- "Pop"
freq.means <- dplyr::left_join(freq.in[, c("Pop", "Allele.freq")],
freq.means,
by="Pop")
freq.in$Allele.freq <- freq.means$V1
freq.in$Freq.e2 <- freq.means$V2
freq.in$LCL <- freq.means$V3
freq.in$UCL <- freq.means$V4
freq.in <- freq.in[1:np, ]
freq.in$increasing <- freq.in$Freq.e2 > freq.in$Allele.freq
freq.in$Allele <- factor(rep("Alleles aggregated", np))
}
waffle.iron <- function(freq, A.value="base A") {
data0 <- rbind(as.character(rep(200, 12)),
as.character(c(200, 1:10, 200)),
as.character(c(200, 11:20, 200)),
as.character(c(200, 21:30, 200)),
as.character(c(200, 31:40, 200)),
as.character(c(200, 41:50, 200)),
as.character(c(200, 51:60, 200)),
as.character(c(200, 61:70, 200)),
as.character(c(200, 71:80, 200)),
as.character(c(200, 81:90, 200)),
as.character(c(200, 91:100, 200)),
as.character(rep(200, 12)))
freq0 <- round(100*freq, 0)
data0[suppressWarnings(as.numeric(data0)) <= freq0] <- A.value
data0[suppressWarnings(as.numeric(data0)) == 200] <- c("background")
data0[suppressWarnings(as.numeric(data0)) > freq0] <- c("base B")
return(data0)
}
for (i in 1:nrow(freq.in)) {
if (i/100 == round(i/100)) {message(paste("Reached row: ", i, "out of ", nrow(freq.in)))}
sort.start.i <- 12*as.numeric(freq.in[i, sort.index]) - 11
sort.end.i <- sort.start.i + 11
rows.i.left <- data.frame(Pop=rep(freq.in[i, "Pop"], 12),
sort.index=seq(from=sort.start.i, to=sort.end.i),
Allele=rep(freq.in[i, "Allele"], 12))
waffle.left.i <- data.frame(waffle.iron(freq.in[i, "Allele.freq"]))
freq.fut <- as.numeric(freq.in[i, "Freq.e2"])
if (freq.in[i, "increasing"] == TRUE) {
waffle.right.i <- data.frame(waffle.iron(freq.fut, A.value="change A increase"))
}else{
waffle.right.i <- data.frame(waffle.iron(freq.fut, A.value="change A decrease"))
}
double.waffle.i <- cbind(rows.i.left,
waffle.left.i,
waffle.right.i)
if (i == 1) {
waffle.grid <- double.waffle.i
}else{
waffle.grid <- rbind(waffle.grid, double.waffle.i)
}
}
for (c.index in 4:ncol(waffle.grid)) {
waffle.lines <- data.frame(waffle.grid[, c(1:3)],
x.pos=rep((c.index-3), nrow(waffle.grid)),
colour=waffle.grid[, c.index])
if (c.index == 4) {
result <- waffle.lines
}else{
result <- rbind(result, waffle.lines)
}
}
result$line.colour <- as.character(rep(NA, nrow(result)))
result[result$colour == "base A", "line.colour"] <- c("black")
result[result$colour == "base B", "line.colour"] <- c("white")
result[result$colour == "change A increase", "line.colour"] <- c("black")
result[result$colour == "change A decrease", "line.colour"] <- c("black")
result$colour <- factor(result$colour, levels=c("background", "base A", "base B", "change A decrease", "change A increase"))
return(result)
}
shift.waffle.ggplot <- function(
future.waffle,
manual.colour.values=c("black", "grey", "firebrick3", "chartreuse4"),
manual.colour.codes=c("A baseline ", "B", "A decreasing", "A increasing")
)
{
np <- length(unique(future.waffle$Pop))
ggwafflex <- ggplot2::ggplot(future.waffle) +
ggplot2::scale_y_continuous(breaks=seq(from=7, to=12*(np-1)+7, length.out=np),
labels=levels(future.waffle$Pop)) +
ggplot2::geom_tile(ggplot2::aes(x=future.waffle$x.pos, y=future.waffle$sort.index, fill=future.waffle$colour, colour=future.waffle$line.colour)) +
ggplot2::xlab(ggplot2::element_blank()) +
ggplot2::ylab(ggplot2::element_blank()) +
ggplot2::labs(fill=" ") +
ggplot2::scale_fill_manual(values=c(NA, manual.colour.values),
# breaks=c("", "baseA", "baseB", "change A decrease", "change A increase"),
labels=c("Allele", "A baseline ", "B", "A decreasing", "A increasing")) +
ggplot2::scale_colour_manual(values=c(manual.colour.values[2], "white"),
guide=FALSE) +
ggplot2::theme(panel.grid = ggplot2::element_blank()) +
ggplot2::theme(axis.text.x= ggplot2::element_blank()) +
ggplot2::theme(axis.ticks.x = ggplot2::element_blank())
if (length(unique(future.waffle$Allele)) > 1 ){
ggwafflex <- ggwafflex +
ggplot2::theme(legend.position="top") +
ggplot2::facet_grid( ~ Allele, scales="free")
}
return(ggwafflex)
}
| /scratch/gouwar.j/cran-all/cranData/AlleleShift/R/shift.waffle.ggplot.R |
.onAttach <- function(...) {
packageStartupMessage("AlleleShift ", utils::packageDescription("AlleleShift", field="Version"),
": Please see https://doi.org/10.7717/peerj.11534 - choose functions count.model and freq.model to calibrate frequencies.")
}
| /scratch/gouwar.j/cran-all/cranData/AlleleShift/R/zzz.R |
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#' Ordinary Least Squares
#'
#' Fits the standard OLS model.
#'
#' @param y (n x 1) Numeric vector.
#' @param X (n x p) Numeric matrix.
#'
#' @return List containing the following:
#' \itemize{
#' \item{Beta}{Regression coefficient.}
#' \item{V}{Outcome variance.}
#' \item{SE}{Standard errors.}
#' \item{Z}{Z-scores.}
#' }
#' @export
OLS <- function(y, X) {
.Call(`_AllelicSeries_OLS`, y, X)
}
#' Calculate Residual Variance
#'
#' @param y (n x 1) Numeric phenotype vector.
#' @param X (n x q) Numeric covariate matrix.
#'
#' @return Scalar residual variance.
ResidVar <- function(y, X) {
.Call(`_AllelicSeries_ResidVar`, y, X)
}
#' Calculate Score Statistic
#'
#' @param y (n x 1) Numeric phenotype vector.
#' @param G (n x p) Numeric genotype matrix.
#' @param X (n x q) Numeric covariate matrix.
#' @param v Scalar residual variance.
#'
#' @return Scalar score statistic.
Score <- function(y, G, X, v) {
.Call(`_AllelicSeries_Score`, y, G, X, v)
}
| /scratch/gouwar.j/cran-all/cranData/AllelicSeries/R/RcppExports.R |
# Purpose: Allelic series test.
# Updated: 2023-10-04
# Default weights.
DEFAULT_WEIGHTS <- c(1, 2, 3)
#' Aggregator
#'
#' Aggregates genotypes within annotation categories.
#'
#' @param anno (snps x 1) annotation vector with values in c(0, 1, 2).
#' @param geno (n x snps) genotype matrix.
#' @param drop_empty Drop empty columns? Default: TRUE.
#' @param indicator Convert raw counts to indicators? Default: FALSE.
#' @param method Method for aggregating across categories:
#' {"none", "max", "sum"}. Default: "none".
#' @param weights Annotation category weights.
#' @return (n x 3) Numeric matrix without weighting, (n x 1) numeric matrix
#' with weighting.
#' @export
Aggregator <- function(
anno,
geno,
drop_empty = TRUE,
indicator = FALSE,
method = "none",
weights = DEFAULT_WEIGHTS
) {
# Sum to categories.
bmv <- apply(geno[, anno == 0, drop = FALSE], 1, sum)
dmv <- apply(geno[, anno == 1, drop = FALSE], 1, sum)
ptv <- apply(geno[, anno == 2, drop = FALSE], 1, sum)
# Convert to indicators.
if (indicator) {
bmv <- 1 * (bmv > 0)
dmv <- 1 * (dmv > 0)
ptv <- 1 * (ptv > 0)
}
# If weights are null, output 3 column matrix.
out <- cbind(bmv = bmv, dmv = dmv, ptv = ptv)
# Apply weighting.
out <- out %*% diag(weights)
# Drop empty columns.
if (drop_empty) {
col_sums <- apply(out, 2, sum)
out <- out[, col_sums > 0, drop = FALSE]
# Case of no non-zero variant classes.
if (ncol(out) == 0) {
warning("No non-zero variant classes after weighting.")
return(NA)
}
}
if (method == "sum") {
# Sum aggregation.
out <- apply(out, 1, sum)
} else if (method == "max") {
# Max aggregation.
out <- apply(out, 1, max)
} else {
# No aggregation (default).
out <- out
}
return(as.matrix(out))
}
# ------------------------------------------------------------------------------
#' Allelic Series Burden Test
#'
#' Burden test with allelic series weights.
#'
#' @param anno (snps x 1) annotation vector with values in c(0, 1, 2).
#' @param geno (n x snps) genotype matrix.
#' @param pheno (n x 1) phenotype vector.
#' @param apply_int Apply rank-based inverse normal transform to the phenotype?
#' Default: TRUE. Ignored if phenotype is binary.
#' @param covar (n x p) covariate matrix. Defaults to an (n x 1) intercept.
#' @param indicator Convert raw counts to indicators?
#' @param is_pheno_binary Is the phenotype binary? Default: FALSE.
#' @param method Method for aggregating across categories: {"none", "max",
#' "sum"}. Default: "none".
#' @param score_test Run a score test? If FALSE, performs a Wald test.
#' @param weights (3 x 1) annotation category weights.
#' @return Numeric p-value.
#' @examples
#' # Generate data.
#' data <- DGP(n = 1e3, snps = 1e2)
#'
#' # Run the Allelic Series Burden Test.
#' # Note: the output is a scalar p-value.
#' results <- ASBT(
#' anno = data$anno,
#' geno = data$geno,
#' pheno = data$pheno,
#' covar = data$covar
#' )
#' @export
ASBT <- function(
anno,
geno,
pheno,
apply_int = TRUE,
covar = NULL,
indicator = FALSE,
is_pheno_binary = FALSE,
method = "none",
score_test = FALSE,
weights = DEFAULT_WEIGHTS
) {
# Covariates.
if (is.null(covar)) {
covar <- rep(1, length(pheno))
}
# Data types.
anno <- as.vector(anno)
covar <- as.matrix(covar)
geno <- as.matrix(geno)
pheno <- as.vector(pheno)
# Input check.
CheckInputs(
anno = anno,
covar = covar,
geno = geno,
is_pheno_binary = is_pheno_binary,
pheno = pheno,
weights = weights
)
# Aggregate genotypes.
agg_geno <- Aggregator(
anno = anno,
geno = geno,
drop_empty = TRUE,
indicator = indicator,
method = method,
weights = weights
)
# Case of no non-zero variant classes.
if (!is.numeric(agg_geno)) {
return(NA)
}
# Rank-normal phenotype.
if (!is_pheno_binary & apply_int) {
y <- RNOmni::RankNorm(pheno)
} else {
y <- pheno
}
# Association test.
if (is_pheno_binary) {
pval <- LogisticLRT(y = y, g = agg_geno, x = covar)
} else {
pval <- LinearTest(y = y, g = agg_geno, x = covar, score_test = score_test)
}
return(pval)
}
# ------------------------------------------------------------------------------
#' Allelic Series SKAT Test
#'
#' Sequence kernel association test (SKAT) with allelic series weights.
#'
#' @param anno (snps x 1) annotation vector with values in c(0, 1, 2).
#' @param geno (n x snps) genotype matrix.
#' @param pheno (n x 1) phenotype vector.
#' @param apply_int Apply rank-based inverse normal transform to the phenotype?
#' Default: TRUE. Ignored if phenotype is binary.
#' @param covar (n x p) covariate matrix. Defaults to an (n x 1) intercept.
#' @param is_pheno_binary Is the phenotype binary? Default: FALSE.
#' @param return_null_model Return the null model in addition to the p-value?
#' Useful if running additional SKAT tests. Default: FALSE.
#' @param weights (3 x 1) annotation category weights.
#' @return If `return_null_model`, a list containing the p-value and the
#' SKAT null model. Otherwise, a numeric p-value.
#' @examples
#' # Generate data.
#' data <- DGP(n = 1e3, snps = 1e2)
#'
#' # Run the Allelic Series SKAT Test.
#' # Note: the output is a scalar p-value.
#' results <- ASKAT(
#' anno = data$anno,
#' geno = data$geno,
#' pheno = data$pheno,
#' covar = data$covar
#' )
#' @export
ASKAT <- function(
anno,
geno,
pheno,
apply_int = TRUE,
covar = NULL,
is_pheno_binary = FALSE,
return_null_model = FALSE,
weights = DEFAULT_WEIGHTS
) {
# Covariates.
if (is.null(covar)) {
covar <- rep(1, length(pheno))
}
# Data types.
anno <- as.vector(anno)
covar <- as.matrix(covar)
geno <- as.matrix(geno)
pheno <- as.vector(pheno)
# Input check.
CheckInputs(
anno = anno,
covar = covar,
geno = geno,
is_pheno_binary = is_pheno_binary,
pheno = pheno,
weights = weights
)
# Alternate allele frequencies.
aaf <- apply(geno, 2, mean) / 2
# Drop empty genotypes.
is_empty <- (aaf == 0 | aaf == 1)
anno <- anno[!is_empty]
geno <- geno[, !is_empty, drop = FALSE]
aaf <- aaf[!is_empty]
# SKAT weight.
w <- rep(0, length(anno))
for (i in 0:2) {
w[anno == i] <- weights[i + 1]
}
v <- aaf * (1 - aaf)
skat_weights <- sqrt(w / v)
# Case of no non-zero weights.
if (all(skat_weights == 0)) {
warning("No non-zero variant classes after weighting.")
return(NA)
}
# Rank-normal phenotype.
if (!is_pheno_binary & apply_int) {
y <- RNOmni::RankNorm(pheno)
} else {
y <- pheno
}
# SKAT null model.
if (is_pheno_binary) {
null <- SKAT::SKAT_Null_Model(y ~ covar, out_type = "D")
} else {
null <- SKAT::SKAT_Null_Model(y ~ covar, out_type = "C")
}
# SKAT test.
skato_test <- SKAT::SKAT(
geno,
null,
method = "SKATO",
weights = skat_weights
)
# Output.
if (return_null_model) {
out <- list(
p = skato_test$p.value,
null = null
)
} else {
out <- skato_test$p.value
}
return(out)
}
# -----------------------------------------------------------------------------
#' COding-variant Allelic Series Test
#'
#' Main allelic series test. Performs both Burden and SKAT type tests, then
#' combines the results to calculate an omnibus p-value.
#'
#' @param anno (snps x 1) annotation vector with values in c(0, 1, 2).
#' @param geno (n x snps) genotype matrix.
#' @param pheno (n x 1) phenotype vector.
#' @param apply_int Apply rank-based inverse normal transform to the phenotype?
#' Default: TRUE. Ignored if phenotype is binary.
#' @param covar (n x p) covariate matrix. Defaults to an (n x 1) intercept.
#' @param include_orig_skato_all Include the original version of SKAT-O applied
#' to all variants in the omnibus test? Default: FALSE.
#' @param include_orig_skato_ptv Include the original version of SKAT-O applied
#' to PTV variants only in the omnibus test? Default: FALSE.
#' @param is_pheno_binary Is the phenotype binary? Default: FALSE.
#' @param return_omni_only Return only the omnibus p-value? Default: FALSE.
#' @param score_test Use a score test for burden analysis? If FALSE, uses a
#' Wald test.
#' @param weights (3 x 1) annotation category weights.
#' @return Numeric p-value.
#' @examples
#' # Generate data.
#' data <- DGP(n = 1e3, snps = 1e2)
#'
#' # Run the COding-variant Allelic Series Test.
#' results <- COAST(
#' anno = data$anno,
#' geno = data$geno,
#' pheno = data$pheno,
#' covar = data$covar
#' )
#' show(results)
#'
#' @export
COAST <- function(
anno,
geno,
pheno,
apply_int = TRUE,
covar = NULL,
include_orig_skato_all = FALSE,
include_orig_skato_ptv = FALSE,
is_pheno_binary = FALSE,
return_omni_only = FALSE,
score_test = FALSE,
weights = DEFAULT_WEIGHTS
) {
# Covariates.
if (is.null(covar)) {
covar <- rep(1, length(pheno))
}
# Data types.
anno <- as.vector(anno)
covar <- as.matrix(covar)
geno <- as.matrix(geno)
pheno <- as.vector(pheno)
# Input check.
CheckInputs(
anno = anno,
covar = covar,
geno = geno,
is_pheno_binary = is_pheno_binary,
pheno = pheno,
weights = weights
)
BurdenWrap <- function(...) {
out <- ASBT(
anno = anno,
covar = covar,
geno = geno,
pheno = pheno,
apply_int = apply_int,
is_pheno_binary = is_pheno_binary,
score_test = score_test,
...
)
return(out)
}
# Burden tests.
p_count <- BurdenWrap(
indicator = FALSE, method = "none", weights = c(1, 1, 1))
# Case of no non-zero variant classes.
if (is.na(p_count)) {return(NA)}
p_ind <- BurdenWrap(
indicator = TRUE, method = "none", weights = c(1, 1, 1))
p_max_count <- BurdenWrap(
indicator = FALSE, method = "max", weights = weights)
p_max_ind <- BurdenWrap(
indicator = TRUE, method = "max", weights = weights)
p_sum_count <- BurdenWrap(
indicator = FALSE, method = "sum", weights = weights)
p_sum_ind <- BurdenWrap(
indicator = TRUE, method = "sum", weights = weights)
# Collect p-values.
p_burden <- c(
p_count = p_count,
p_ind = p_ind,
p_max_count = p_max_count,
p_max_ind = p_max_ind,
p_sum_count = p_sum_count,
p_sum_ind = p_sum_ind
)
# SKAT tests.
skat_list <- ASKAT(
anno = anno,
covar = covar,
geno = geno,
pheno = pheno,
is_pheno_binary = is_pheno_binary,
return_null_model = TRUE,
weights = weights
)
p_skat <- c(p_allelic_skat = skat_list$p)
null <- skat_list$null
# Standard SKAT-O all.
if (include_orig_skato_all) {
orig_skato_all <- SKAT::SKAT(geno, null, method = "SKATO")
p_skat <- c(p_skat, p_orig_skat_all = orig_skato_all$p.value)
}
# Standard SKAT-O PTV.
if (include_orig_skato_ptv) {
ptv <- geno[, anno == 2, drop = FALSE]
if (ncol(ptv) > 0) {
orig_skato_ptv <- SKAT::SKAT(ptv, null, method = "SKATO")
p_skat <- c(p_skat, p_orig_skat_ptv = orig_skato_ptv$p.value)
}
}
# Omnibus.
n_burden <- length(p_burden)
n_skat <- length(p_skat)
p_val = c(p_burden, p_skat)
omni_weights <- c(rep(1, n_burden), rep(n_burden / n_skat, n_skat))
p_omni <- RNOmni::OmniP(p = p_val, w = omni_weights)
# Output.
if (return_omni_only) {
out <- c(p_omni = p_omni)
} else {
out <- c(p_val, p_omni = p_omni)
}
return(out)
}
| /scratch/gouwar.j/cran-all/cranData/AllelicSeries/R/allelic_series_test.R |
#' @useDynLib AllelicSeries, .registration = TRUE
#' @importFrom Rcpp sourceCpp
NULL
#' @keywords internal
"_PACKAGE"
## usethis namespace: start
## usethis namespace: end
NULL
| /scratch/gouwar.j/cran-all/cranData/AllelicSeries/R/allelicseries-package.R |
# Purpose: Comparators for allelic series test.
# Updated: 2023-10-04
#' Comparator Test
#'
#' Runs burden, SKAT, and SKAT-O, using default settings.
#'
#' @param covar (n x p) covariate matrix.
#' @param geno (n x snps) genotype matrix.
#' @param pheno (n x 1) phenotype vector.
#' @param apply_int Apply rank-based inverse normal transform to the phenotype?
#' Default: TRUE. Ignored if phenotype is binary.
#' @param is_pheno_binary Is the phenotype binary? Default: FALSE.
#' @return Numeric vector of p-values.
#' @examples
#' # Generate data.
#' data <- DGP(n = 1e3, snps = 1e2)
#'
#' # Run the comparators.
#' results <- Comparator(
#' geno = data$geno,
#' pheno = data$pheno,
#' covar = data$covar
#' )
#' @export
Comparator <- function(
covar,
geno,
pheno,
apply_int = TRUE,
is_pheno_binary = FALSE
) {
# Rank-normal phenotype.
if (!is_pheno_binary & apply_int) {
y <- RNOmni::RankNorm(pheno)
} else {
y <- pheno
}
# SKAT null model.
if (is_pheno_binary) {
out_type <- "D"
} else {
out_type <- "C"
}
null <- SKAT::SKAT_Null_Model(y ~ covar, out_type = out_type)
# Alternate allele frequencies.
aaf <- apply(geno, 2, mean) / 2
v <- aaf * (1 - aaf)
skat_weights <- sqrt(1 / v)
# SKAT test.
burden_test <- SKAT::SKAT(geno, null, r.corr = 1.0)
p_burden <- burden_test$p.value
skat_test <- SKAT::SKAT(
geno,
null,
r.corr = 0.0,
weights = skat_weights
)
p_skat <- skat_test$p.value
skato_test <- SKAT::SKAT(
geno,
null,
method = "SKATO",
weights = skat_weights
)
p_skato <- skato_test$p.value
# Output.
out <- c(
p_burden = p_burden,
p_orig_skat = p_skat,
p_orig_skato = p_skato
)
return(out)
}
| /scratch/gouwar.j/cran-all/cranData/AllelicSeries/R/comparators.R |
# Purpose: Data generation for allelic series.
# Updated: 2023-03-15
#' Generate Genotype Matrix
#'
#' @param n Sample size.
#' @param snps Number of SNP in the gene.
#' @param maf_range Range of minor allele frequencies: c(MIN, MAX).
#' @return (n x snps) numeric matrix.
GenGenoMat <- function(
n,
snps,
maf_range = c(0.005, 0.010)
) {
geno <- lapply(seq_len(snps), function(i) {
maf <- stats::runif(1, maf_range[1], maf_range[2])
g <- stats::rbinom(n, 2, maf)
if (sum(g) == 0) {
# Randomly add 1 minor allele to avoid MAC = 0.
draw <- sample.int(n, size = 1)
g[draw] <- 1
}
return(g)
})
geno <- do.call(cbind, geno)
return(geno)
}
#' Generate Genotype Annotations
#'
#' Returns a vector of length = the number of columns (SNPs) in the genotype
#' matrix. Each SNP is classified as a benign missense variant (0), a
#' deleterious missense variant (1), or a protein truncating variant (2).
#'
#' @param snps Number of SNPs in the gene.
#' @param p_dmv Frequency of deleterious missense variants.
#' @param p_ptv Frequency of protein truncating variants.
#' @return (snps x 1) integer vector.
GenAnno <- function(
snps,
p_dmv = 0.33,
p_ptv = 0.33
) {
p_bmv <- 1 - sum(c(p_dmv, p_ptv))
p <- c(p_bmv, p_dmv, p_ptv)
anno <- stats::rmultinom(snps, size = 1, prob = p)
anno <- apply(anno, 2, which.max) - 1
return(anno)
}
#' Generate Genotypes
#'
#' @param n Sample size.
#' @param snps Number of SNP in the gene.
#' @param maf_range Range of minor allele frequencies: c(MIN, MAX).
#' @param p_dmv Frequency of deleterious missense variants.
#' @param p_ptv Frequency of protein truncating variants.
#' @return List containing the (n x snps) genotype matrix "geno" and the
#' (snps x 1) annotation vector "anno".
GenGeno <- function(
n,
snps,
maf_range = c(0.005, 0.010),
p_dmv = 0.33,
p_ptv = 0.33
) {
geno <- GenGenoMat(n = n, snps = snps, maf_range = maf_range)
anno <- GenAnno(snps, p_dmv, p_ptv)
out <- list(
anno = anno,
geno = geno
)
return(out)
}
#' Filter Noncausal Variants
#'
#' Remove a random fraction of variants, which are designated non-causal.
#'
#' @param anno (snps x 1) annotation vector.
#' @param geno (n x snps) genotype matrix.
#' @param prop_causal Proportion of variants which are causal.
#' @return List containing the (n x snps) genotype matrix "geno" and the
#' (snps x 1) annotation vector "anno".
FilterGenos <- function(
anno,
geno,
prop_causal = 1.0
) {
n_snp <- length(anno)
p_noncausal <- 1.0 - prop_causal
n_noncausal <- round(n_snp * p_noncausal)
which_drop <- sample(x = n_snp, size = n_noncausal, replace = FALSE)
# Code non-causal variants as "-1".
anno[which_drop] <- -1
geno_filtered <- geno[, anno != -1, drop = FALSE]
anno_filtered <- anno[anno != -1]
# Output.
out <- list(
anno = anno_filtered,
geno = geno_filtered
)
return(out)
}
#' Generate Covariates
#'
#' Generate an (n x 6) covariate matrix with columns representing an intercept,
#' age, sex, and 3 genetic PCs. Because these simulations address rare variant
#' analysis, correlation between genotypes and the genetic PCs (based on
#' common variants) is unnecessary.
#'
#' @param n Sample size.
#' @return (n x 6) numeric matrix.
GenCovar <- function(n) {
# Covariate representing (standardized) age.
age <- stats::rnorm(n)
# Covariate representing sex.
sex <- stats::rbinom(n, size = 1, prob = 0.5)
# 3 covariates representing PCs.
N_PC <- 3
pcs <- lapply(seq_len(N_PC), function(i) {stats::rnorm(n)})
pcs <- do.call(cbind, pcs)
# Output.
out <- cbind(age, pcs)
out <- scale(out)
out <- cbind(1, out[, 1], sex, out[, 2:ncol(out)])
colnames(out) <- c("int", "age", "sex", paste0("pc", seq_len(N_PC)))
return(out)
}
#' Calculate Regression Parameters
#'
#' Calculate phenotypic regression coefficients and the residual variation
#' based on proportion of variation explained (PVE) by each factor. Note that
#' the proportion of variation explained by genotype is required, but genetic
#' effects are not generated here.
#'
#' @param pve_age PVE by age.
#' @param pve_pcs PVE by PCs (collectively).
#' @param pve_sex PVE by sex.
#' @return List containing the (5 x 1) regression coefficient vector "coef" and
#' the residual standard deviation "sd".
CalcRegParam <- function(
pve_age = 0.10,
pve_pcs = 0.20,
pve_sex = 0.10
) {
# Residual PVE.
pve_res <- 1 - sum(c(pve_age, pve_pcs, pve_sex))
# Draw regression coefficients.
b_int <- 0
b_age <- stats::rnorm(1, sd = sqrt(pve_age))
b_sex <- stats::rnorm(1, sd = sqrt(pve_sex))
b_pcs <- stats::rnorm(3, sd = sqrt(pve_pcs / 3))
beta <- c(b_int, b_age, b_sex, b_pcs)
names(beta) <- c("int", "age", "sex", "pc1", "pc2", "pc3")
# Output.
out <- list(
coef = beta,
sd = sqrt(pve_res)
)
return(out)
}
#' Generate Phenotypes
#'
#' @param anno (snps x 1) annotation vector.
#' @param beta (3 x 1) coefficient vector for bmvs, dmvs, and ptvs respectively.
#' @param covar Covariate matrix.
#' @param geno (n x snps) genotype matrix.
#' @param reg_param Regression parameters.
#' @param binary Generate binary phenotype? Default: FALSE.
#' @param include_residual Include residual? If FALSE, returns the expected
#' value. Intended for testing.
#' @param indicator Convert raw counts to indicators? Default: FALSE.
#' @param method Genotype aggregation method. Default: "none".
#' @param prop_causal Proportion of variants which are causal.
#' @param random_signs Randomize signs? FALSE for burden-type genetic
#' architecture, TRUE for SKAT-type.
#' @param random_var Frailty variance in the case of random signs. Default: 0.
#' @param weights Aggregation weights.
#' @return (n x 1) numeric vector.
GenPheno <- function(
anno,
beta,
covar,
geno,
reg_param,
binary = FALSE,
include_residual = TRUE,
indicator = FALSE,
method = "none",
prop_causal = 1.0,
random_signs = FALSE,
random_var = 0.0,
weights = c(0, 1, 2)
) {
# Check configuration.
if ((method != "none") & (length(beta) > 1)) {
stop("Scalar beta is required for genotype aggregation.")
}
if ((method != "none") & random_signs) {
stop("Random signs are incompatible with aggregated genotypes.")
}
# Filter genotypes.
anno_geno <- FilterGenos(
anno = anno,
geno = geno,
prop_causal = prop_causal
)
anno <- anno_geno$anno
geno <- anno_geno$geno
# Calculate genetic effect.
# Null phenotype.
if (all(beta == 0)) {
eta_g <- 0
# SKAT-type phenotype.
} else if(random_signs) {
n_snps <- length(anno)
long_beta <- rep(0, n_snps)
# Generate an effect size vector of length == the annotation vector.
for (i in 0:2) {long_beta[anno == i] <- beta[i + 1]}
# Sample the sign.
signs <- sample(x = c(-1, 1), size = n_snps, replace = TRUE)
# Sample the frailty (positive random effect with expectation 1.0).
if (random_var == 0) {
gamma <- 1
} else {
shape <- 1 / random_var
gamma <- stats::rgamma(n = n_snps, shape = shape, rate = shape)
}
# Overall genetic effect sizes.
long_beta <- signs * gamma * long_beta
# Convert to indicator genotypes, if required.
if (indicator) {geno <- 1 * (geno > 0)}
# Overall genetic contribution to the phenotype.
eta_g <- as.numeric(geno %*% long_beta)
# Burden-type phenotypes.
} else {
agg_geno <- Aggregator(
anno = anno,
geno = geno,
drop_empty = FALSE,
indicator = indicator,
method = method,
weights = weights
)
# Overall genetic contribution to the phenotype.
# If method is not none, beta is a scalar, else a vector.
if (method != "none") {
eta_g <- as.numeric(agg_geno * beta)
} else {
eta_g <- as.numeric(agg_geno %*% beta)
}
}
# Covariate effect.
eta_x <- as.numeric(covar %*% reg_param$coef)
# Linear predictor.
eta <- eta_g + eta_x
# Add residual, if required.
if (include_residual) {
y <- eta + stats::rnorm(length(eta), sd = reg_param$sd)
} else {
y <- eta
}
# Convert to binary, if required.
if (binary) {
y <- 1 * (y >= 0)
}
return(y)
}
# -----------------------------------------------------------------------------
#' Data Generating Process
#'
#' Generate a data set consisting of: \itemize{
#' \item{"anno"}{A SNP-length annotation vector.}
#' \item{"covar"}{A subject by 6 covariate matrix.}
#' \item{"geno"}{A subject by SNP genotype matrix.}
#' \item{"pheno"}{A subject-length phenotype vector.}
#' }
#'
#' @param anno Annotation vector, if providing genotypes. Should match the
#' number of columns in geno.
#' @param beta If method = "none", a (3 x 1) coefficient vector for bmvs, dmvs,
#' and ptvs respectively. If method != "none", a scalar effect size.
#' @param binary Generate binary phenotype? Default: FALSE.
#' @param geno Genotype matrix, if providing genotypes.
#' @param include_residual Include residual? If FALSE, returns the expected
#' value. Intended for testing.
#' @param indicator Convert raw counts to indicators? Default: FALSE.
#' @param maf_range Range of minor allele frequencies: c(MIN, MAX).
#' @param method Genotype aggregation method. Default: "none".
#' @param n Sample size.
#' @param p_dmv Frequency of deleterious missense variants. Default of 40% is
#' based on the frequency of DMVs among rare coding variants in the UK
#' Biobank.
#' @param p_ptv Frequency of protein truncating variants. Default of 10% is
#' based on the frequency of PTVs among rare coding variants in the UK
#' Biobank.
#' @param prop_causal Proportion of variants which are causal. Default: 1.0.
#' @param random_signs Randomize signs? FALSE for burden-type genetic
#' architecture, TRUE for SKAT-type.
#' @param random_var Frailty variance in the case of random signs. Default: 0.
#' @param snps Number of SNP in the gene. Default: 100.
#' @param weights Aggregation weights.
#' @return List containing: genotypes, annotations, covariates, phenotypes.
#' @examples
#' # Generate data.
#' data <- DGP(n = 100)
#'
#' # View components.
#' table(data$anno)
#' head(data$covar)
#' head(data$geno[, 1:5])
#' hist(data$pheno)
#' @export
DGP <- function(
anno = NULL,
beta = c(0, 1, 2),
binary = FALSE,
geno = NULL,
include_residual = TRUE,
indicator = FALSE,
maf_range = c(0.005, 0.010),
method = "none",
n = 100,
p_dmv = 0.40,
p_ptv = 0.10,
prop_causal = 1.0,
random_signs = FALSE,
random_var = 0.0,
snps = 100,
weights = c(1, 2, 3)
) {
# Generate genotypes and annotations.
if (is.null(anno) & is.null(geno)) {
# Neither annotations nor genotypes provided.
anno_geno <- GenGeno(
n = n,
snps = snps,
maf_range = maf_range,
p_dmv = p_dmv,
p_ptv = p_ptv
)
} else if(is.null(anno) & !is.null(geno)) {
# Only genotypes provided.
geno <- as.matrix(geno)
n <- nrow(geno)
snps <- ncol(geno)
anno <- GenAnno(snps, p_dmv = p_dmv, p_ptv = p_ptv)
anno_geno <- list(
anno = anno,
geno = geno
)
} else if(!is.null(anno) & is.null(geno)) {
# Only annotations provided.
snps <- length(anno)
geno <- GenGenoMat(
n = n,
snps = snps,
maf_range = maf_range
)
anno_geno <- list(
anno = anno,
geno = geno
)
} else {
# Annotations and genotypes provided.
geno <- as.matrix(geno)
stopifnot(length(anno) == ncol(geno))
snps <- ncol(geno)
n <- nrow(geno)
anno_geno <- list(
anno = anno,
geno = geno
)
}
# Generate covariates.
covar <- GenCovar(n)
# Regression parameters.
reg_param <- CalcRegParam()
# Generate phenotypes.
pheno <- GenPheno(
anno = anno_geno$anno,
beta = beta,
covar = covar,
geno = anno_geno$geno,
reg_param = reg_param,
binary = binary,
include_residual = include_residual,
indicator = indicator,
method = method,
prop_causal = prop_causal,
random_signs = random_signs,
random_var = random_var,
weights = weights
)
# Output.
out <- list(
anno = anno_geno$anno,
covar = covar,
geno = anno_geno$geno,
pheno = pheno
)
return(out)
}
| /scratch/gouwar.j/cran-all/cranData/AllelicSeries/R/generate_data.R |
# Purpose: Input checks.
# Updated: 2023-10-04
#' Check Inputs
#'
#' @param anno (snps x 1) annotation vector.
#' @param covar (n x p) covariate matrix.
#' @param geno (n x snps) genotype matrix.
#' @param is_pheno_binary Is the phenotype binary?
#' @param pheno (n x 1) phenotype vector.
#' @param weights (3 x 1) annotation category weights.
#' @return None.
CheckInputs <- function(
anno,
covar,
geno,
is_pheno_binary,
pheno,
weights
) {
# Check annotation length.
if (length(anno) != ncol(geno)) {
stop("Length of the annotation vector should match number of columns in
the genotype matrix.")
}
# Check for missing values.
any_na <- any(is.na(anno)) |
any(is.na(covar)) |
any(is.na(geno)) |
any(is.na(pheno))
if (any_na) {
stop("Input data should not contain missing values.")
}
# Check dimensional consistency.
equal_dims <- all.equal(nrow(covar), nrow(geno), length(pheno))
if (!equal_dims) {
stop("Input dimensions are inconsistent.")
}
# Check for non-zero genotypes and phenotypes.
if (all(geno == 0)) {
stop("No non-zero genotypes are present.")
}
if (all(pheno == 0)){
stop("No non-zero phenotypes are present.")
}
# Check weights.
if (all(weights == 0)) {
stop("At least 1 annotation category requires non-zero weights.")
}
if (any(weights < 0)) {
stop("Annotation category weights should be non-negative.")
}
# Check binary phenotype.
unique_pheno_values <- sort(unique(pheno))
if (is_pheno_binary) {
improper <- any(
length(unique_pheno_values) != 2,
!all(unique_pheno_values %in% c(0, 1))
)
if (improper) {
stop("A binary phenotype must have exactly 2 values: {0, 1}.")
}
}
}
| /scratch/gouwar.j/cran-all/cranData/AllelicSeries/R/input_checks.R |
# Purpose: Utility functions.
# Updated: 2023-04-25
#' Linear Association Test
#'
#' @param y (n x 1) continuous phenotype vector
#' @param g (n x p) genotype matrix.
#' @param x (n x q) covariate matrix.
#' @param score_test Run a score test? If FALSE, performs a Wald test.
#' @return Numeric p-value.
#' @noRd
LinearTest <- function(y, g, x, score_test = FALSE) {
# Estimate residual variance.
if (score_test) {
resid_var <- ResidVar(y = y, X = x)
} else {
resid_var <- ResidVar(y = y, X = cbind(g, x))
}
# Calculate test statistic.
stat <- Score(y = y, G = g, X = x, v = resid_var)
df <- ncol(g)
pval <- stats::pchisq(q = stat, df = df, lower.tail = FALSE)
return(pval)
}
#' Likelihood Ratio Test
#'
#' @param y (n x 1) binary (0/1) phenotype vector
#' @param g (n x p) genotype matrix.
#' @param x (n x q) covariate matrix.
#' @return Numeric p-value.
#' @noRd
LogisticLRT <- function(y, g, x) {
# Full model.
fit_full <- stats::glm(
y ~ 0 + g + x, family = stats::binomial(link = "logit"))
# Null model.
fit_null <- stats::glm(
y ~ 0 + x, family = stats::binomial(link = "logit"))
# LRT.
lrt <- stats::anova(fit_null, fit_full)
dev <- lrt$Deviance[2]
df <- lrt$Df[2]
pval <- stats::pchisq(q = dev, df = df, lower.tail = FALSE)
return(pval)
}
| /scratch/gouwar.j/cran-all/cranData/AllelicSeries/R/utilities.R |
## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(echo = TRUE)
## -----------------------------------------------------------------------------
set.seed(101)
n <- 100
data <- AllelicSeries::DGP(
n = n,
snps = 300,
beta = c(1, 2, 3) / sqrt(n),
)
# Annotations.
anno <- data$anno
head(anno)
# Covariates.
covar <- data$covar
head(covar)
# Genotypes.
geno <- data$geno
head(geno[,1:5])
# Phenotype.
pheno <- data$pheno
head(pheno)
## -----------------------------------------------------------------------------
results <- AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = pheno,
covar = covar
)
show(results)
## ---- eval = FALSE------------------------------------------------------------
# AllelicSeries::COAST(
# anno = anno,
# geno = geno,
# pheno = pheno,
# covar = covar,
# apply_int = TRUE
# )
## ---- eval = FALSE------------------------------------------------------------
# AllelicSeries::COAST(
# anno = anno,
# geno = geno,
# pheno = pheno,
# covar = covar,
# include_orig_skato_all = TRUE,
# include_orig_skato_ptv = TRUE,
# )
## ---- eval = FALSE------------------------------------------------------------
# AllelicSeries::COAST(
# anno = anno,
# geno = geno,
# pheno = 1 * (pheno > 0),
# covar = covar,
# is_pheno_binary = TRUE
# )
## ---- eval = FALSE------------------------------------------------------------
# AllelicSeries::COAST(
# anno = anno,
# geno = geno,
# pheno = pheno,
# covar = covar,
# return_omni_only = TRUE
# )
## ---- eval = FALSE------------------------------------------------------------
# AllelicSeries::COAST(
# anno = anno,
# geno = geno,
# pheno = pheno,
# covar = covar,
# score_test = TRUE
# )
## ---- eval = FALSE------------------------------------------------------------
# AllelicSeries::COAST(
# anno = anno,
# geno = geno,
# pheno = pheno,
# covar = covar,
# weights = c(1, 2, 3)
# )
| /scratch/gouwar.j/cran-all/cranData/AllelicSeries/inst/doc/coast.R |
---
title: "Coding-variant Allelic Series Test"
output: rmarkdown::html_vignette
date: "2023-05-01"
vignette: >
%\VignetteIndexEntry{my-vignette}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Data
To run an allelic series test, there are 4 key inputs:
* A numeric annotation vector, of the same length as the number of variants, coded as 0 for benign missense variants (BMVs), 1 for deleterious missense variants (DMVs), and 2 for protein truncating variants (PTVs).
* A covariates matrix, with as many rows as subjects and including columns such as age and sex. If omitted, defaults to an intercept only.
* A genotype matrix, with subjects as rows and variants as columns. The number of columns should correspond to the length of the annotation vector.
* A numeric phenotype vector, either continuous or binary.
The example data used below were generated using the `DGP` function provided with the package. The data set includes 100 subjects, 300 variants, and a continuous phenotype. The true effect sizes follow an allelic series, with magnitudes proportional to `c(1, 2, 3)` for BMVs, DMVs, and PTVs respectively.
```{r}
set.seed(101)
n <- 100
data <- AllelicSeries::DGP(
n = n,
snps = 300,
beta = c(1, 2, 3) / sqrt(n),
)
# Annotations.
anno <- data$anno
head(anno)
# Covariates.
covar <- data$covar
head(covar)
# Genotypes.
geno <- data$geno
head(geno[,1:5])
# Phenotype.
pheno <- data$pheno
head(pheno)
```
The example data generated by the preceding are available under `vignettes/vignette_data`.
## Running the alleic series test
The COding-variant Allelic Series Test (COAST) is run using the `COAST` function. By default, p-values for the component tests, as well as the overall omnibus test (`p_omni`), are returned. Inspection of the component p-values is useful for determining which model(s) drove an association. In the presence case, the association was most evident via the baseline count model (`p_count`).
```{r}
results <- AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = pheno,
covar = covar
)
show(results)
```
### Test options
* `apply_int = TRUE` applies the rank-based inverse normal transformation from the [RNOmni](https://CRAN.R-project.org/package=RNOmni) package. This transformation is expected to improve power for phenotypes that have a skewed or kurtotic (e.g. long-tailed) distribution. It is applied by default in the case of continuous phenotype, and is ignored in the case of a binary phenotype.
```{r, eval = FALSE}
AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = pheno,
covar = covar,
apply_int = TRUE
)
```
* `include_orig_skato_all = TRUE` includes standard SKAT-O applied to all variants as a component of the omnibus test, while `include_orig_skato_ptv = TRUE` includes standard SKAT-O applied to PTVs only. Including standard SKAT-O as a component of the omnibus test can improve power to detect associations between the phenotype and genes that may not be allelic series.
```{r, eval = FALSE}
AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = pheno,
covar = covar,
include_orig_skato_all = TRUE,
include_orig_skato_ptv = TRUE,
)
```
* `is_pheno_binary = TRUE` is required to indicate that the supplied phenotype is binary, and should be analyzed using a logistic regression model.
```{r, eval = FALSE}
AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = 1 * (pheno > 0),
covar = covar,
is_pheno_binary = TRUE
)
```
* `return_omni_only = TRUE` is used to return `p_omni` only when the component p-values are not of interest:
```{r, eval = FALSE}
AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = pheno,
covar = covar,
return_omni_only = TRUE
)
```
* `score_test = TRUE` specifies the use of a score-type allelic series burden test. The default of `score_test = FALSE` specifies a Wald-type allelic series burden test.
```{r, eval = FALSE}
AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = pheno,
covar = covar,
score_test = TRUE
)
```
* `weights` specifies the relative phenotypic effects of BMVs, DMVs, and PTVs. An increasing pattern such as the default setting of `weights = c(1, 2, 3)` targets allelic series. Setting `weights = c(1, 1, 1)` would target a genetic architecture where all variants have equivalent expected magnitudes.
```{r, eval = FALSE}
AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = pheno,
covar = covar,
weights = c(1, 2, 3)
)
```
| /scratch/gouwar.j/cran-all/cranData/AllelicSeries/inst/doc/coast.Rmd |
---
title: "Coding-variant Allelic Series Test"
output: rmarkdown::html_vignette
date: "2023-05-01"
vignette: >
%\VignetteIndexEntry{my-vignette}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Data
To run an allelic series test, there are 4 key inputs:
* A numeric annotation vector, of the same length as the number of variants, coded as 0 for benign missense variants (BMVs), 1 for deleterious missense variants (DMVs), and 2 for protein truncating variants (PTVs).
* A covariates matrix, with as many rows as subjects and including columns such as age and sex. If omitted, defaults to an intercept only.
* A genotype matrix, with subjects as rows and variants as columns. The number of columns should correspond to the length of the annotation vector.
* A numeric phenotype vector, either continuous or binary.
The example data used below were generated using the `DGP` function provided with the package. The data set includes 100 subjects, 300 variants, and a continuous phenotype. The true effect sizes follow an allelic series, with magnitudes proportional to `c(1, 2, 3)` for BMVs, DMVs, and PTVs respectively.
```{r}
set.seed(101)
n <- 100
data <- AllelicSeries::DGP(
n = n,
snps = 300,
beta = c(1, 2, 3) / sqrt(n),
)
# Annotations.
anno <- data$anno
head(anno)
# Covariates.
covar <- data$covar
head(covar)
# Genotypes.
geno <- data$geno
head(geno[,1:5])
# Phenotype.
pheno <- data$pheno
head(pheno)
```
The example data generated by the preceding are available under `vignettes/vignette_data`.
## Running the alleic series test
The COding-variant Allelic Series Test (COAST) is run using the `COAST` function. By default, p-values for the component tests, as well as the overall omnibus test (`p_omni`), are returned. Inspection of the component p-values is useful for determining which model(s) drove an association. In the presence case, the association was most evident via the baseline count model (`p_count`).
```{r}
results <- AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = pheno,
covar = covar
)
show(results)
```
### Test options
* `apply_int = TRUE` applies the rank-based inverse normal transformation from the [RNOmni](https://CRAN.R-project.org/package=RNOmni) package. This transformation is expected to improve power for phenotypes that have a skewed or kurtotic (e.g. long-tailed) distribution. It is applied by default in the case of continuous phenotype, and is ignored in the case of a binary phenotype.
```{r, eval = FALSE}
AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = pheno,
covar = covar,
apply_int = TRUE
)
```
* `include_orig_skato_all = TRUE` includes standard SKAT-O applied to all variants as a component of the omnibus test, while `include_orig_skato_ptv = TRUE` includes standard SKAT-O applied to PTVs only. Including standard SKAT-O as a component of the omnibus test can improve power to detect associations between the phenotype and genes that may not be allelic series.
```{r, eval = FALSE}
AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = pheno,
covar = covar,
include_orig_skato_all = TRUE,
include_orig_skato_ptv = TRUE,
)
```
* `is_pheno_binary = TRUE` is required to indicate that the supplied phenotype is binary, and should be analyzed using a logistic regression model.
```{r, eval = FALSE}
AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = 1 * (pheno > 0),
covar = covar,
is_pheno_binary = TRUE
)
```
* `return_omni_only = TRUE` is used to return `p_omni` only when the component p-values are not of interest:
```{r, eval = FALSE}
AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = pheno,
covar = covar,
return_omni_only = TRUE
)
```
* `score_test = TRUE` specifies the use of a score-type allelic series burden test. The default of `score_test = FALSE` specifies a Wald-type allelic series burden test.
```{r, eval = FALSE}
AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = pheno,
covar = covar,
score_test = TRUE
)
```
* `weights` specifies the relative phenotypic effects of BMVs, DMVs, and PTVs. An increasing pattern such as the default setting of `weights = c(1, 2, 3)` targets allelic series. Setting `weights = c(1, 1, 1)` would target a genetic architecture where all variants have equivalent expected magnitudes.
```{r, eval = FALSE}
AllelicSeries::COAST(
anno = anno,
geno = geno,
pheno = pheno,
covar = covar,
weights = c(1, 2, 3)
)
```
| /scratch/gouwar.j/cran-all/cranData/AllelicSeries/vignettes/coast.Rmd |
# Class definition.
setClass("Asset",
representation(
title="character",
parameters="numeric", # processing and other parameters
reference="data.frame", # population features
demographics="data.frame", # population covariates
naming="data.frame", # conversions for variable names
categories="data.frame", # category attributes
centroids="matrix", # classification model
coefficients="list")) # regression models
# Import asset from disk.
asset <- function(
folder=NULL,
verbose=TRUE) {
# Check if anything to do.
output <- new("Asset"); configuration(output) <- NULL
if(length(folder) < 1) return(output)
# Check folder.
if(!dir.exists(folder)) stop("Folder does not exist.")
# Asset identifier.
dat <- import_data(folder, "configuration", verbose=F)
rownames(dat) <- dat$PARAM
output@title <- dat["title","VALUE"]
if(verbose) {
cat("\n", output@title, "\n", sep="")
cat(attr(dat, "message"))
}
# Configuration parameters.
dat <- dat[setdiff(rownames(dat),"title"),,drop=FALSE]
output@parameters <- as.double(dat$VALUE)
names(output@parameters) <- dat$PARAM
# Visual attributes.
dat <- import_data(folder, "categories", verbose=verbose)
rownames(dat) <- dat$CATEG; dat$CATEG <- NULL
# Check if duplicated labels.
if(anyDuplicated(dat$LABEL) > 0) {
f <- as.factor(dat$LABEL)
if(length(levels(f)) < 2) stop("Less than two category groups.")
dat$GROUP <- as.integer(f)
}
output@categories <- dat
# Population features.
dat <- import_data(folder, "reference", verbose=verbose)
rownames(dat) <- dat$VAR; dat$VAR <- NULL
output@reference <- dat
# Population covariates.
dat <- import_data(folder, "covariates", verbose=verbose)
if(length(dat) > 0) {
rownames(dat) <- dat$VAR; dat$VAR <- NULL
output@demographics <- dat
}
# Variable name conversions.
dat <- import_data(folder, "nomenclature", verbose=verbose)
if(length(dat) > 0) {
rownames(dat) <- dat$VAR; dat$VAR <- NULL
output@naming <- dat
}
# Centroids.
dat <- import_data(folder, "centroids", verbose=verbose)
rownames(dat) <- dat$VAR; dat$VAR <- NULL
output@centroids <- as.matrix(dat)
# Regression models.
dat <- import_data(folder, "coefficients", verbose=verbose)
models <- split(x=dat, f=dat$MODEL)
output@coefficients <- lapply(models, function(x) {
rownames(x) <- x$CATEG; x$CATEG <- NULL; x$MODEL <- NULL
return(t(as.matrix(x)))
})
return(output)
}
# Import asset component from file.
import_data <- function(
folder,
fname,
verbose) {
output <- NULL
fpath <- file.path(folder, paste0(fname, ".txt"))
if(file.exists(fpath)) {
output <- read.delim(file=fpath, sep="\t",
stringsAsFactors=FALSE, check.names=FALSE)
nbytes <- prettyNum(file.size(fpath), big.mark=",")
msg <- paste0(" ", fname, " -> ", nbytes, " bytes\n")
if(verbose) cat(msg)
attr(output, "message") <- msg
}
return(output)
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/Asset.R |
# Train a classification asset.
setGeneric("assemble<-", function(obj, value)
standardGeneric("assemble<-"))
setMethod("assemble<-", "Asset",
function(
obj,
value) {
# Check if locked.
if(length(obj@centroids) > 0)
stop("Asset is already assembled.")
# Set title.
if(length(value$title) < 1) stop("No title.")
if(!is.character(value$title)) stop("Unusable title.")
if(nchar(value$title) < 1) stop("Empty title.")
if(nchar(value$title) > 16) stop("Title is over 16 characters.")
obj@title <- as.character(value$title[1])
# Check data.
if(length(value$dat) < 1) stop("No data.")
dat <- value$dat; value$dat <- NULL # reduce memory footprint
dat <- makematrix(dat, finite=TRUE)
if(is.character(dat)) {
warning("Problem with input data.", call.=F, immediate.=T)
stop(dat)
}
# Select final training features.
predictors <- value$predictors
if(length(predictors) > 0) {
predictors <- intersect(predictors, rownames(dat))
if(length(predictors) < length(value$predictors))
warning("Missing predictors.", immediate.=T)
if(length(predictors) < 3) stop("Too few predictors.")
}
# Check bitmap.
if(length(value$bits) < 1) stop("No category bits.")
bits <- make_bits(value$bits)
if(is.character(bits)) {
warning("Problem with category bits.", call.=F, immediate.=T)
stop(bits)
}
# Check reserved variable names.
reserved <- c("Ambiguous","Unclassified","")
cnames <- setdiff(colnames(bits), reserved)
if(length(cnames) < 1) stop("No usable category labels.")
if(length(cnames) < ncol(bits)) {
reserved <- intersect(reserved, colnames(bits))
for(m in reserved) {
msg <- paste0("Category label excluded: '", m, "'.")
warning(msg, call.=F, immediate.=T)
}
bits <- bits[,cnames,drop=FALSE]
}
# Check covariates.
covars <- value$covariates
if(length(covars) > 0) {
covars <- makematrix(covars, finite=TRUE)
if(is.character(covars)) {
warning("Problem with covariates.", call.=F, immediate.=T)
stop(covars)
}
# Check reserved variable names.
reserved <- c("CATEG", "")
if(anyDuplicated(colnames(covars)) > 0)
stop("Duplicated covariates.")
if(anyDuplicated(c(colnames(covars), reserved)) > 0)
stop("Reserved covariate names.")
}
# Check sample identities.
keys <- intersect(colnames(dat), rownames(bits))
if(length(covars) > 0) keys <- intersect(keys, rownames(covars))
if(length(keys) < ncol(dat)) {
msg <- paste0("Asset.assemble(): ", length(keys),
" / ", ncol(dat), " samples included.")
warning(msg, call.=FALSE, immediate.=TRUE)
if(length(keys) < 10) stop("Too few training samples.")
}
dat <- dat[,keys,drop=FALSE]
bits <- bits[keys,,drop=FALSE]
if(length(covars) > 0) covars <- covars[keys,,drop=FALSE]
# Check visuals.
if(length(obj@categories) < 1) visuals(obj) <- colnames(bits)
categ <- c(colnames(bits), "Unclassified", "Ambiguous")
vars <- intersect(categ, rownames(obj@categories))
if(length(vars) < length(categ)) {
missed <- setdiff(categ, rownames(obj@categories))
for(m in missed) {
msg <- paste0("Missing visuals: ", m, ".")
warning(msg, call.=F, immediate.=T)
}
stop("Incompatible visuals.")
}
obj@categories <- obj@categories[vars,,drop=FALSE]
# Apply nomenclature.
vars <- translate(dat, obj@naming)
if(anyDuplicated(vars) > 0)
stop("Nomenclature caused duplicated row names.")
if(length(predictors) > 0)
predictors <- vars[match(predictors, rownames(dat))]
rownames(dat) <- vars
# Population reference.
ref <- reference(dat=dat, cfg=obj@parameters)
if(is.character(ref)) stop(ref)
obj@reference <- ref
# Trim nomenclature.
if(length(obj@naming) > 0) {
keys <- intersect(rownames(ref), rownames(obj@naming))
obj@naming <- obj@naming[keys,,drop=F]
}
# Population covariates.
if(length(covars) > 0) {
obj@demographics <- data.frame(
N=apply(is.finite(covars), 2, sum),
MEAN=apply(covars, 2, mean, na.rm=TRUE),
SD=apply(covars, 2, sd, na.rm=TRUE))
}
# Normalize and standardize training data.
dat <- normalize(obj, dat=dat); gc()
dat <- standardize(obj, dat=dat); gc()
# Exclude redundant variables.
if(length(predictors) > 0) {
dat <- dat[predictors,,drop=FALSE]
}
else {
dat <- prune(dat=dat, bits=bits,
nmax=obj@parameters["ninput.max"],
rrmax=obj@parameters["rrinput.max"])
if(is.character(dat)) stop(dat)
}
# Summarize subset patterns.
cents <- summarize(dat=dat, bits=bits)
if(is.character(cents)) stop(cents)
if(ncol(cents) < ncol(bits)) {
msg <- paste0("Asset.assemble(): ", ncol(cents),
" / ", ncol(bits), " categories included.")
warning(msg, call.=FALSE, immediate.=TRUE)
}
obj@centroids <- cents
# Distances to centroids.
delta <- distances(dat=dat, centroids=obj@centroids)
if(is.character(delta)) stop(delta)
# Regression models of proximity.
beta <- analyze(dat=delta, covariates=covars, bits=bits, balance=TRUE)
if(is.character(beta)) stop(beta)
obj@coefficients[["prox"]] <- beta
# Regression models of frequency.
beta <- analyze(dat=delta, covariates=covars, bits=bits, balance=FALSE)
if(is.character(beta)) stop(beta)
obj@coefficients[["freq"]] <- beta
return(obj)
})
#-------------------------------------------------------------------------
# Prepare category data.
make_bits <- function(dat) {
output <- NULL
# Check if any data.
if(length(dat) < 1) return("Empty input.")
# Convert a vector into a matrix.
if(!is.matrix(dat) && !is.data.frame(dat)) {
keys <- names(dat)
if(length(keys) < 1) return("No identities for category bits.")
dat <- data.frame(X=as.vector(dat), stringsAsFactors=FALSE)
rownames(dat) <- keys
}
# Split into binary columns.
output <- NULL
if(ncol(dat) == 1) {
keys <- rownames(dat)
if(length(keys) < 1) return("No identities for category bits.")
dat <- as.factor(dat[,1])
levs <- as.character(levels(dat))
if(sum(is.na(levs)) > 0) return("Unusable category name.")
if(sum(nchar(levs) < 1) > 0) return("Empty category name.")
dat <- as.integer(dat)
output <- matrix(0, nrow=length(keys), ncol=length(levs))
rownames(output) <- as.character(keys)
colnames(output) <- as.character(levs)
for(j in 1:ncol(output))
output[,j] <- as.integer(dat == j)
}
else {
output <- dat
for(j in 1:ncol(output))
output[,j] <- as.integer(dat[,j] != 0)
}
return(makematrix(output, finite=TRUE))
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/Asset.assemble.R |
# Samples as columns, genes as rows.
setGeneric("classify", function(obj, dat, covariates)
standardGeneric("classify"))
setMethod("classify", "Asset",
function(
obj,
dat,
covariates) {
# Check if ready.
if(length(obj@centroids) < 1)
stop("Asset is not assembled.")
# Make sure data are in a matrix.
dat <- makematrix(dat)
if(is.character(dat)) stop(dat)
# Normalize and standardize profiles.
dat <- normalize(obj, dat=dat)
dat <- standardize(obj, dat=dat, trim=TRUE)
# Select covariates.
if(length(obj@demographics) > 0) {
# Make sure covariates are in a matrix.
covariates <- makematrix(covariates)
if(is.character(covariates)) stop(covariates)
# Check compatibility.
keys <- intersect(colnames(dat), rownames(covariates))
if(length(keys) < ncol(dat)) stop("Incompatible covariates.")
covariates <- covariates[colnames(dat),,drop=FALSE]
# Select variables.
prox <- obj@coefficients[["prox"]]
vars <- intersect(rownames(prox), colnames(covariates))
vars <- setdiff(vars, c("B0","B1","MODEL"))
if((length(vars) + 3) < nrow(prox))
stop("Insufficient covariates.")
covariates <- covariates[,vars,drop=FALSE]
}
# Distances to centroids.
delta <- distances(dat=dat, centroids=obj@centroids)
if(is.character(delta)) stop(delta)
# Standardized category scores.
biomrk <- regress(dat=delta, covariates=covariates,
coeff=obj@coefficients[["prox"]])
fscores <- regress(dat=delta, covariates=covariates,
coeff=obj@coefficients[["freq"]])
# Include only within-group best matches.
dscores <- biomrk
if(length(obj@categories$GROUP) > 0) {
res <- merge_groups(pdat=dscores, fdat=fscores,
grouping=obj@categories)
dscores <- res$pdat
fscores <- res$fdat
}
# Find best matches between groups.
topscor <- matrix(0, nrow=nrow(dscores), ncol=4)
matched <- matrix(0, nrow=nrow(dscores), ncol=2)
for(k in 1:nrow(dscores)) {
sorted <- order(dscores[k,], decreasing=TRUE)
topscor[k,1:2] <- dscores[k,sorted[1:2]]
topscor[k,3:4] <- fscores[k,sorted[1:2]]
matched[k,] <- sorted[1:2]
}
# Calculate quality metrics.
x <- (topscor[,1] - topscor[,2])
prox <- cbind(pnorm(topscor[,1]), pnorm(topscor[,2]))
freq <- cbind(pnorm(topscor[,3]), pnorm(topscor[,4]))
excl <- pchisq((x > 0)*(x^2), df=1)
# Convert to data frame.
categ <- colnames(fscores)
output <- data.frame(CATEG=categ[matched[,1]],
MATCH=categ[matched[,1]], MATCH.2nd=categ[matched[,2]],
FREQ=freq[,1], FREQ.2nd=freq[,2],
PROX=prox[,1], PROX.2nd=prox[,2],
EXCL=excl, stringsAsFactors=FALSE)
rownames(output) <- rownames(fscores)
# Check proximity.
prox.min <- obj@parameters["proximity.min"]
unclass <- which(output$PROX < prox.min)
output[unclass,"CATEG"] <- "Unclassified"
# Check exclusivity.
excl.min <- obj@parameters["exclusivity.min"]
ambig <- setdiff(which(output$EXCL < excl.min), unclass)
output[ambig,"CATEG"] <- "Ambiguous"
# Add visual parameters.
output$LABEL <- obj@categories[output$CATEG,"LABEL"]
output$COLOR <- obj@categories[output$CATEG,"COLOR"]
output$COLOR.light <- obj@categories[output$CATEG,"COLOR.light"]
output$COLOR.dark <- obj@categories[output$CATEG,"COLOR.dark"]
# Return results.
attr(output, "biomarkers") <- biomrk
attr(output, "biomarkers.grouped") <- dscores
return(output)
})
# Merge category scores into superscores.
merge_groups <- function(
pdat,
fdat,
grouping) {
# Put member categories together.
grp <- grouping[colnames(pdat),"GROUP"]
grp <- split(x=colnames(pdat), f=grp)
nums <- sapply(grp, length)
# Merge scores within supergroups.
output <- fdat
for(g in grp[which(nums > 1)]) {
p <- pdat[,g,drop=FALSE]
f <- fdat[,g,drop=FALSE]
w <- length(g)/ncol(pdat)
for(k in 1:nrow(p)) {
ind <- which.max(p[k,])
p[k,-ind] <- NA
}
pdat[,g] <- p
fdat[,g] <- ((1 - w)*f + w*p)
}
# Return result.
output <- list()
output$pdat <- pdat
output$fdat <- fdat
return(output)
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/Asset.classify.R |
# Set internal parameters.
setGeneric("configuration<-", function(obj, value)
standardGeneric("configuration<-"))
setMethod("configuration<-", "Asset",
function(
obj,
value) {
# Check if locked.
if(length(obj@centroids) > 0)
stop("Asset is already assembled.")
# Default values.
cfg <- obj@parameters
if(length(cfg) < 1) {
cfg["norm"] <- 1
cfg["nonzero.min"] <- 100
cfg["nonzero.ratio"] <- 0.01
cfg["standard"] <- 1
cfg["logarithm"] <- 1
cfg["ninput.max"] <- 20
cfg["rrinput.max"] <- 0.36
cfg["proximity.min"] <- 0.5
cfg["exclusivity.min"] <- 0.5
}
# Check if unknown parameters.
unkn <- setdiff(names(value), names(cfg))
if(length(unkn) > 0) stop("Unknown parameter.")
# Update values.
prm <- intersect(names(cfg), names(value))
cfg[prm] <- value[prm]
# Check values.
if(sum(!is.finite(cfg)) > 0) stop("Unusable parameter value.")
if(sum(cfg < 0) > 0) stop("Negative parameter value.")
obj@parameters <- cfg
return(obj)
})
# Get internal parameters.
setGeneric("configuration", function(obj)
standardGeneric("configuration"))
setMethod("configuration", "Asset",
function(obj) {
return(obj@parameters)
})
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/Asset.configuration.R |
# Save resources to disk.
setGeneric("export", function(obj, folder)
standardGeneric("export"))
setMethod("export", "Asset",
function(
obj,
folder) {
output <- character()
# Check if ready.
if(length(obj@centroids) < 1) stop("Incomplete asset.")
# Check folder name.
if(!is.character(folder)) stop("Unusable folder name.")
if(!dir.exists(folder)) dir.create(folder[1])
if(!dir.exists(folder)) stop("Folder cannot be used.")
# Save configuration.
fn <- file.path(folder, "configuration.txt")
dat <- data.frame(PARAM=c("title", names(obj@parameters)),
VALUE=c(obj@title, obj@parameters), stringsAsFactors=FALSE)
write.table(dat, file=fn, quote=FALSE, row.names=FALSE, sep="\t")
output[length(output)+1] <- fn
# Save visuals.
fn <- file.path(folder, "categories.txt")
dat <- data.frame(CATEG=rownames(obj@categories),
obj@categories, stringsAsFactors=FALSE)
write.table(dat, file=fn, quote=FALSE, row.names=FALSE, sep="\t")
output[length(output)+1] <- fn
# Save data statistics.
fn <- file.path(folder, "reference.txt")
dat <- data.frame(VAR=rownames(obj@reference),
obj@reference, stringsAsFactors=FALSE)
write.table(dat, file=fn, quote=FALSE,
row.names=FALSE, sep="\t")
output[length(output)+1] <- fn
# Save covariate statistics.
if(length(obj@demographics) > 0) {
fn <- file.path(folder, "covariates.txt")
dat <- obj@demographics
dat <- data.frame(VAR=rownames(dat), dat)
write.table(dat, file=fn, quote=FALSE,
row.names=FALSE, sep="\t")
output[length(output)+1] <- fn
}
# Save nomenclature if available.
if(length(obj@naming) > 0) {
fn <- file.path(folder, "nomenclature.txt")
dat <- data.frame(VAR=rownames(obj@naming),
obj@naming, stringsAsFactors=FALSE)
write.table(dat, file=fn, quote=FALSE,
row.names=FALSE, sep="\t")
output[length(output)+1] <- fn
}
# Save centroids.
fn <- file.path(folder, "centroids.txt")
dat <- data.frame(VAR=rownames(obj@centroids), obj@centroids,
check.names=FALSE, stringsAsFactors=FALSE)
write.table(dat, file=fn, quote=FALSE, row.names=FALSE, sep="\t")
output[length(output)+1] <- fn
# Save regression coefficients.
fn <- file.path(folder, "coefficients.txt")
prox <- obj@coefficients[["prox"]]
prox <- data.frame(CATEG=colnames(prox), MODEL="prox",
t(prox), stringsAsFactors=F)
freq <- obj@coefficients[["freq"]]
freq <- data.frame(CATEG=colnames(freq), MODEL="freq",
t(freq), stringsAsFactors=F)
write.table(rbind(prox, freq), file=fn, quote=FALSE,
row.names=FALSE, sep="\t")
output[length(output)+1] <- fn
return(output)
})
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/Asset.export.R |
# Save resources to disk.
setGeneric("nomenclature<-", function(obj, value)
standardGeneric("nomenclature<-"))
setMethod("nomenclature<-", "Asset",
function(
obj,
value) {
# Check if locked.
if(length(obj@centroids) > 0)
stop("Asset is already assembled.")
# Check input.
if(!is.data.frame(value)) stop("Value must be a data frame.")
if(nrow(value)*ncol(value) < 1) stop("Empty value.")
if(length(rownames(value)) < 1) stop("No row names.")
if(length(colnames(value)) < 1) stop("No column names.")
# Check for duplicates.
for(j in 1:ncol(value)) {
if(anyDuplicated(value[,j]))
stop("Duplicated entries in nomenclature.")
}
# Update object.
obj@naming <- value
return(obj)
})
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/Asset.nomenclature.R |
# Samples in columns, variables in rows.
setGeneric("normalize", function(obj, dat)
standardGeneric("normalize"))
setMethod("normalize", "Asset",
function(
obj,
dat) {
# Make sure data are in a matrix.
output <- makematrix(dat)
if(is.character(output)) stop(output)
# Check if anything to do.
if(obj@parameters["norm"] == 0) return(output)
# Reference profile.
stats <- obj@reference
if(length(stats) < 1) stop("No population reference.")
if(length(stats$VALUE) < 1) stop("No reference profile.")
refvals <- as.double(obj@reference$VALUE)
names(refvals) <- rownames(obj@reference)
# Nomenclature conversion.
if(length(obj@naming) > 0) {
keys <- translate_names(dat=output, naming=obj@naming)
ndiff <- sum(keys != rownames(output))
if(ndiff > 0) {
rownames(output) <- keys
if(ndiff < nrow(output)) {
msg <- paste0("Asset.normalize(): ", ndiff, " / ",
nrow(output), " variables renamed.")
warning(msg, call.=FALSE, immediate.=TRUE)
}
}
}
# Select variables for normalization.
alerts <- character()
vars <- intersect(names(refvals), rownames(output))
if(length(vars) < 1) stop("Incompatible data.")
if(length(vars) < length(refvals)) {
# Expand data matrix to include more variables.
extra <- setdiff(names(refvals), rownames(output))
newdat <- rep(refvals[extra], times=ncol(output))
newdat <- matrix(newdat, nrow=length(extra), ncol=ncol(output))
rownames(newdat) <- extra
colnames(newdat) <- colnames(output)
output <- rbind(output, newdat); newdat <- NULL; gc()
# Warning message.
msg <- paste0("Asset.normalize(): ", length(extra), " / ",
length(refvals), " variables imputed from reference.")
warning(msg, call.=FALSE, immediate.=TRUE)
}
output <- output[names(refvals),,drop=FALSE]
# Median ratio to pseudo-reference for each sample.
med <- apply(output, 2, "/", refvals)
med <- apply(med, 2, median)
med <- pmax(med, 1e-6)
# Remove unusable samples.
mask <- which(!is.finite(med))
if(length(mask) > 0) {
msg <- paste0("Asset.normalize(): ", length(mask), " / ",
length(med), " unusable samples excluded.")
output <- output[,-mask,drop=FALSE]
med <- med[-mask]
warning(msg, call.=FALSE, immediate.=TRUE)
}
# Normalize by median ratio (DESeq2).
for(k in 1:ncol(output))
output[,k] <- (output[,k])/(med[k])
return(output)
})
#---------------------------------------------------------------------------
translate_names <- function(
dat,
naming) {
output <- rownames(dat)
symbols <- rownames(naming)
for(v in colnames(naming)) {
# Find matching keys.
pos <- match(rownames(dat), naming[,v])
mask <- which(pos > 0)
if(length(mask) < 1) next
# Check if any changes.
keys <- rownames(dat)
keys[mask] <- symbols[pos[mask]]
if(sum(keys != rownames(dat)) < 1) next
# Update output.
output[mask] <- keys[mask]
}
return(output)
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/Asset.normalize.R |
# Samples in columns, variables in rows.
setGeneric("standardize", function(obj, dat, trim=FALSE)
standardGeneric("standardize"))
setMethod("standardize", "Asset",
function(
obj,
dat,
trim=FALSE) {
# Make sure data are in a matrix.
output <- makematrix(dat)
if(is.character(output)) stop(output)
# Check if anything to do.
if(obj@parameters["standard"] == 0) return(output)
# Reference profile.
stats <- obj@reference
if(length(stats) < 1) stop("No population reference.")
if(length(stats$MEAN) < 1) stop("No population statistics.")
if(length(stats$SD) < 1) stop("No population statistics.")
# Select variables.
vars <- intersect(rownames(stats), rownames(output))
if(trim && (length(obj@centroids) > 0))
vars <- intersect(rownames(obj@centroids), vars)
if(length(vars) < 1) stop("Incompatible data.")
output <- output[vars,,drop=FALSE]
stats <- stats[vars,,drop=FALSE]
# Logarithm.
if(obj@parameters["logarithm"]) output <- log2(output + 1)
# Impute missing values.
nimput <- 0
for(k in 1:ncol(output)) {
mask <- which(!is.finite(output[,k]))
if(length(mask) > 0) output[mask,k] <- stats$MEAN[mask]
nimput <- (nimput + length(mask))
}
if(nimput > 0) {
msg <- paste0("Asset.standardize(): ", nimput,
" / ", nrow(output)*ncol(output), " values imputed.")
warning(msg, call.=FALSE, immediate.=TRUE)
}
# Center and scale with tapering by t-distribution.
if(obj@parameters["standard"]) {
e <- .Machine$double.eps
for(k in 1:ncol(output)) {
x <- (output[,k] - stats$MEAN)/(stats$SD + e)
x <- pmax(pt(x, df=20), e)
x <- pmin(x, (1 - e))
output[,k] <- 1.047*qnorm(x)
}
}
# Check variances.
n <- sum(apply(output, 1, sd) > 0)
if(n < nrow(output)) {
msg <- paste0("Asset.standardize(): ", n,
" / ", nrow(output), " usable variables.")
warning(msg, call.=FALSE, immediate.=TRUE)
}
return(output)
}) | /scratch/gouwar.j/cran-all/cranData/Allspice/R/Asset.standardize.R |
setGeneric("visuals<-", function(obj, value)
standardGeneric("visuals<-"))
setMethod("visuals<-", "Asset",
function(
obj,
value) {
# Check if locked.
if(length(obj@centroids) > 0)
stop("Asset is already assembled.")
# Check input.
if(is.character(value)) {
vnames <- names(value)
value <- data.frame(LABEL=value)
if(length(vnames) > 0) rownames(value) <- vnames
else rownames(value) <- value$LABEL
}
if(!is.data.frame(value)) stop("Unusable value.")
if(nrow(value)*ncol(value) < 1) stop("Empty value.")
if(length(rownames(value)) < 1) stop("No row names.")
if(length(value$LABEL) < 1) stop("No labels.")
# Default visuals.
categ <- list(LABEL=as.character(value$LABEL))
if(length(value$COLOR) > 0) categ$COLOR <- value$COLOR
else categ$COLOR <- colormap(1:nrow(value))
if(length(value$COLOR.light) > 0) categ$COLOR.light <- value$COLOR.light
else categ$COLOR.light <- colormap(1:nrow(value), adjustment="light")
if(length(value$COLOR.dark) > 0) categ$COLOR.dark <- value$COLOR.dark
else categ$COLOR.dark <- colormap(1:nrow(value), adjustment="dark")
# Add reserved categories.
vnames <- rownames(value)
if(sum(vnames == "Unclassified") < 1) {
categ$LABEL <- c(categ$LABEL, "Unclassified")
categ$COLOR <- c(categ$COLOR, "#888888")
categ$COLOR.light <- c(categ$COLOR.light, "#b0b0b0")
categ$COLOR.dark <- c(categ$COLOR.dark, "#404040")
vnames <- c(vnames, "Unclassified")
}
if(sum(vnames == "Ambiguous") < 1) {
categ$LABEL <- c(categ$LABEL, "Ambiguous")
categ$COLOR <- c(categ$COLOR, "#888888")
categ$COLOR.light <- c(categ$COLOR.light, "#b0b0b0")
categ$COLOR.dark <- c(categ$COLOR.dark, "#404040")
vnames <- c(vnames, "Ambiguous")
}
# Convert to data frame.
categ <- data.frame(categ, stringsAsFactors=FALSE)
rownames(categ) <- vnames
# Update object.
obj@categories <- categ
return(obj)
}) | /scratch/gouwar.j/cran-all/cranData/Allspice/R/Asset.visuals.R |
# Class definition.
setClass("Classifier",
representation(
assets="list", # classification pipeline
covardat="matrix", # covariates
results="list"))
# Create classifier from disk asset.
classifier <- function(
...,
verbose=TRUE) {
# New Classifier object.
output <- new("Classifier")
output@covardat <- matrix(nrow=0, ncol=0)
folders <- list(...)
# Assets for B-cell acute lymphoblast leukemia.
if(length(folders) < 1) {
basepath <- system.file(package="Allspice")
folders[["subtypes"]] <- file.path(basepath, "subtypes")
folders[["drivers"]] <- file.path(basepath, "drivers")
folders[["tissues"]] <- file.path(basepath, "tissues")
}
# Import assets.
if(anyDuplicated(folders) > 0) stop("Duplicated inputs.")
for(f in folders) {
fpath <- as.character(f)
if(!dir.exists(fpath)) stop("Folder does not exist.")
output@assets[[fpath]] <- asset(fpath, verbose=verbose)
}
return(output)
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/Classifier.R |
# Set covariates.
setGeneric("covariates<-", function(obj, value)
standardGeneric("covariates<-"))
setMethod("covariates<-", "Classifier",
function(
obj,
value) {
# Check input.
dat <- makematrix(value)
if(is.character(dat)) stop(dat)
# Check that row and column names are distinct.
ovl <- intersect(rownames(dat), colnames(dat))
if(length(ovl) > 0) stop("Row and column names overlap.")
# Collect modelled covariates.
vars <- character()
for(a in obj@assets) {
if(length(a@demographics) > 0) {
prox <- a@coefficients[["prox"]]
vars <- c(vars, rownames(prox))
}
}
# Select columns.
if(length(vars) < 1) {
msg <- paste0("Classifier.covariates(): No covariates modelled.")
warning(msg, call.=FALSE, immediate.=TRUE)
}
else {
# Check if covariates need to be transposed.
cnames <- intersect(vars, colnames(dat))
if(length(cnames) < 1) dat <- t(dat)
# Update object.
vars <- intersect(vars, colnames(dat))
if(length(vars) < 1) stop("Incompatible covariates.")
obj@covardat <- dat[,vars,drop=FALSE]
}
return(obj)
})
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/Classifier.covariates.R |
# Return useful information about assets.
setGeneric("information", function(obj)
standardGeneric("information"))
setMethod("information", "Classifier",
function(obj) {
# Check if any contents.
if(length(obj@assets) < 1) stop("Empty classifier.")
# Collect modelled covariates.
assnames <- names(obj@assets)
covars <- list(ASSET=integer(), TITLE=character(),
COVAR=character(), SOURCE=character())
for(k in 1:length(assnames)) {
a <- obj@assets[[k]]
if(length(a@demographics) > 0) {
beta <- a@coefficients[["prox"]]
vars <- setdiff(rownames(beta), c("B0","B1"))
covars$ASSET <- c(covars$ASSET, rep(k, length(vars)))
covars$TITLE <- c(covars$TITLE, rep(a@title, length(vars)))
covars$COVAR <- c(covars$COVAR, vars)
covars$SOURCE <- c(covars$SOURCE, rep(assnames[k], length(vars)))
}
else {
covars$ASSET <- c(covars$ASSET, k)
covars$TITLE <- c(covars$TITLE, a@title)
covars$COVAR <- c(covars$COVAR, NA)
covars$SOURCE <- c(covars$SOURCE, assnames[k])
}
}
covars <- data.frame(covars, stringsAsFactors=FALSE)
# Collect configuration parameters.
config <- NULL; titles <- character()
for(k in 1:length(assnames)) {
a <- obj@assets[[k]]
if(length(config) < 1) {
config <- a@parameters
}
else {
config <- rbind(config, a@parameters)
colnames(config) <- names(a@parameters)
}
titles[k] <- a@title
}
config <- data.frame(ASSET=(1:length(assnames)),
TITLE=titles, config, SOURCE=assnames,
stringsAsFactors=FALSE)
rownames(config) <- NULL
# Collect category labels.
categ <- NULL
for(k in 1:length(assnames)) {
a <- obj@assets[[k]]
dat <- a@categories
dat <- data.frame(stringsAsFactors=FALSE,
ASSET=rep(k, nrow(dat)),
TITLE=rep(a@title, nrow(dat)),
CATEG=rownames(a@categories), a@categories,
SOURCE=rep(assnames[k], nrow(dat)))
rownames(dat) <- NULL
if(length(categ) < 1) {
categ <- dat
}
else {
vars <- intersect(colnames(categ), colnames(dat))
categ <- rbind(categ[,vars,drop=F], dat[,vars,drop=F])
}
}
# Return results.
output <- list()
output$covariates <- covars
output$configuration <- config
output$categories <- categ
return(output)
})
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/Classifier.information.R |
# Predicted category labels.
setGeneric("predictions", function(obj)
standardGeneric("predictions"))
setMethod("predictions", "Classifier", function(obj) {
output <- NULL
# Check if results are available.
if(length(obj@results) < 1) stop("No profiles.")
# Strip any extra attributes from data frames.
output <- list()
for(r in names(obj@results)) {
output[[r]] <- data.frame(obj@results[[r]],
stringsAsFactors=FALSE)
}
return(output)
})
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/Classifier.predictions.R |
# Set RNA profiles.
setGeneric("profiles<-", function(obj, value)
standardGeneric("profiles<-"))
setMethod("profiles<-", "Classifier",
function(
obj,
value) {
# Make sure data are in a matrix.
dat <- makematrix(value)
if(is.character(dat)) stop(dat)
# Classify samples.
ok <- TRUE
for(a in names(obj@assets)) {
ass <- obj@assets[[a]]
# Set default covariates.
covars <- NULL
if(length(ass@demographics) > 0) {
stats <- ass@demographics
covars <- matrix(NA, nrow=ncol(dat), ncol=nrow(stats))
rownames(covars) <- colnames(dat)
colnames(covars) <- rownames(stats)
for(j in 1:ncol(covars))
covars[,j] <- stats$MEAN[j]
# Replace default covariates with available values.
ntotal <- 0
keys <- intersect(rownames(obj@covardat), rownames(covars))
vars <- intersect(colnames(obj@covardat), colnames(covars))
for(v in vars) {
x <- obj@covardat[keys,v]
mask <- which(is.finite(x))
covars[keys[mask],v] <- x[mask]
ntotal <- (ntotal + length(mask))
}
# Check if all values were available.
if(ntotal < nrow(covars)*ncol(covars)) ok <- FALSE
}
# Assign categories.
obj@results[[a]] <- classify(ass, dat=dat, covariates=covars)
}
# Check for incomplete covariates.
if(!ok) warning("Classifier.profiles(): Incomplete covariates.",
call.=FALSE, immediate.=TRUE)
return(obj)
})
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/Classifier.profiles.R |
# Predicted category labels.
setGeneric("report", function(obj, name, file=NULL)
standardGeneric("report"))
setMethod("report", "Classifier",
function(
obj,
name,
file=NULL) {
# Check if any results.
if(length(obj@results) < 1) stop("No profiles.")
# Check sample name.
if(is.numeric(name)) {
name <- round(name)[1]
keys <- rownames(obj@results[[1]])
if(!is.finite(name)) stop("Unusable name.")
if(name < 1) stop("Unusable name.")
if(name > length(keys)) stop("Unusable name.")
name <- keys[name]
}
if(!is.character(name)) stop("Unusable name.")
if(length(name) < 1) stop("Unusable name.")
name <- as.character(name)[1]
# Check file name.
if(length(file) > 0) {
if(!is.character(file)) stop("Unusable file name.")
file <- as.character(file[1])
}
# Visualize classification results.
for(j in 1:length(obj@results)) {
res <- report_bars(fname=file, key=name, column=j,
assets=obj@assets, results=obj@results)
if(is.character(res)) stop(res)
}
# Return file name.
invisible(file)
})
#---------------------------------------------------------------------------
report_bars <- function(
fname,
key,
results,
assets,
column,
block=9,
capacity=18) {
# Find prediction.
pred <- results[[column]]
ind <- which(rownames(pred) == key)
if(length(ind) < 1) return("Unknown name.")
output <- pred[key,,drop=FALSE]
# Set canvas size.
primary <- assets[[1]]
nrows <- max(ncol(primary@centroids), capacity)
ncols <- length(results)
xcanvas <- c(0.5, (block*max(ncols, 2) + 3))
ycanvas <- c(0.5, (nrows + 3.2))
wcanvas <- (xcanvas[2] - xcanvas[1])
hcanvas <- (ycanvas[2] - ycanvas[1])
# Set up figure.
if(column == 1) {
if(length(fname) > 0)
svg(filename=fname, width=0.3*wcanvas, height=0.3*hcanvas)
# Set canvas parameters.
prev <- par(pty="m", oma=c(0,0,0,0), mar=c(0,0,0,0))
on.exit(par(prev))
# Prepare plot area.
plot(bty="n", axes=FALSE, asp=(length(fname) > 0),
x=NA, y=NA, xlim=xcanvas, ylim=ycanvas,
xlab=NA, ylab=NA, main=NA)
# Sample name.
text(x=xcanvas[1], y=(ycanvas[2] - 0.55),
labels=key, pos=4, cex=1.2, col="#303030")
# Best matching category and frequency.
clabel <- output$LABEL
best <- primary@categories[output$MATCH,"LABEL"]
if(clabel == best)
clabel <- paste(clabel, percent_label(output$FREQ))
# Category label.
colr <- output$COLOR.dark
text(x=xcanvas[1], y=(ycanvas[2] - 1.38),
labels=clabel, pos=4, cex=1.0, col=colr, font=2)
# Proximity.
proxmin <- primary@parameters["proximity.min"]
if(output$PROX < proxmin) {
txt <- sprintf("Proximity: %s", percent_label(output$PROX))
txt <- sprintf("%s < %.0f%%", txt, 100*proxmin)
text(x=(xcanvas[1] + block), y=(ycanvas[2] - 0.55),
labels=txt, pos=4, cex=1.0, col="#000000")
}
# Exclusivity.
exclmin <- primary@parameters["proximity.min"]
if(output$EXCL < exclmin) {
txt <- sprintf("Exclusivity: %s", percent_label(output$EXCL))
txt <- sprintf("%s < %.0f%%", txt, 100*exclmin)
text(x=(xcanvas[1] + block), y=(ycanvas[2] - 1.38),
labels=txt, pos=4, cex=1.0, col="#000000")
}
}
# Title for category score.
ass <- assets[[column]]
xdiv <- (xcanvas[1] + (column - 0.5)*block + 1.5)
if(column == 1) {
text(x=xdiv, y=(nrows + 0.4), labels=ass@title,
pos=3, cex=1.0, font=2, col="#000000")
}
else {
text(x=xdiv, y=(nrows + 0.4), labels=ass@title,
pos=3, cex=1.0, col="#606060")
}
# Sort entries by biomarker value.
biomrk <- attr(pred, "biomarkers.grouped")
mask <- order(biomrk[key,], decreasing=TRUE)
bnames <- colnames(biomrk)[mask]
# Exclude duplicated labels.
visuals <- ass@categories
mask <- which(duplicated(visuals[bnames,"LABEL"]) == FALSE)
if(length(mask) > nrows) mask <- mask[1:nrows]
bnames <- bnames[mask]
# Sort entries alphabetically.
mask <- order(visuals[bnames,"LABEL"])
bnames <- bnames[mask]
# Category labels.
labels <- visuals[bnames,"LABEL"]
ydivs <- (nrows:1); ydivs <- ydivs[1:length(labels)]
text(x=xdiv, y=ydivs, labels=labels,
pos=2, cex=1.0, col="#000000")
# Set colors.
fills <- rep("#a0a0a0", length.out=length(labels))
strokes <- rep("#505050", length.out=length(labels))
if(column == 1) {
fills <- visuals[bnames,"COLOR"]
strokes <- visuals[bnames,"COLOR.dark"]
}
# Category scores.
bvals <- biomrk[key,bnames]
dx <- bvals/max(max(bvals), 3)
dx <- pmax(dx, 0.03)*(block - 5)
rect(xleft=xdiv, ybottom=(ydivs - 0.35),
xright=(xdiv + dx), ytop=(ydivs + 0.48),
border=NA, col=fills)
# Save figure.
if((length(fname) > 0) && (column == length(results))) dev.off()
return(NULL)
}
#---------------------------------------------------------------------------
percent_label <- function(x) {
if(x < 0.01) return("<1%")
if(x > 0.99) return(">99%")
return(sprintf("%.0f%%", 100*x))
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/Classifier.report.R |
# Predicted category labels.
setGeneric("scores", function(obj)
standardGeneric("scores"))
setMethod("scores", "Classifier", function(obj) {
output <- NULL
# Check if results are available.
if(length(obj@results) < 1) stop("No profiles.")
# Collect biomarker scores.
output <- list()
for(r in names(obj@results))
output[[r]] <- attr(obj@results[[r]], "biomarkers")
return(output)
})
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/Classifier.scores.R |
bcellALL <- function(
n=200,
contamination=0.05) {
# Check input.
if(!is.numeric(n)) stop("Unusable input.")
if(!is.finite(n)) stop("Unusable input.")
if(n < 1) stop("Unusable input.")
# Check input.
if(!is.numeric(contamination)) stop("Unusable input.")
if(!is.finite(contamination)) stop("Unusable input.")
if(contamination >= 1) stop("Unusable input.")
# Import expression statistics.
base <- system.file(package="Allspice")
fn <- file.path(base, "simulation", "statistics.txt")
stats <- read.delim(fn, stringsAsFactors=FALSE)
rownames(stats) <- stats$VAR; stats$VAR <- NULL
# Import subgroup centroids.
base <- system.file(package="Allspice")
fn <- file.path(base, "simulation", "centroids.txt")
cents <- read.delim(fn, stringsAsFactors=FALSE)
rownames(cents) <- cents$VAR; cents$VAR <- NULL
# Import subgroup demographics.
base <- system.file(package="Allspice")
fn <- file.path(base, "simulation", "covariates.txt")
covars <- read.delim(fn, stringsAsFactors=FALSE)
rownames(covars) <- covars$VAR; covars$VAR <- NULL
# Pick subtype labels.
catnames <- sample(colnames(covars), size=n, prob=covars["N",],
replace=(n > ncol(covars)))
# Reference stats.
mu0 <- log2(stats$MEDIAN + 1)
sigma0 <- (log2(stats$Q691 + 1) - log2(stats$Q309 + 1))
# Set up profile matrix.
profs <- matrix(NA, nrow=nrow(cents), ncol=n)
rownames(profs) <- rownames(cents)
colnames(profs) <- paste0("patient", 1:n)
# Simulate subtype profiles.
for(k in 1:n) {
mu <- log2(cents[,catnames[k]] + 1)
x <- rnorm(length(mu), mean=mu, sd=0.5*sigma0)
profs[,k] <- pmax(round(2^x - 1), 0)
}
# Trim extreme values.
f <- sqrt(n)*sqrt(nrow(profs))
q <- -quantile(as.vector(-profs), 1/f)
for(j in 1:ncol(profs)) profs[,j] <- pmin(profs[,j], q)
# Simulate covariates.
meta <- data.frame(stringsAsFactors=FALSE,
MALE=as.integer(runif(n) < covars["MALE",catnames]),
AGE=as.integer(0.5*covars["AGE",catnames] + runif(n)*40),
SUBTYPE=catnames)
rownames(meta) <- colnames(profs)
# Perturb a proportion of profiles.
nfail <- floor(contamination*n)
if(nfail > 0) {
mask <- sample.int(n, nfail)
for(k in mask) {
profs[,k] <- sample(profs[,k])
meta[k,"SUBTYPE"] <- "Contaminated"
}
}
# Return results.
output <- list()
output$counts <- profs
output$metadata <- meta
return(output)
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/bcellALL.R |
analyze <- function(
dat,
bits,
covariates=NULL,
balance=FALSE) {
# Check covariates.
covnames <- NULL
if(length(covariates) > 0) {
keys <- intersect(rownames(dat), rownames(covariates))
if(length(keys) < nrow(dat)) return("Incompatible covariates.")
covariates <- covariates[rownames(dat),]
# Check reserved variable names.
reserved <- c("X","Y","B0","B1","MODEL")
if(anyDuplicated(colnames(covariates)) > 0)
return("Duplicated covariates.")
if(anyDuplicated(c(colnames(covariates), reserved)) > 0)
return("Reserved covariate names.")
covnames <- colnames(covariates)
}
# Check classification.
keys <- intersect(rownames(dat), rownames(bits))
if(length(keys) < nrow(dat)) return("Incompatible bits.")
bits <- bits[rownames(dat),]
# Regression models.
output <- list()
for(v in colnames(dat)) {
output[[v]] <- analyze_glm(xdat=dat[,v],
ydat=bits[,v], cdat=covariates, balance=balance)
}
# Set row and column names.
output <- data.frame(output, stringsAsFactors=FALSE)
rownames(output) <- c("B0", "B1", covnames)
colnames(output) <- colnames(dat)
# Convert to matrix.
output <- makematrix(output)
return(output)
}
#---------------------------------------------------------------------------
analyze_glm <- function(
xdat,
ydat,
cdat=NULL,
fam=binomial("probit"),
balance=FALSE) {
# Set up training data.
ds <- data.frame(X=xdat, Y=ydat)
if(length(cdat) > 0) ds <- data.frame(ds, cdat)
# Add extra samples for numerical stability.
mx <- mean(ds$X)
xtra <- data.frame(Y=c(0,1), X=c(mx,mx))
if(length(cdat) > 0) {
mc <- colMeans(cdat)
xtra <- data.frame(xtra, rbind(mc, mc))
}
ds <- rbind(ds, xtra)
# Fit model.
model <- list()
if(balance) {
n0 <- mean(ds$Y == 0)
n1 <- mean(ds$Y == 1)
w <- (n0*(ds$Y == 1) + n1*(ds$Y == 0))
suppressWarnings(
model <- glm(formula=Y~., data=ds, weights=w, family=fam))
}
else {
suppressWarnings(
model <- glm(formula=Y~., data=ds, family=fam))
}
return(model$coefficients)
} | /scratch/gouwar.j/cran-all/cranData/Allspice/R/local.analyze.R |
colormap <- function(
dat,
range=NULL,
adjustment=NULL) {
# Value range.
if(length(range) < 2)
range <- c(min(dat, na.rm=TRUE), max(dat, na.rm=TRUE))
# Matrix of pivot colors.
mtx <- matrix(NA, 0, 0)
mtx.points <- double()
# Single color or balanced rainbow.
if(diff(range) == 0) {
mtx <- matrix(NA, nrow=3, ncol=3)
mtx[1,] <- c(100, 100, 100)/255
mtx[2,] <- c(100, 100, 100)/255
mtx[3,] <- c(100, 100, 100)/255
mtx.points <- (0:2)/2
} else {
mtx <- matrix(NA, nrow=7, ncol=3)
mtx[1,] <- c(255, 71, 189)/255
mtx[2,] <- c(255, 65, 50)/255
mtx[3,] <- c(255, 126, 25)/255
mtx[4,] <- c(215, 210, 0)/255
mtx[5,] <- c( 70, 240, 45)/255
mtx[6,] <- c( 10, 190, 213)/255
mtx[7,] <- c( 35, 130, 255)/255
mtx.points <- (0:6)/6
}
# Brightness adjustment.
if(length(adjustment) < 1) adjustment <- ""
if(adjustment == "light") {
mtx <- (1 - 0.97*(1 - mtx)^(1.5))
}
if(adjustment == "dark") {
bright <- (0.3*(mtx[,1]) + 0.5*(mtx[,2]) + 0.1*(mtx[,3]))
mtx[,1] <- (1 - 0.2*bright)*((mtx[,1])^(1.5))
mtx[,2] <- (1 - 0.3*bright)*((mtx[,2])^(1.5))
mtx[,3] <- (1 - 0.2*bright)*((mtx[,3])^(1.5))
}
# Make sure colors are usable.
mtx <- apply(mtx, 2, function(x) {
x <- pmax(x, 0.0, na.rm=TRUE)
x <- pmin(x, 1.0, na.rm=TRUE)
return(x)
})
# Find usable data values.
hues <- (dat - range[1])
if(diff(range) != 0) hues <- hues/(range[2] - range[1])
hues <- pmin(pmax(hues, 0.0), 1.0)
# Interpolate color components.
mask <- which(is.finite(hues))
comps <- matrix(0.5, nrow=length(dat), ncol=4)
rownames(comps) <- seq(from=range[1], to=range[2], length.out=length(dat))
colnames(comps) <- c("RED", "GREEN", "BLUE", "ALPHA")
comps[mask,1] <- approx(x=mtx.points, y=mtx[,1], xout=hues[mask])$y
comps[mask,2] <- approx(x=mtx.points, y=mtx[,2], xout=hues[mask])$y
comps[mask,3] <- approx(x=mtx.points, y=mtx[,3], xout=hues[mask])$y
comps[mask,4] <- 1.0
# Create colors.
output <- rgb(red=comps[,"RED"], green=comps[,"GREEN"],
blue=comps[,"BLUE"], alpha=comps[,"ALPHA"])
names(output) <- names(dat)
attr(output, "components") <- comps
return(output)
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/local.colormap.R |
# Samples in columns, variables in rows.
distances <- function(
dat,
centroids,
closest=FALSE) {
# Select inputs.
vars <- intersect(rownames(centroids), rownames(dat))
if(length(vars) < nrow(centroids)) return("Incompatible data.")
else dat <- dat[rownames(centroids),,drop=FALSE]
# Calculate Euclidean distances.
delta <- apply(dat, 2, function(x, centroids) {
d <- colMeans((centroids - x)^2)
return(sqrt(d))
}, centroids=centroids)
colnames(delta) <- colnames(dat)
# Return the closest matches.
if(closest) {
ind <- apply(delta, 2, which.min)
delta <- apply(delta, 2, min)
output <- data.frame(MATCH=colnames(centroids)[ind],
D=delta, stringsAsFactors=FALSE)
rownames(output) <- colnames(dat)
return(output)
}
# Return all distances.
return(t(delta))
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/local.distances.R |
makematrix <- function(
dat,
finite=FALSE) {
# Check if numeric.
if(length(dat) < 1) return("Empty data.")
if(is.logical(dat)) dat <- (dat + 0)
if(is.vector(dat) && is.numeric(dat)) {
dat <- as.matrix(dat)
colnames(dat) <- "(empty)"
}
if(is.data.frame(dat)) {
for(j in 1:ncol(dat))
suppressWarnings(dat[,j] <- as.numeric(dat[,j]))
dat <- as.matrix(dat)
}
# Check if usable.
if(!is.matrix(dat)) return("Unusable matrix.")
if(!is.numeric(dat)) return("Non-numeric matrix.")
if(ncol(dat)*nrow(dat) < 1) return("Empty matrix.")
if(length(rownames(dat)) < 1) return("No row names.")
if(length(colnames(dat)) < 1) return("No column names.")
rownames(dat) <- as.character(rownames(dat))
colnames(dat) <- as.character(colnames(dat))
# Check for missing values.
if(finite) {
for(j in 1:ncol(dat)) {
if(sum(is.finite(dat[,j])) < nrow(dat))
return("Unusable values.")
}
}
return(dat)
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/local.makematrix.R |
# Samples in columns, variables in rows.
prune <- function(
dat,
bits,
nmax,
rrmax) {
# Make sure data are in a matrix.
dat <- makematrix(dat)
if(is.character(dat)) return(dat)
# Make sure bitmap is a matrix.
bits <- makematrix(bits)
if(is.character(bits)) return(bits)
# Check inputs.
keys <- intersect(colnames(dat), rownames(bits))
if(length(keys) < ncol(dat)) return("Incompatible bits.")
bits <- bits[colnames(dat),,drop=FALSE]
nmax <- min(c(nmax, nrow(dat)))
# Check if anything to do.
if(nrow(dat) <= nmax) return(dat)
# Welch t statistic converted into Z-scores.
z <- matrix(0, nrow=nrow(dat), ncol=ncol(bits))
rownames(z) <- rownames(dat)
colnames(z) <- colnames(bits)
for(v in colnames(bits)) {
contr <- which(bits[,v] == 0)
cases <- which(bits[,v] == 1)
n0 <- length(contr)
n1 <- length(cases)
if((n1 >= 2) && (n0 >= 2)) {
x0 <- dat[,contr]
x1 <- dat[,cases]
mu0 <- rowMeans(x0)
mu1 <- rowMeans(x1)
sigma0 <- rowMeans(x0^2)
sigma1 <- rowMeans(x1^2)
sigma0 <- (sigma0 - mu0*mu0)
sigma1 <- (sigma1 - mu1*mu1)
sigma0 <- pmax(sigma0, 1e-9)
sigma1 <- pmax(sigma1, 1e-9)
sq0 <- sigma0*sigma0/n0
sq1 <- sigma1*sigma1/n1
x <- (mu1 - mu0)/sqrt(sq1 + sq0)
p <- 2*pt(q=-abs(x), df=n1)
p <- pmin(p, (1 - 1e-9), na.rm=TRUE)
p <- pmax(p, 1e-99, na.rm=TRUE)
z[,v] <- sign(x)*abs(qnorm(p=p))
}
}
# Standardize to remove differences in category sizes.
for(j in 1:ncol(z)) {
mu <- mean(z[,j], na.rm=TRUE)
sigma <- sd(z[,j], na.rm=TRUE)
z[,j] <- (z[,j] - mu)/(sigma + 1e-9)
}
# Aggregate scores.
scores <- apply(z, 1, sd, na.rm=TRUE)
scores <- sort(scores, decreasing=TRUE)
# Select non-redundant variables.
starter <- names(scores[1])
output <- matrix(dat[starter,], nrow=ncol(dat), ncol=1)
rownames(output) <- colnames(dat)
colnames(output) <- starter
for(g in names(scores)) {
if(ncol(output) >= nmax) break
cc <- 0 # looping is slow but stops early
for(j in 1:ncol(output)) {
cc <- cor(output[,j], dat[g,])
if(cc^2 >= rrmax) break
}
if(cc^2 < rrmax) {
cnames <- colnames(output)
output <- cbind(output, dat[g,])
colnames(output) <- c(cnames, g)
}
}
# Return results.
output <- t(output)
attr(output, "scores") <- scores
return(output)
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/local.prune.R |
reference <- function(
dat,
cfg) {
# Make sure data are in a matrix.
dat <- makematrix(dat)
if(is.character(dat)) return(dat)
# Frequencies of non-zero values per variable across samples.
fcutoff <- (cfg["nonzero.ratio"])*ncol(dat)
freq <- apply((dat >= cfg["nonzero.min"]), 1, sum, na.rm=TRUE)
# Remove variables with low or sparse expression.
dat <- dat[which(freq >= fcutoff),,drop=FALSE]
# Apply logarithm.
if(cfg["logarithm"]) dat <- log2(dat + 1)
# Mean for each variable across samples.
refvals <- rowMeans(dat, na.rm=TRUE)
names(refvals) <- rownames(dat)
# Undo logarithm for reference values.
if(cfg["logarithm"]) refvals <- (2^refvals - 1)
# Robust descriptive statistics.
mu <- apply(dat, 1, mean, trim=0.01)
mom2 <- apply(dat^2, 1, mean, trim=0.01)
sigma <- sqrt(pmax((mom2 - mu^2), 0))
# Collect statistics.
output <- data.frame(VALUE=refvals, MEAN=mu,
SD=sigma, stringsAsFactors=FALSE)
rownames(output) <- rownames(dat)
# Exclude unsusable variables.
mask <- which(output$SD > 0)
if(length(mask) < nrow(output))
output <- output[mask,,drop=FALSE]
return(output)
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/local.reference.R |
regress <- function(
dat,
coeff,
covariates=NULL,
intercept="B0",
variable="B1") {
# Check data.
output <- makematrix(dat)
if(is.character(output)) stop(output)
# No covariates.
if(length(covariates) < 1) {
ds <- matrix(1, nrow=nrow(output), ncol=nrow(coeff))
colnames(ds) <- rownames(coeff)
for(v in colnames(output)) {
ds[,variable] <- output[,v]
b <- coeff[,v,drop=FALSE]
output[,v] <- (ds %*% b)
}
return(output)
}
# Check covariates.
covariates <- makematrix(covariates)
if(is.character(covariates)) stop(covariates)
# Prepare regressors.
vars <- intersect(rownames(coeff), colnames(covariates))
covariates <- covariates[,vars,drop=FALSE]
coeff <- coeff[c(intercept,variable,vars),]
ds <- data.frame(B0=rep(1, nrow(dat)), B1=NA, covariates)
ds <- as.matrix(ds)
# Calculate scores.
for(v in colnames(output)) {
ds[,"B1"] <- output[,v]
b <- coeff[,v,drop=FALSE]
output[,v] <- (ds %*% b)
}
return(output)
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/local.regress.R |
statistics <- function(
dat,
bits) {
# Make sure data are in a matrix.
dat <- makematrix(dat)
bits <- makematrix(bits)
if(is.character(dat)) return(dat)
if(is.character(bits)) return(bits)
# Calculate subgroup statistics.
output <- list()
for(v in colnames(bits)) {
mask <- which(bits[,v] == 1)
x <- dat[mask,,drop=FALSE]
stats <- data.frame(stringsAsFactors=FALSE,
CATEG=rep(v, ncol(x)),
N=apply(is.finite(x), 2, sum),
MEAN=apply(x, 2, mean, na.rm=TRUE),
SD=apply(x, 2, sd, na.rm=TRUE),
MIN=apply(x, 2, min, na.rm=TRUE),
MAX=apply(x, 2, max, na.rm=TRUE))
rownames(stats) <- colnames(dat)
output[[v]] <- stats
}
# Calculate total statistics.
totals <- data.frame(stringsAsFactors=FALSE,
N=apply(is.finite(dat), 2, sum),
MEAN=apply(dat, 2, mean, na.rm=TRUE),
SD=apply(dat, 2, sd, na.rm=TRUE),
MIN=apply(dat, 2, min, na.rm=TRUE),
MAX=apply(dat, 2, max, na.rm=TRUE))
rownames(totals) <- colnames(dat)
# Return results.
attr(output, "total") <- totals
return(output)
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/local.statistics.R |
summarize <- function(
dat,
bits) {
# Make sure data are in a matrix.
dat <- makematrix(dat)
if(is.character(dat)) return(dat)
# Make sure bitmap is a matrix.
bits <- makematrix(bits)
if(is.character(bits)) return(bits)
# Check reserved categories.
if(anyDuplicated(colnames(bits)) > 0)
return("Duplicated category labels.")
if(anyDuplicated(c(colnames(bits), "Unclassified")) > 0)
return("Category cannot be named 'Unclassified'.")
if(anyDuplicated(c(colnames(bits), "Ambiguous")) > 0)
return("Category cannot be named 'Ambiguous'.")
if(anyDuplicated(c(colnames(bits), "VAR")) > 0)
return("Category cannot be named 'VAR'.")
# Exclude unusable categories.
freq <- colSums(bits == 1)
cols <- which(freq >= 2)
if(length(cols) < 1) return("Unusable category data.")
bits <- bits[,cols,drop=FALSE]
# Calculate subset centroids.
output <- matrix(NA, nrow=nrow(dat), ncol=ncol(bits))
rownames(output) <- rownames(dat)
colnames(output) <- colnames(bits)
for(cname in colnames(bits)) {
mask <- which(bits[,cname] == 1)
output[,cname] <- rowMeans(dat[,mask,drop=FALSE])
}
return(output)
}
| /scratch/gouwar.j/cran-all/cranData/Allspice/R/local.summarize.R |
translate <- function(
dat,
naming) {
# Check if anything to do.
output <- rownames(dat)
if(length(naming) < 1) return(output)
# Translate row names.
symbols <- rownames(naming)
for(v in colnames(naming)) {
# Find matching keys.
pos <- match(rownames(dat), naming[,v])
mask <- which(pos > 0)
if(length(mask) < 1) next
# Check if any changes.
keys <- rownames(dat)
keys[mask] <- symbols[pos[mask]]
if(sum(keys != rownames(dat)) < 1) next
# Update output.
output[mask] <- keys[mask]
}
return(output)
} | /scratch/gouwar.j/cran-all/cranData/Allspice/R/local.translate.R |
## ----echo=FALSE, results="hide"-----------------------------------------------
opt <- options(digits=3)
set.seed(1)
## ----eval=FALSE---------------------------------------------------------------
# # Install the package from a remote repository.
# install.packages("Allspice")
## -----------------------------------------------------------------------------
# Activate the library.
library("Allspice")
packageVersion("Allspice")
ls("package:Allspice")
## ----eval=FALSE---------------------------------------------------------------
# # Access function documentation (not shown in vignette).
# ? Allspice::classifier
## ----eval=FALSE---------------------------------------------------------------
# # Run all code examples (not shown in vignette).
# fn <- system.file("examples.R", package = "Allspice")
# source(fn)
## -----------------------------------------------------------------------------
# Generate gene RNA read counts.
simu <- bcellALL(300)
print(simu$counts[1:5,1:6])
print(simu$metadata[1:6,])
## -----------------------------------------------------------------------------
# Set up a classifier for genetic B-cell ALL subtypes.
cls <- classifier()
## -----------------------------------------------------------------------------
# List covariates.
info <- information(cls)
print(info$covariates[,c("ASSET","TITLE","COVAR")])
## -----------------------------------------------------------------------------
# Set covariates.
covariates(cls) <- simu$metadata
## -----------------------------------------------------------------------------
# Load RNA-seq profiles.
profiles(cls) <- simu$counts
## -----------------------------------------------------------------------------
# Prediction results.
pred <- predictions(cls)
primary <- pred[[1]]
print(primary[1:6,c("LABEL","FREQ","PROX","EXCL")])
## -----------------------------------------------------------------------------
# Prediction results.
ambig <- which(primary$CATEG == "Ambiguous")
uncla <- which(primary$CATEG == "Unclassified")
rows <- unique(c(1:5, ambig[1], uncla[1]))
print(primary[rows,c("LABEL","MATCH","FREQ","PROX","EXCL")])
## -----------------------------------------------------------------------------
# Access subtype labelling information.
info <- information(cls)
print(info$categories[1:5,c("ASSET","TITLE","CATEG","LABEL")])
## -----------------------------------------------------------------------------
# Select successful classification.
rows <- which((primary$CATEG != "Ambiguous") & (primary$FREQ > 0.9))
print(primary[rows[1],c("LABEL","MATCH","FREQ","PROX","EXCL")])
## ----results="hide", fig.width=8, fig.height=6, fig.align="center", fig.cap="Figure: Classification results. The predicted subtype label is written on the top left corner. The expected frequency of the subtype given the data profile is written as a percentage after the predicted label. RNA biomarker scores were also calculated for the presence of alterations in specific genes (center bar chart), note that a patient may have multiple driver genes in parallel. The right-most chart shows RNA biomarker scores for the predicted source tissue of the sample (in this simulated dataset, all samples were generated from B-cell ALL profiles). "----
# Show patient report.
report(cls, name = rows[1], file = NULL)
## -----------------------------------------------------------------------------
# Select ambiguous classification.
rows <- which((primary$CATEG == "Ambiguous") & (primary$PROX > 0.9))
print(primary[rows[1],c("LABEL","MATCH","FREQ","PROX","EXCL")])
## ----results="hide", fig.width=8, fig.height=6, fig.align="center", fig.cap="Figure: Classification results for a case with mixed transcriptional characteristics."----
# Show patient report.
report(cls, name = rows[1], file = NULL)
## -----------------------------------------------------------------------------
# Select poor quality samples.
rows <- which(primary$CATEG == "Unclassified")
print(primary[rows[1],c("LABEL","MATCH","FREQ","PROX","EXCL")])
## ----results="hide", fig.width=8, fig.height=6, fig.align="center", fig.cap="Figure: Classification results for a case with atypical data."----
# Show patient report.
report(cls, name = rows[1], file = NULL)
## -----------------------------------------------------------------------------
# Create a new empty asset.
bALL <- asset()
print(configuration(bALL))
## -----------------------------------------------------------------------------
# Re-configure asset.
configuration(bALL) <- c(ninput.max=30, nonzero.min=90)
print(configuration(bALL)[c("ninput.max","nonzero.min")])
## -----------------------------------------------------------------------------
# Prepare asset title.
materials <- list(title="Simutypes")
## -----------------------------------------------------------------------------
# Prepare RNA-seq read counts.
materials$dat <- simu$counts
## -----------------------------------------------------------------------------
# Prepare covariate data.
materials$covariates <- simu$metadata[,c("MALE","AGE")]
## -----------------------------------------------------------------------------
# Prepare subtype information.
categ <- simu$metadata[,"SUBTYPE",drop=FALSE]
rows <- which(categ != "Contaminated")
materials$bits <- categ[rows,,drop=FALSE]
## -----------------------------------------------------------------------------
# Assemble the classification asset.
bALL <- asset()
assemble(bALL) <- materials
## -----------------------------------------------------------------------------
# Save asset to disk.
tpath <- tempfile()
export(bALL, folder = tpath)
## -----------------------------------------------------------------------------
# Create a classifier.
clstest <- classifier(tpath)
## -----------------------------------------------------------------------------
# Classify samples.
simutest <- bcellALL(5)
covariates(clstest) <- simutest$metadata
profiles(clstest) <- simutest$counts
primtest <- predictions(clstest)[[1]]
print(primtest[,c("LABEL","MATCH","FREQ","PROX","EXCL")])
## -----------------------------------------------------------------------------
# Show correct subtypes.
print(simutest$metadata)
## -----------------------------------------------------------------------------
# Iris flower dataset.
print(head(iris))
## -----------------------------------------------------------------------------
# Set row names.
flowers <- iris
rownames(flowers) <- paste0("flower", 1:nrow(flowers))
print(flowers[c(1,80,150),])
## -----------------------------------------------------------------------------
# Prepare training set.
materials <- list(title="Iris species")
materials$dat <- t(flowers[,1:4]) # vars on rows, samples on columns
materials$bits <- flowers[,"Species",drop=FALSE]
## -----------------------------------------------------------------------------
# Set human-readable category labels.
model <- asset()
labels <- c("Iris Setosa", "Iris Virginica", "Iris Versicolor")
names(labels) <- c("setosa", "virginica", "versicolor")
visuals(model) <- labels
## -----------------------------------------------------------------------------
# Configure a new asset.
configuration(model) <- c(norm=FALSE, logarithm=FALSE)
configuration(model) <- c(nonzero.min=0, nonzero.ratio=0)
print(configuration(model))
## -----------------------------------------------------------------------------
# Assemble the classification asset.
assemble(model) <- materials
tpath <- tempfile()
export(model, folder = tpath)
## -----------------------------------------------------------------------------
# Classify samples.
clsiris <- classifier(tpath)
profiles(clsiris) <- t(flowers[,1:4])
iristest <- predictions(clsiris)[[1]]
print(iristest[c(1,80,150),c("LABEL","MATCH","PROX","EXCL")])
## -----------------------------------------------------------------------------
# Summary of results.
print(table(iristest$LABEL, flowers$Species))
## ----results="hide"-----------------------------------------------------------
# Default ALL classifier.
cls <- classifier()
## -----------------------------------------------------------------------------
# Predict source tissue.
simu <- bcellALL(5)
covariates(cls) <- simu$metadata
profiles(cls) <- simu$counts
tissues <- predictions(cls)[[3]]
print(tissues[,c("LABEL","CATEG","MATCH","MATCH.2nd")])
## -----------------------------------------------------------------------------
# Show asset contents.
base <- system.file(package = "Allspice")
folder <- file.path(base, "subtypes")
print(dir(folder))
## -----------------------------------------------------------------------------
# Category information.
dat <- read.delim(file.path(folder, "categories.txt"))
print(dat)
## -----------------------------------------------------------------------------
# Standardized subtype profiles.
dat <- read.delim(file.path(folder, "centroids.txt"))
print(dat[1:5,1:6])
cat(nrow(dat), " genes, ", ncol(dat), " subtypes\n", sep="")
## -----------------------------------------------------------------------------
# Regression coefficients.
dat <- read.delim(file.path(folder, "coefficients.txt"))
print(dat[1:5,])
## -----------------------------------------------------------------------------
# Asset settings.
dat <- read.delim(file.path(folder, "configuration.txt"))
print(dat)
## -----------------------------------------------------------------------------
# Covariate statistics.
dat <- read.delim(file.path(folder, "covariates.txt"))
print(dat)
## -----------------------------------------------------------------------------
# Gene names.
dat <- read.delim(file.path(folder, "nomenclature.txt"))
print(dat[1:5,])
## -----------------------------------------------------------------------------
# RNA reference profile.
dat <- read.delim(file.path(folder, "reference.txt"))
print(dat[1:5,])
cat(nrow(dat), " genes\n", sep="")
## ----echo=FALSE---------------------------------------------------------------
sessionInfo()
Sys.time()
## ----echo=FALSE, results="hide"-----------------------------------------------
options(opt)
| /scratch/gouwar.j/cran-all/cranData/Allspice/inst/doc/intro.R |
---
title: Introduction to Allspice
output:
html_document:
toc: true
toc_float: true
toc_depth: 2
number_sections: true
vignette: >
%\VignetteIndexEntry{intro}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
<style>
body {
text-align: justify;
}
p.caption {
display: inline-block;
padding-left: 0.5em;
padding-right: 0.5em;
border-color: #F4F4F4;
border-width: 1px;
border-style: solid;
border-radius: 4px;
background-color: #F6F6F6;
text-align: justify;
}
div.caption {
display: inline-block;
padding-left: 0.5em;
padding-right: 0.5em;
border-color: #F4F4F4;
border-width: 1px;
border-style: solid;
border-radius: 4px;
background-color: #F6F6F6;
text-align: justify;
}
h1 {
margin-top: 1em;
margin-bottom: 0.1em;
}
h2 {
margin-top: 0.2em;
margin-bottom: 0.1em;
}
</style>
**Author:** Ville-Petteri Mäkinen
**Version:** `r packageVersion("Allspice")`
**Abstract:** Allspice is a lightweight machine learning tool that was
initially developed for RNA profiling of acute lymphoplastic leukemia,
but it can be used for any problem where multiple classes need
to be identified from multi-dimensional data. The classifier contains
optimized mean profiles for the classes (centroids) as observed in the
training data, and new samples are matched to these centroids using the
shortest Euclidean distance. Allspice produces both numerical and visual
output of the classification results and flags samples with mixed features
from multiple classes or atypical values.
**Citation:** Ville-Petteri Mäkinen, Jacqueline Rehn, James Breen, David Yeung, Deborah L White (2022) Multi-cohort transcriptomic subtyping of B-cell acute lymphoblastic leukemia, Int J Mol Sci 2022, 23(9), 4574, https://doi.org/10.3390/ijms23094574
**Resources:** Additional assets were created from tissue-specific RNA-seq data from the Genotype-Tissue Expression Project v8 [Lonsdale J et al. Nat Genet 45, 580–585 (2013) https://doi.org/10.1038/ng.2653], from lymphoblastoid cell lines [Lappalainen et al. Nature 2013 September 26; 501(7468): 506–511. doi:10.1038/nature12531], from pediatric T-cell leukemia samples [Drobna-Śledzińska et al. ArrayExpress E-MTAB-11759, accessed 2022], and from 11 EPT and 134 T-cell ALL samples (South Australian Health and Medical Research Institute, 2022, unpublished).
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="svg8"
version="1.1"
viewBox="0 0 171.97917 42.333334"
height="160"
width="650">
<defs
id="defs2">
<marker
style="overflow:visible"
id="marker3621"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path3619" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker1319"
style="overflow:visible">
<path
id="path1317"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker2702"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2700" />
</marker>
<marker
style="overflow:visible"
id="marker2470"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2468" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker10633"
style="overflow:visible">
<path
id="path10631"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker8705"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path8703" />
</marker>
<marker
style="overflow:visible"
id="marker8577"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path8575" />
</marker>
<marker
style="overflow:visible"
id="marker7895"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path7893" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker7273"
style="overflow:visible">
<path
id="path7271"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker4786"
style="overflow:visible">
<path
id="path4784"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker20325"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path20323" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker19827"
style="overflow:visible">
<path
id="path19825"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker15111"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path15109" />
</marker>
<marker
style="overflow:visible"
id="marker10869"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path10867" />
</marker>
<marker
style="overflow:visible"
id="marker5520"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path5518" />
</marker>
<marker
style="overflow:visible"
id="marker3450"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path3448" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2910"
style="overflow:visible">
<path
id="path2908"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2792"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2790" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2680"
style="overflow:visible">
<path
id="path2678"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2288"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2286" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2194"
style="overflow:visible">
<path
id="path2192"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2106"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2104" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2006"
style="overflow:visible">
<path
id="path2004"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker1260"
style="overflow:visible">
<path
id="path1258"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker9062"
style="overflow:visible">
<path
id="path9060"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker6764"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path6762" />
</marker>
<marker
style="overflow:visible"
id="marker6184"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path6182" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker4074"
style="overflow:visible">
<path
id="path4072"
style="fill:#c837ab;fill-opacity:1;fill-rule:evenodd;stroke:#c837ab;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2646"
style="overflow:visible">
<path
id="path2644"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker1794"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path1792" />
</marker>
<marker
style="overflow:visible"
id="marker3621-9"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path3619-1" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker1319-2"
style="overflow:visible">
<path
id="path1317-7"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker2702-0"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2700-9" />
</marker>
<marker
style="overflow:visible"
id="marker2470-3"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2468-6" />
</marker>
<marker
style="overflow:visible"
id="marker8705-0"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path8703-6" />
</marker>
<marker
style="overflow:visible"
id="marker8577-2"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path8575-6" />
</marker>
<marker
style="overflow:visible"
id="marker7895-1"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path7893-8" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker7273-7"
style="overflow:visible">
<path
id="path7271-9"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker4786-20"
style="overflow:visible">
<path
id="path4784-2"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker15111-5"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path15109-9" />
</marker>
<marker
style="overflow:visible"
id="marker5520-9"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path5518-7" />
</marker>
<marker
style="overflow:visible"
id="marker3450-3"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path3448-6" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2910-1"
style="overflow:visible">
<path
id="path2908-29"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2792-3"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2790-1" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2680-9"
style="overflow:visible">
<path
id="path2678-4"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2288-7"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2286-8" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2194-4"
style="overflow:visible">
<path
id="path2192-5"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2106-0"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2104-3" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2006-6"
style="overflow:visible">
<path
id="path2004-1"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker15111-3"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path15109-6" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker49830"
style="overflow:visible">
<path
id="path49828"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker49422"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path49420" />
</marker>
<marker
style="overflow:visible"
id="marker10633-0"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path10631-6" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker8705-7"
style="overflow:visible">
<path
id="path8703-5"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker8577-3"
style="overflow:visible">
<path
id="path8575-5"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker7895-6"
style="overflow:visible">
<path
id="path7893-2"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker7273-9"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path7271-1" />
</marker>
<marker
style="overflow:visible"
id="marker4786-2"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path4784-7" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker20325-0"
style="overflow:visible">
<path
id="path20323-9"
style="fill:#d35fbc;fill-opacity:1;fill-rule:evenodd;stroke:#d35fbc;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker19827-3"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path19825-2" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker15633"
style="overflow:visible">
<path
id="path15631"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker15111-36"
style="overflow:visible">
<path
id="path15109-0"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker10869-6"
style="overflow:visible">
<path
id="path10867-2"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker5520-6"
style="overflow:visible">
<path
id="path5518-1"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker3450-8"
style="overflow:visible">
<path
id="path3448-7"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2910-9"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2908-2" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2792-0"
style="overflow:visible">
<path
id="path2790-2"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2680-3"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2678-7" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2288-5"
style="overflow:visible">
<path
id="path2286-9"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2194-2"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2192-2" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2106-8"
style="overflow:visible">
<path
id="path2104-9"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2006-7"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2004-3" />
</marker>
<g
id="g16974">
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-0">
<path
style="stroke:none"
d=""
id="path16947" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-1">
<path
style="stroke:none"
d="M 5.6875,-2.625 6.59375,0 h 1.25 L 4.765625,-8.75 h -1.4375 L 0.203125,0 h 1.1875 L 2.3125,-2.625 Z M 5.375,-3.5625 H 2.59375 l 1.4375,-3.984375 z m 0,0"
id="path16950" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-2">
<path
style="stroke:none"
d="M 1.828125,-8.75 H 0.8125 V 0 h 1.015625 z m 0,0"
id="path16953" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-3">
<path
style="stroke:none"
d=""
id="path16956" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-4">
<path
style="stroke:none"
d="m 5.25,-4.53125 c 0,-1.234375 -0.828125,-1.9375 -2.28125,-1.9375 -1.453125,0 -2.40625,0.75 -2.40625,1.921875 0,0.984375 0.5,1.453125 2,1.8125 l 0.921875,0.21875 c 0.703125,0.171875 0.984375,0.421875 0.984375,0.875 0,0.59375 -0.59375,1 -1.46875,1 -0.546875,0 -1,-0.15625 -1.25,-0.421875 C 1.59375,-1.25 1.53125,-1.421875 1.46875,-1.875 h -1.0625 c 0.046875,1.453125 0.859375,2.15625 2.515625,2.15625 1.578125,0 2.59375,-0.78125 2.59375,-2 0,-0.9375 -0.53125,-1.453125 -1.78125,-1.75 l -0.96875,-0.234375 c -0.8125,-0.1875 -1.15625,-0.453125 -1.15625,-0.890625 0,-0.59375 0.515625,-0.953125 1.328125,-0.953125 0.8125,0 1.234375,0.34375 1.265625,1.015625 z m 0,0"
id="path16959" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-5">
<path
style="stroke:none"
d="M 6.421875,-0.59375 C 6.3125,-0.5625 6.265625,-0.5625 6.203125,-0.5625 c -0.34375,0 -0.546875,-0.1875 -0.546875,-0.5 V -4.75 c 0,-1.125 -0.8125,-1.71875 -2.359375,-1.71875 -0.921875,0 -1.65625,0.265625 -2.078125,0.734375 -0.296875,0.328125 -0.421875,0.6875 -0.4375,1.3125 h 1 c 0.09375,-0.78125 0.546875,-1.125 1.484375,-1.125 0.90625,0 1.40625,0.34375 1.40625,0.9375 V -4.34375 C 4.65625,-3.90625 4.4375,-3.75 3.625,-3.640625 2.203125,-3.46875 1.984375,-3.421875 1.609375,-3.265625 0.875,-2.953125 0.5,-2.40625 0.5,-1.578125 0.5,-0.4375 1.296875,0.28125 2.5625,0.28125 3.359375,0.28125 4,0 4.703125,-0.640625 4.78125,0 5.09375,0.28125 5.734375,0.28125 c 0.21875,0 0.34375,-0.03125 0.6875,-0.109375 z m -1.75,-1.390625 c 0,0.34375 -0.09375,0.546875 -0.40625,0.828125 -0.40625,0.359375 -0.890625,0.5625 -1.484375,0.5625 -0.78125,0 -1.234375,-0.375 -1.234375,-1.015625 0,-0.65625 0.4375,-1 1.515625,-1.15625 1.0625,-0.140625 1.265625,-0.1875 1.609375,-0.34375 z m 0,0"
id="path16962" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-6">
<path
style="stroke:none"
d="M 0.84375,-6.28125 V 0 h 1 v -3.953125 c 0,-0.90625 0.671875,-1.640625 1.484375,-1.640625 0.734375,0 1.15625,0.453125 1.15625,1.265625 V 0 H 5.5 v -3.953125 c 0,-0.90625 0.65625,-1.640625 1.46875,-1.640625 0.734375,0 1.171875,0.46875 1.171875,1.265625 V 0 h 1 v -4.71875 c 0,-1.125 -0.640625,-1.75 -1.828125,-1.75 -0.828125,0 -1.34375,0.25 -1.921875,0.953125 -0.375,-0.671875 -0.875,-0.953125 -1.6875,-0.953125 -0.84375,0 -1.40625,0.3125 -1.9375,1.0625 v -0.875 z m 0,0"
id="path16965" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-7">
<path
style="stroke:none"
d="M 0.640625,2.609375 H 1.65625 V -0.65625 c 0.53125,0.640625 1.109375,0.9375 1.9375,0.9375 1.625,0 2.6875,-1.3125 2.6875,-3.3125 0,-2.109375 -1.03125,-3.4375 -2.703125,-3.4375 -0.859375,0 -1.53125,0.390625 -2,1.125 v -0.9375 h -0.9375 z M 3.40625,-5.53125 c 1.109375,0 1.828125,0.96875 1.828125,2.46875 0,1.4375 -0.734375,2.40625 -1.828125,2.40625 -1.0625,0 -1.75,-0.96875 -1.75,-2.4375 0,-1.484375 0.6875,-2.4375 1.75,-2.4375 z m 0,0"
id="path16968" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-8">
<path
style="stroke:none"
d="m 6.15625,-2.8125 c 0,-0.953125 -0.078125,-1.53125 -0.25,-2 C 5.5,-5.84375 4.53125,-6.46875 3.359375,-6.46875 c -1.75,0 -2.875,1.328125 -2.875,3.40625 0,2.078125 1.078125,3.34375 2.859375,3.34375 1.4375,0 2.421875,-0.828125 2.6875,-2.1875 H 5.015625 C 4.734375,-1.078125 4.171875,-0.640625 3.375,-0.640625 2.734375,-0.640625 2.203125,-0.9375 1.859375,-1.46875 1.625,-1.828125 1.53125,-2.1875 1.53125,-2.8125 Z M 1.546875,-3.625 C 1.625,-4.78125 2.34375,-5.546875 3.34375,-5.546875 4.375,-5.546875 5.078125,-4.75 5.078125,-3.625 Z m 0,0"
id="path16971" />
</symbol>
</g>
<g
id="g46644">
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-0-3">
<path
style="stroke:none"
d=""
id="path46503" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-1-6">
<path
style="stroke:none"
d="M 5.6875,-2.625 6.59375,0 h 1.25 L 4.765625,-8.75 h -1.4375 L 0.203125,0 h 1.1875 L 2.3125,-2.625 Z M 5.375,-3.5625 H 2.59375 l 1.4375,-3.984375 z m 0,0"
id="path46506" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-2-7">
<path
style="stroke:none"
d="M 1.828125,-8.75 H 0.8125 V 0 h 1.015625 z m 0,0"
id="path46509" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-3-5">
<path
style="stroke:none"
d=""
id="path46512" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-4-3">
<path
style="stroke:none"
d="m 5.25,-4.53125 c 0,-1.234375 -0.828125,-1.9375 -2.28125,-1.9375 -1.453125,0 -2.40625,0.75 -2.40625,1.921875 0,0.984375 0.5,1.453125 2,1.8125 l 0.921875,0.21875 c 0.703125,0.171875 0.984375,0.421875 0.984375,0.875 0,0.59375 -0.59375,1 -1.46875,1 -0.546875,0 -1,-0.15625 -1.25,-0.421875 C 1.59375,-1.25 1.53125,-1.421875 1.46875,-1.875 h -1.0625 c 0.046875,1.453125 0.859375,2.15625 2.515625,2.15625 1.578125,0 2.59375,-0.78125 2.59375,-2 0,-0.9375 -0.53125,-1.453125 -1.78125,-1.75 l -0.96875,-0.234375 c -0.8125,-0.1875 -1.15625,-0.453125 -1.15625,-0.890625 0,-0.59375 0.515625,-0.953125 1.328125,-0.953125 0.8125,0 1.234375,0.34375 1.265625,1.015625 z m 0,0"
id="path46515" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-5-5">
<path
style="stroke:none"
d="M 6.421875,-0.59375 C 6.3125,-0.5625 6.265625,-0.5625 6.203125,-0.5625 c -0.34375,0 -0.546875,-0.1875 -0.546875,-0.5 V -4.75 c 0,-1.125 -0.8125,-1.71875 -2.359375,-1.71875 -0.921875,0 -1.65625,0.265625 -2.078125,0.734375 -0.296875,0.328125 -0.421875,0.6875 -0.4375,1.3125 h 1 c 0.09375,-0.78125 0.546875,-1.125 1.484375,-1.125 0.90625,0 1.40625,0.34375 1.40625,0.9375 V -4.34375 C 4.65625,-3.90625 4.4375,-3.75 3.625,-3.640625 2.203125,-3.46875 1.984375,-3.421875 1.609375,-3.265625 0.875,-2.953125 0.5,-2.40625 0.5,-1.578125 0.5,-0.4375 1.296875,0.28125 2.5625,0.28125 3.359375,0.28125 4,0 4.703125,-0.640625 4.78125,0 5.09375,0.28125 5.734375,0.28125 c 0.21875,0 0.34375,-0.03125 0.6875,-0.109375 z m -1.75,-1.390625 c 0,0.34375 -0.09375,0.546875 -0.40625,0.828125 -0.40625,0.359375 -0.890625,0.5625 -1.484375,0.5625 -0.78125,0 -1.234375,-0.375 -1.234375,-1.015625 0,-0.65625 0.4375,-1 1.515625,-1.15625 1.0625,-0.140625 1.265625,-0.1875 1.609375,-0.34375 z m 0,0"
id="path46518" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-6-6">
<path
style="stroke:none"
d="M 0.84375,-6.28125 V 0 h 1 v -3.953125 c 0,-0.90625 0.671875,-1.640625 1.484375,-1.640625 0.734375,0 1.15625,0.453125 1.15625,1.265625 V 0 H 5.5 v -3.953125 c 0,-0.90625 0.65625,-1.640625 1.46875,-1.640625 0.734375,0 1.171875,0.46875 1.171875,1.265625 V 0 h 1 v -4.71875 c 0,-1.125 -0.640625,-1.75 -1.828125,-1.75 -0.828125,0 -1.34375,0.25 -1.921875,0.953125 -0.375,-0.671875 -0.875,-0.953125 -1.6875,-0.953125 -0.84375,0 -1.40625,0.3125 -1.9375,1.0625 v -0.875 z m 0,0"
id="path46521" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-7-2">
<path
style="stroke:none"
d="M 0.640625,2.609375 H 1.65625 V -0.65625 c 0.53125,0.640625 1.109375,0.9375 1.9375,0.9375 1.625,0 2.6875,-1.3125 2.6875,-3.3125 0,-2.109375 -1.03125,-3.4375 -2.703125,-3.4375 -0.859375,0 -1.53125,0.390625 -2,1.125 v -0.9375 h -0.9375 z M 3.40625,-5.53125 c 1.109375,0 1.828125,0.96875 1.828125,2.46875 0,1.4375 -0.734375,2.40625 -1.828125,2.40625 -1.0625,0 -1.75,-0.96875 -1.75,-2.4375 0,-1.484375 0.6875,-2.4375 1.75,-2.4375 z m 0,0"
id="path46524" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-8-9">
<path
style="stroke:none"
d="m 6.15625,-2.8125 c 0,-0.953125 -0.078125,-1.53125 -0.25,-2 C 5.5,-5.84375 4.53125,-6.46875 3.359375,-6.46875 c -1.75,0 -2.875,1.328125 -2.875,3.40625 0,2.078125 1.078125,3.34375 2.859375,3.34375 1.4375,0 2.421875,-0.828125 2.6875,-2.1875 H 5.015625 C 4.734375,-1.078125 4.171875,-0.640625 3.375,-0.640625 2.734375,-0.640625 2.203125,-0.9375 1.859375,-1.46875 1.625,-1.828125 1.53125,-2.1875 1.53125,-2.8125 Z M 1.546875,-3.625 C 1.625,-4.78125 2.34375,-5.546875 3.34375,-5.546875 4.375,-5.546875 5.078125,-4.75 5.078125,-3.625 Z m 0,0"
id="path46527" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-9">
<path
style="stroke:none"
d="m 0.953125,0 h 3.9375 C 5.71875,0 6.34375,-0.234375 6.796875,-0.734375 7.234375,-1.1875 7.46875,-1.8125 7.46875,-2.5 7.46875,-3.546875 7,-4.1875 5.875,-4.625 c 0.8125,-0.359375 1.21875,-1 1.21875,-1.90625 0,-0.640625 -0.234375,-1.203125 -0.703125,-1.609375 C 5.921875,-8.5625 5.34375,-8.75 4.5,-8.75 H 0.953125 Z M 2.0625,-4.984375 v -2.78125 h 2.15625 c 0.625,0 0.984375,0.078125 1.28125,0.3125 0.3125,0.234375 0.46875,0.59375 0.46875,1.078125 0,0.484375 -0.15625,0.84375 -0.46875,1.078125 -0.296875,0.234375 -0.65625,0.3125 -1.28125,0.3125 z m 0,4 V -4 h 2.71875 c 0.984375,0 1.578125,0.5625 1.578125,1.515625 0,0.9375 -0.59375,1.5 -1.578125,1.5 z m 0,0"
id="path46530" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-10">
<path
style="stroke:none"
d="M 7.9375,-6.03125 C 7.59375,-7.953125 6.484375,-8.890625 4.578125,-8.890625 c -1.1875,0 -2.125,0.375 -2.78125,1.09375 -0.78125,0.859375 -1.21875,2.109375 -1.21875,3.53125 0,1.4375 0.4375,2.671875 1.265625,3.515625 0.671875,0.703125 1.546875,1.03125 2.6875,1.03125 2.125,0 3.328125,-1.15625 3.59375,-3.46875 H 6.96875 C 6.875,-2.59375 6.75,-2.1875 6.578125,-1.84375 6.21875,-1.109375 5.46875,-0.703125 4.53125,-0.703125 c -1.734375,0 -2.84375,-1.390625 -2.84375,-3.578125 0,-2.25 1.046875,-3.625 2.75,-3.625 0.703125,0 1.375,0.203125 1.734375,0.546875 0.3125,0.296875 0.5,0.65625 0.625,1.328125 z m 0,0"
id="path46533" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-11">
<path
style="stroke:none"
d="m 2.078125,-8.75 h -1.125 V 0 h 5.4375 v -0.984375 h -4.3125 z m 0,0"
id="path46536" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-12">
<path
style="stroke:none"
d="M 6.078125,-1.046875 H 1.59375 c 0.109375,-0.71875 0.5,-1.171875 1.53125,-1.8125 L 4.328125,-3.53125 C 5.515625,-4.1875 6.125,-5.078125 6.125,-6.140625 6.125,-6.859375 5.84375,-7.53125 5.34375,-8 c -0.5,-0.453125 -1.125,-0.671875 -1.9375,-0.671875 -1.078125,0 -1.875,0.375 -2.34375,1.125 -0.3125,0.453125 -0.4375,1 -0.46875,1.875 h 1.0625 c 0.03125,-0.59375 0.109375,-0.9375 0.25,-1.234375 C 2.1875,-7.421875 2.734375,-7.75 3.375,-7.75 c 0.953125,0 1.671875,0.6875 1.671875,1.625 0,0.703125 -0.390625,1.296875 -1.140625,1.734375 L 2.796875,-3.75 C 1.015625,-2.71875 0.5,-1.90625 0.40625,-0.015625 h 5.671875 z m 0,0"
id="path46539" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-13">
<path
style="stroke:none"
d="m 6.9375,1.515625 h -7.203125 v 0.59375 H 6.9375 Z m 0,0"
id="path46542" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-14">
<path
style="stroke:none"
d="m 5.609375,0 2.46875,-7.328125 V 0 H 9.125 V -8.75 H 7.578125 L 5.046875,-1.125 2.453125,-8.75 H 0.90625 V 0 H 1.953125 V -7.328125 L 4.4375,0 Z m 0,0"
id="path46545" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-15">
<path
style="stroke:none"
d="M 4.640625,-3.4375 7.9375,-8.75 H 6.59375 L 4.109375,-4.484375 1.53125,-8.75 h -1.375 l 3.375,5.3125 V 0 h 1.109375 z m 0,0"
id="path46548" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-16">
<path
style="stroke:none"
d="m 2.234375,-3.765625 h 2.875 c 1,0 1.4375,0.484375 1.4375,1.5625 v 0.78125 c 0,0.53125 0.09375,1.0625 0.25,1.421875 h 1.34375 V -0.28125 C 7.734375,-0.5625 7.640625,-0.875 7.625,-2.046875 7.609375,-3.484375 7.375,-3.90625 6.4375,-4.3125 c 0.984375,-0.5 1.375,-1.09375 1.375,-2.09375 C 7.8125,-7.921875 6.875,-8.75 5.140625,-8.75 H 1.109375 V 0 h 1.125 z m 0,-0.984375 V -7.765625 H 4.9375 c 0.625,0 0.984375,0.09375 1.25,0.34375 0.296875,0.25 0.453125,0.640625 0.453125,1.15625 C 6.640625,-5.21875 6.125,-4.75 4.9375,-4.75 Z m 0,0"
id="path46551" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-17">
<path
style="stroke:none"
d="M 2.203125,-3.984375 H 6.375 V -4.96875 H 2.203125 v -2.796875 h 4.75 V -8.75 h -5.875 V 0 h 1.125 z m 0,0"
id="path46554" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-18">
<path
style="stroke:none"
d="m 1.0625,0 h 3.375 C 6.640625,0 8,-1.65625 8,-4.375 8,-7.09375 6.65625,-8.75 4.4375,-8.75 h -3.375 z m 1.125,-0.984375 v -6.78125 H 4.25 c 1.71875,0 2.640625,1.171875 2.640625,3.390625 0,2.234375 -0.921875,3.390625 -2.640625,3.390625 z m 0,0"
id="path46557" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-19">
<path
style="stroke:none"
d="m 6.625,-8.75 v 6.140625 c 0,1.1875 -0.859375,1.90625 -2.25,1.90625 -0.65625,0 -1.1875,-0.15625 -1.609375,-0.453125 C 2.34375,-1.5 2.140625,-1.9375 2.140625,-2.609375 V -8.75 h -1.125 v 6.140625 c 0,1.78125 1.28125,2.890625 3.359375,2.890625 2.046875,0 3.359375,-1.140625 3.359375,-2.890625 V -8.75 Z m 0,0"
id="path46560" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-20">
<path
style="stroke:none"
d="M 4.6875,-4.484375 7.640625,-8.75 H 6.3125 l -2.25,3.4375 -2.25,-3.4375 H 0.453125 L 3.359375,-4.484375 0.265625,0 H 1.625 L 4.015625,-3.640625 6.40625,0 h 1.375 z m 0,0"
id="path46563" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-21">
<path
style="stroke:none"
d="M 3.921875,-2.09375 V 0 h 1.0625 v -2.09375 h 1.25 v -0.953125 h -1.25 v -5.625 H 4.203125 L 0.34375,-3.21875 v 1.125 z m 0,-0.953125 H 1.265625 L 3.921875,-6.875 Z m 0,0"
id="path46566" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-22">
<path
style="stroke:none"
d="m 2.203125,-3.984375 h 4.75 V -4.96875 h -4.75 v -2.796875 h 4.9375 V -8.75 h -6.0625 V 0 h 6.28125 v -0.984375 h -5.15625 z m 0,0"
id="path46569" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-23">
<path
style="stroke:none"
d="M 4.25,-7.765625 H 7.109375 V -8.75 H 0.25 v 0.984375 H 3.125 V 0 H 4.25 Z m 0,0"
id="path46572" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-24">
<path
style="stroke:none"
d="m 4.703125,0 3.03125,-8.75 h -1.1875 L 4.125,-1.34375 1.5625,-8.75 H 0.359375 L 3.5,0 Z m 0,0"
id="path46575" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-25">
<path
style="stroke:none"
d="m 5.96875,-6.421875 c -0.203125,-1.421875 -1.109375,-2.25 -2.40625,-2.25 -0.9375,0 -1.78125,0.453125 -2.28125,1.234375 -0.53125,0.84375 -0.765625,1.90625 -0.765625,3.484375 0,1.453125 0.203125,2.375 0.71875,3.15625 C 1.6875,-0.09375 2.4375,0.28125 3.375,0.28125 c 1.609375,0 2.78125,-1.21875 2.78125,-2.90625 0,-1.59375 -1.078125,-2.734375 -2.609375,-2.734375 -0.828125,0 -1.5,0.3125 -1.953125,0.953125 0.015625,-2.140625 0.6875,-3.328125 1.890625,-3.328125 0.75,0 1.265625,0.46875 1.4375,1.3125 z m -2.546875,2 c 1.015625,0 1.65625,0.71875 1.65625,1.875 0,1.09375 -0.71875,1.890625 -1.6875,1.890625 -0.984375,0 -1.734375,-0.828125 -1.734375,-1.9375 0,-1.078125 0.71875,-1.828125 1.765625,-1.828125 z m 0,0"
id="path46578" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-26">
<path
style="stroke:none"
d="m 2.296875,-1.25 h -1.25 V 0 h 1.25 z m 0,0"
id="path46581" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-27">
<path
style="stroke:none"
d="M 7.75,-8.75 H 6.703125 v 7.15625 L 2.125,-8.75 H 0.90625 V 0 h 1.0625 V -7.09375 L 6.484375,0 H 7.75 Z m 0,0"
id="path46584" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-28">
<path
style="stroke:none"
d="M 3.109375,-6.1875 V 0 H 4.15625 v -8.671875 h -0.6875 c -0.375,1.328125 -0.609375,1.515625 -2.25,1.71875 V -6.1875 Z m 0,0"
id="path46587" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-29">
<path
style="stroke:none"
d="M 6.609375,-3.984375 V 0 h 1.125 v -8.75 h -1.125 v 3.78125 h -4.5 V -8.75 H 1 V 0 h 1.109375 v -3.984375 z m 0,0"
id="path46590" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-30">
<path
style="stroke:none"
d="M 4.65625,-6.28125 2.921875,-1.390625 1.3125,-6.28125 H 0.234375 l 2.125,6.3125 -0.375,0.984375 C 1.8125,1.46875 1.59375,1.625 1.171875,1.625 c -0.15625,0 -0.3125,-0.015625 -0.53125,-0.0625 V 2.453125 C 0.859375,2.5625 1.0625,2.609375 1.3125,2.609375 c 0.328125,0 0.671875,-0.09375 0.9375,-0.296875 0.3125,-0.21875 0.5,-0.484375 0.6875,-1 l 2.796875,-7.59375 z m 0,0"
id="path46593" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-31">
<path
style="stroke:none"
d="M 0.828125,-6.28125 V 0 H 1.84375 v -3.265625 c 0,-1.515625 0.625,-2.1875 2.015625,-2.140625 V -6.4375 C 3.6875,-6.453125 3.59375,-6.46875 3.46875,-6.46875 2.8125,-6.46875 2.328125,-6.078125 1.75,-5.140625 V -6.28125 Z m 0,0"
id="path46596" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-32">
<path
style="stroke:none"
d="m 5.9375,-8.75 h -1 V -5.5 C 4.53125,-6.125 3.859375,-6.46875 3.015625,-6.46875 c -1.640625,0 -2.703125,1.3125 -2.703125,3.3125 0,2.125 1.03125,3.4375 2.734375,3.4375 0.859375,0 1.46875,-0.328125 2,-1.109375 V 0 H 5.9375 Z m -2.75,3.21875 c 1.078125,0 1.75,0.953125 1.75,2.453125 0,1.453125 -0.6875,2.421875 -1.75,2.421875 -1.09375,0 -1.828125,-0.96875 -1.828125,-2.4375 0,-1.46875 0.734375,-2.4375 1.828125,-2.4375 z m 0,0"
id="path46599" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-33">
<path
style="stroke:none"
d="m 1.796875,-6.28125 h -1 V 0 h 1 z m 0,-2.46875 h -1 v 1.265625 h 1 z m 0,0"
id="path46602" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-34">
<path
style="stroke:none"
d="m 3.265625,-6.46875 c -1.78125,0 -2.828125,1.265625 -2.828125,3.375 0,2.125 1.046875,3.375 2.84375,3.375 1.765625,0 2.84375,-1.265625 2.84375,-3.328125 0,-2.1875 -1.03125,-3.421875 -2.859375,-3.421875 z m 0.015625,0.921875 c 1.125,0 1.796875,0.921875 1.796875,2.484375 0,1.484375 -0.703125,2.421875 -1.796875,2.421875 -1.125,0 -1.8125,-0.9375 -1.8125,-2.453125 0,-1.53125 0.6875,-2.453125 1.8125,-2.453125 z m 0,0"
id="path46605" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-35">
<path
style="stroke:none"
d="m 2.203125,-3.703125 h 2.75 c 0.6875,0 1.234375,-0.203125 1.6875,-0.625 C 7.171875,-4.8125 7.40625,-5.375 7.40625,-6.1875 7.40625,-7.828125 6.4375,-8.75 4.703125,-8.75 H 1.09375 V 0 h 1.109375 z m 0,-0.984375 V -7.765625 H 4.53125 c 1.078125,0 1.703125,0.578125 1.703125,1.53125 0,0.96875 -0.625,1.546875 -1.703125,1.546875 z m 0,0"
id="path46608" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-36">
<path
style="stroke:none"
d="m 2.328125,-8.75 h -1.125 V 0 h 1.125 z m 0,0"
id="path46611" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-37">
<path
style="stroke:none"
d="M 2.0625,-3.0625 3.484375,-4.484375 6.578125,0 h 1.3125 l -3.59375,-5.1875 3.5625,-3.5625 h -1.4375 L 2.0625,-4.3125 V -8.75 H 0.953125 V 0 H 2.0625 Z m 0,0"
id="path46614" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-38">
<path
style="stroke:none"
d="M 6.96875,-8.75 H 0.671875 v 0.984375 H 5.59375 l -5.25,6.78125 V 0 H 7 V -0.984375 H 1.734375 l 5.234375,-6.75 z m 0,0"
id="path46617" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-39">
<path
style="stroke:none"
d="M 0.84375,-6.28125 V 0 h 1 v -3.46875 c 0,-1.28125 0.671875,-2.125 1.703125,-2.125 0.796875,0 1.296875,0.484375 1.296875,1.234375 V 0 h 1 v -4.75 c 0,-1.046875 -0.78125,-1.71875 -1.984375,-1.71875 -0.9375,0 -1.546875,0.359375 -2.09375,1.234375 V -6.28125 Z m 0,0"
id="path46620" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-40">
<path
style="stroke:none"
d="M 5.71875,-8.515625 H 1.3125 L 0.6875,-3.875 h 0.96875 c 0.484375,-0.59375 0.90625,-0.796875 1.578125,-0.796875 1.140625,0 1.84375,0.78125 1.84375,2.046875 0,1.21875 -0.703125,1.96875 -1.859375,1.96875 -0.921875,0 -1.484375,-0.46875 -1.75,-1.4375 H 0.421875 C 0.5625,-1.390625 0.6875,-1.0625 0.9375,-0.75 c 0.484375,0.65625 1.34375,1.03125 2.296875,1.03125 1.71875,0 2.921875,-1.25 2.921875,-3.046875 0,-1.6875 -1.109375,-2.84375 -2.75,-2.84375 -0.59375,0 -1.078125,0.15625 -1.5625,0.515625 l 0.328125,-2.375 H 5.71875 Z m 0,0"
id="path46623" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-41">
<path
style="stroke:none"
d="M 0.640625,-1.984375 C 0.84375,-0.5625 1.75,0.28125 3.046875,0.28125 4,0.28125 4.84375,-0.1875 5.34375,-0.953125 5.875,-1.8125 6.109375,-2.875 6.109375,-4.4375 c 0,-1.46875 -0.21875,-2.390625 -0.71875,-3.15625 -0.46875,-0.703125 -1.21875,-1.078125 -2.15625,-1.078125 -1.609375,0 -2.78125,1.203125 -2.78125,2.890625 0,1.59375 1.078125,2.71875 2.625,2.71875 0.796875,0 1.390625,-0.28125 1.9375,-0.953125 C 5,-1.84375 4.328125,-0.65625 3.125,-0.65625 c -0.75,0 -1.265625,-0.484375 -1.4375,-1.328125 z M 3.234375,-7.75 c 0.984375,0 1.71875,0.828125 1.71875,1.9375 C 4.953125,-4.734375 4.234375,-4 3.1875,-4 2.171875,-4 1.53125,-4.71875 1.53125,-5.875 1.53125,-6.953125 2.25,-7.75 3.234375,-7.75 Z m 0,0"
id="path46626" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-42">
<path
style="stroke:none"
d="m 3.046875,-6.28125 h -1.03125 v -1.734375 h -1 v 1.734375 h -0.84375 v 0.8125 h 0.84375 v 4.75 c 0,0.640625 0.4375,1 1.21875,1 C 2.5,0.28125 2.71875,0.25 3.046875,0.1875 V -0.640625 C 2.90625,-0.609375 2.765625,-0.59375 2.5625,-0.59375 c -0.421875,0 -0.546875,-0.125 -0.546875,-0.5625 v -4.3125 h 1.03125 z m 0,0"
id="path46629" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-43">
<path
style="stroke:none"
d="m 4.6875,-4.578125 c 0.890625,-0.53125 1.171875,-0.96875 1.171875,-1.78125 0,-1.375 -1.046875,-2.3125 -2.5625,-2.3125 -1.5,0 -2.546875,0.9375 -2.546875,2.296875 0,0.828125 0.265625,1.25 1.140625,1.796875 -0.96875,0.5 -1.453125,1.203125 -1.453125,2.171875 0,1.578125 1.171875,2.6875 2.859375,2.6875 1.6875,0 2.859375,-1.109375 2.859375,-2.6875 0,-0.96875 -0.484375,-1.671875 -1.46875,-2.171875 z m -1.390625,-3.15625 c 0.90625,0 1.484375,0.53125 1.484375,1.390625 0,0.828125 -0.59375,1.359375 -1.484375,1.359375 -0.890625,0 -1.46875,-0.53125 -1.46875,-1.375 0,-0.84375 0.578125,-1.375 1.46875,-1.375 z m 0,3.640625 c 1.0625,0 1.78125,0.703125 1.78125,1.703125 0,1.046875 -0.703125,1.734375 -1.796875,1.734375 -1.03125,0 -1.75,-0.71875 -1.75,-1.71875 0,-1.03125 0.703125,-1.71875 1.765625,-1.71875 z m 0,0"
id="path46632" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-44">
<path
style="stroke:none"
d="m 3.296875,-8.671875 c -0.78125,0 -1.515625,0.359375 -1.953125,0.9375 -0.546875,0.78125 -0.828125,1.921875 -0.828125,3.53125 0,2.9375 0.953125,4.484375 2.78125,4.484375 1.796875,0 2.78125,-1.546875 2.78125,-4.40625 0,-1.6875 -0.265625,-2.8125 -0.828125,-3.609375 -0.4375,-0.59375 -1.140625,-0.9375 -1.953125,-0.9375 z m 0,0.9375 C 4.4375,-7.734375 5,-6.578125 5,-4.21875 c 0,2.46875 -0.546875,3.625 -1.71875,3.625 -1.125,0 -1.6875,-1.203125 -1.6875,-3.59375 0,-2.390625 0.5625,-3.546875 1.703125,-3.546875 z m 0,0"
id="path46635" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-45">
<path
style="stroke:none"
d="M 0.84375,-8.75 V 0 h 1 v -3.46875 c 0,-1.28125 0.671875,-2.125 1.703125,-2.125 0.328125,0 0.640625,0.09375 0.875,0.28125 0.296875,0.21875 0.421875,0.515625 0.421875,0.953125 V 0 h 0.984375 v -4.75 c 0,-1.0625 -0.75,-1.71875 -1.96875,-1.71875 -0.890625,0 -1.4375,0.28125 -2.015625,1.046875 V -8.75 Z m 0,0"
id="path46638" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-46">
<path
style="stroke:none"
d="m 2.65625,-4 h 0.578125 c 1.140625,0 1.75,0.546875 1.75,1.59375 0,1.09375 -0.65625,1.75 -1.75,1.75 -1.15625,0 -1.71875,-0.59375 -1.796875,-1.859375 H 0.390625 c 0.046875,0.6875 0.15625,1.140625 0.359375,1.53125 0.453125,0.84375 1.28125,1.265625 2.4375,1.265625 1.75,0 2.890625,-1.0625 2.890625,-2.703125 C 6.078125,-3.53125 5.65625,-4.125 4.625,-4.484375 5.421875,-4.8125 5.8125,-5.40625 5.8125,-6.28125 c 0,-1.5 -0.96875,-2.390625 -2.578125,-2.390625 -1.71875,0 -2.640625,0.953125 -2.671875,2.796875 H 1.625 c 0,-0.53125 0.0625,-0.828125 0.1875,-1.09375 0.234375,-0.5 0.765625,-0.78125 1.421875,-0.78125 0.9375,0 1.5,0.5625 1.5,1.5 0,0.609375 -0.203125,0.984375 -0.671875,1.1875 -0.296875,0.125 -0.671875,0.171875 -1.40625,0.171875 z m 0,0"
id="path46641" />
</symbol>
</g>
<g
id="g450">
<symbol
id="glyph0-0-36"
overflow="visible"
style="overflow:visible">
<path
id="path405"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph0-1-7"
overflow="visible"
style="overflow:visible">
<path
id="path408"
d="M 8.1875,-3.78125 9.484375,0 H 11.28125 L 6.859375,-12.59375 H 4.78125 L 0.296875,0 H 2 L 3.328125,-3.78125 Z M 7.734375,-5.125 h -4 l 2.078125,-5.75 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-2-5"
overflow="visible"
style="overflow:visible">
<path
id="path411"
d="M 9.546875,-12.59375 V -3.75 c 0,1.6875 -1.234375,2.734375 -3.25,2.734375 -0.9375,0 -1.703125,-0.234375 -2.3125,-0.65625 C 3.375,-2.15625 3.078125,-2.796875 3.078125,-3.75 v -8.84375 H 1.46875 V -3.75 c 0,2.5625 1.828125,4.140625 4.828125,4.140625 2.953125,0 4.84375,-1.625 4.84375,-4.140625 v -8.84375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-3-3"
overflow="visible"
style="overflow:visible">
<path
id="path414"
d="M 3.296875,-1.796875 H 1.5 V 0 h 1.796875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-4-5"
overflow="visible"
style="overflow:visible">
<path
id="path417"
d="M 4.46875,-8.90625 V 0 H 6 V -12.5 H 5 c -0.546875,1.921875 -0.890625,2.1875 -3.234375,2.5 v 1.09375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-5-6"
overflow="visible"
style="overflow:visible">
<path
id="path420"
d="M 8.75,-1.5 H 2.296875 C 2.453125,-2.546875 3,-3.203125 4.515625,-4.109375 l 1.71875,-0.96875 c 1.71875,-0.953125 2.59375,-2.234375 2.59375,-3.765625 0,-1.046875 -0.40625,-2.015625 -1.140625,-2.6875 C 6.96875,-12.1875 6.0625,-12.5 4.90625,-12.5 c -1.546875,0 -2.71875,0.5625 -3.390625,1.625 -0.421875,0.65625 -0.609375,1.4375 -0.65625,2.703125 h 1.53125 C 2.4375,-9.015625 2.546875,-9.515625 2.75,-9.9375 c 0.390625,-0.765625 1.1875,-1.21875 2.109375,-1.21875 1.375,0 2.421875,1 2.421875,2.34375 0,1 -0.578125,1.859375 -1.671875,2.484375 l -1.578125,0.9375 c -2.5625,1.46875 -3.3125,2.640625 -3.4375,5.375 H 8.75 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-6-2"
overflow="visible"
style="overflow:visible">
<path
id="path423"
d="m 3.8125,-5.75 h 0.84375 c 1.65625,0 2.53125,0.765625 2.53125,2.28125 0,1.5625 -0.953125,2.515625 -2.515625,2.515625 -1.6875,0 -2.5,-0.84375 -2.59375,-2.671875 h -1.53125 c 0.078125,1 0.25,1.65625 0.546875,2.203125 0.640625,1.21875 1.828125,1.8125 3.5,1.8125 C 7.125,0.390625 8.75,-1.125 8.75,-3.484375 8.75,-5.078125 8.140625,-5.9375 6.671875,-6.46875 7.8125,-6.9375 8.375,-7.796875 8.375,-9.0625 8.375,-11.203125 6.984375,-12.5 4.65625,-12.5 c -2.484375,0 -3.796875,1.390625 -3.84375,4.03125 h 1.515625 c 0.015625,-0.765625 0.09375,-1.1875 0.28125,-1.578125 0.34375,-0.703125 1.109375,-1.109375 2.0625,-1.109375 1.34375,0 2.15625,0.8125 2.15625,2.15625 0,0.875 -0.3125,1.40625 -0.984375,1.703125 C 5.421875,-7.125 4.875,-7.046875 3.8125,-7.03125 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-0"
overflow="visible"
style="overflow:visible">
<path
id="path426"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph1-1"
overflow="visible"
style="overflow:visible">
<path
id="path429"
d="m 1.1875,0 h 4.71875 c 1.203125,0 2.015625,-0.234375 2.65625,-0.765625 0.625,-0.53125 1.03125,-1.40625 1.03125,-2.265625 0,-1.03125 -0.546875,-1.859375 -1.75,-2.546875 1.046875,-0.65625 1.453125,-1.265625 1.453125,-2.15625 0,-0.734375 -0.359375,-1.484375 -0.953125,-2 C 7.71875,-10.265625 6.984375,-10.5 5.859375,-10.5 H 1.1875 Z M 3.34375,-8.703125 H 5.6875 c 1.015625,0 1.53125,0.40625 1.53125,1.1875 0,0.78125 -0.515625,1.1875 -1.53125,1.1875 H 3.34375 Z m 0,4.171875 h 2.578125 c 1.046875,0 1.59375,0.46875 1.59375,1.375 0,0.890625 -0.546875,1.359375 -1.59375,1.359375 H 3.34375 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-2"
overflow="visible"
style="overflow:visible">
<path
id="path432"
d="M 9.828125,-6.9375 C 9.75,-7.84375 9.5625,-8.421875 9.125,-9.015625 c -0.8125,-1.0625 -2.109375,-1.65625 -3.671875,-1.65625 -2.96875,0 -4.8125,2.109375 -4.8125,5.515625 0,3.390625 1.828125,5.484375 4.75,5.484375 2.625,0 4.34375,-1.515625 4.484375,-3.921875 H 7.765625 C 7.625,-2.25 6.78125,-1.484375 5.453125,-1.484375 c -1.671875,0 -2.65625,-1.359375 -2.65625,-3.640625 0,-2.328125 1.015625,-3.703125 2.71875,-3.703125 1.25,0 1.96875,0.609375 2.25,1.890625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-3"
overflow="visible"
style="overflow:visible">
<path
id="path435"
d="M 3.3125,-10.5 H 1.15625 V 0 h 7.1875 V -1.796875 H 3.3125 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-4"
overflow="visible"
style="overflow:visible">
<path
id="path438"
d="M 7.375,-1.796875 H 3.046875 C 3.3125,-2.34375 3.625,-2.65625 5.125,-3.734375 6.90625,-5.03125 7.421875,-5.796875 7.421875,-7.1875 c 0,-1.96875 -1.375,-3.25 -3.5,-3.25 -2.125,0 -3.359375,1.265625 -3.359375,3.421875 V -6.65625 H 2.5 V -6.984375 C 2.5,-8.125 3.046875,-8.78125 3.96875,-8.78125 c 0.890625,0 1.4375,0.609375 1.4375,1.640625 C 5.40625,-6 5.0625,-5.59375 2.78125,-3.96875 1.046875,-2.796875 0.515625,-1.90625 0.4375,0 H 7.375 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-5"
overflow="visible"
style="overflow:visible">
<path
id="path441"
d="M 3,-10.28125 0.03125,0.203125 H 1 L 3.96875,-10.28125 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-6"
overflow="visible"
style="overflow:visible">
<path
id="path444"
d="M 3.109375,-8.1875 5,0 H 7.15625 L 9.015625,-8.1875 V 0 h 2.15625 v -10.5 h -3.25 L 6.078125,-2.140625 4.171875,-10.5 H 0.953125 V 0 h 2.15625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-7"
overflow="visible"
style="overflow:visible">
<path
id="path447"
d="M 6.03125,-3.890625 9.359375,-10.5 H 6.9375 l -2,4.640625 L 2.796875,-10.5 H 0.390625 L 3.875,-3.890625 V 0 h 2.15625 z m 0,0"
style="stroke:none" />
</symbol>
</g>
<g
id="g6718">
<symbol
id="glyph0-0-8"
overflow="visible"
style="overflow:visible">
<path
id="path6685"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph0-1-9"
overflow="visible"
style="overflow:visible">
<path
id="path6688"
d="M 8.1875,-3.78125 9.484375,0 H 11.28125 L 6.859375,-12.59375 H 4.78125 L 0.296875,0 H 2 L 3.328125,-3.78125 Z M 7.734375,-5.125 h -4 l 2.078125,-5.75 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-2-73"
overflow="visible"
style="overflow:visible">
<path
id="path6691"
d="M 9.546875,-12.59375 V -3.75 c 0,1.6875 -1.234375,2.734375 -3.25,2.734375 -0.9375,0 -1.703125,-0.234375 -2.3125,-0.65625 C 3.375,-2.15625 3.078125,-2.796875 3.078125,-3.75 v -8.84375 H 1.46875 V -3.75 c 0,2.5625 1.828125,4.140625 4.828125,4.140625 2.953125,0 4.84375,-1.625 4.84375,-4.140625 v -8.84375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-3-6"
overflow="visible"
style="overflow:visible">
<path
id="path6694"
d="M 3.296875,-1.796875 H 1.5 V 0 h 1.796875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-4-1"
overflow="visible"
style="overflow:visible">
<path
id="path6697"
d="m 4.75,-12.5 c -1.140625,0 -2.171875,0.53125 -2.8125,1.375 -0.796875,1.109375 -1.1875,2.765625 -1.1875,5.078125 0,4.21875 1.375,6.4375 4,6.4375 2.59375,0 4.015625,-2.21875 4.015625,-6.328125 C 8.765625,-8.359375 8.375,-9.984375 7.5625,-11.125 6.9375,-12 5.90625,-12.5 4.75,-12.5 Z m 0,1.359375 c 1.640625,0 2.453125,1.671875 2.453125,5.0625 0,3.5625 -0.796875,5.21875 -2.484375,5.21875 -1.609375,0 -2.421875,-1.734375 -2.421875,-5.171875 0,-3.4375 0.8125,-5.109375 2.453125,-5.109375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-5-2"
overflow="visible"
style="overflow:visible">
<path
id="path6700"
d="M 8.75,-1.5 H 2.296875 C 2.453125,-2.546875 3,-3.203125 4.515625,-4.109375 l 1.71875,-0.96875 c 1.71875,-0.953125 2.59375,-2.234375 2.59375,-3.765625 0,-1.046875 -0.40625,-2.015625 -1.140625,-2.6875 C 6.96875,-12.1875 6.0625,-12.5 4.90625,-12.5 c -1.546875,0 -2.71875,0.5625 -3.390625,1.625 -0.421875,0.65625 -0.609375,1.4375 -0.65625,2.703125 h 1.53125 C 2.4375,-9.015625 2.546875,-9.515625 2.75,-9.9375 c 0.390625,-0.765625 1.1875,-1.21875 2.109375,-1.21875 1.375,0 2.421875,1 2.421875,2.34375 0,1 -0.578125,1.859375 -1.671875,2.484375 l -1.578125,0.9375 c -2.5625,1.46875 -3.3125,2.640625 -3.4375,5.375 H 8.75 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-6-9"
overflow="visible"
style="overflow:visible">
<path
id="path6703"
d="M 4.46875,-8.90625 V 0 H 6 V -12.5 H 5 c -0.546875,1.921875 -0.890625,2.1875 -3.234375,2.5 v 1.09375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-0-3"
overflow="visible"
style="overflow:visible">
<path
id="path6706"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph1-1-1"
overflow="visible"
style="overflow:visible">
<path
id="path6709"
d="M 3.25,-3.75 H 5.953125 C 7.875,-3.75 9.125,-5.109375 9.125,-7.25 9.125,-9.34375 7.921875,-10.5 5.734375,-10.5 H 1.09375 V 0 H 3.25 Z m 0,-1.796875 v -3.15625 h 2.015625 c 1.15625,0 1.6875,0.5 1.6875,1.578125 0,1.078125 -0.53125,1.578125 -1.6875,1.578125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-2-9"
overflow="visible"
style="overflow:visible">
<path
id="path6712"
d="M 0.96875,-10.5 V 0 H 2.984375 V -4.671875 C 2.984375,-5.5625 3.625,-6.1875 4.53125,-6.1875 c 0.453125,0 0.78125,0.15625 1.015625,0.46875 C 5.734375,-5.453125 5.78125,-5.25 5.78125,-4.75 V 0 H 7.796875 V -5.21875 C 7.796875,-6.1875 7.53125,-6.875 7,-7.3125 6.5625,-7.6875 5.90625,-7.90625 5.265625,-7.90625 c -1,0 -1.71875,0.390625 -2.28125,1.25 V -10.5 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-3-4"
overflow="visible"
style="overflow:visible">
<path
id="path6715"
d="M 7.671875,-4.1875 H 5.0625 v -2.625 H 3.34375 v 2.625 h -2.625 v 1.703125 h 2.625 v 2.625 H 5.0625 v -2.625 h 2.609375 z m 0,0"
style="stroke:none" />
</symbol>
</g>
<g
id="g13143">
<symbol
id="glyph0-0-5"
overflow="visible"
style="overflow:visible">
<path
id="path12930"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph0-1-0"
overflow="visible"
style="overflow:visible">
<path
id="path12933"
d="M 8.1875,-3.78125 9.484375,0 H 11.28125 L 6.859375,-12.59375 H 4.78125 L 0.296875,0 H 2 L 3.328125,-3.78125 Z M 7.734375,-5.125 h -4 l 2.078125,-5.75 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-2-3"
overflow="visible"
style="overflow:visible">
<path
id="path12936"
d="M 9.546875,-12.59375 V -3.75 c 0,1.6875 -1.234375,2.734375 -3.25,2.734375 -0.9375,0 -1.703125,-0.234375 -2.3125,-0.65625 C 3.375,-2.15625 3.078125,-2.796875 3.078125,-3.75 v -8.84375 H 1.46875 V -3.75 c 0,2.5625 1.828125,4.140625 4.828125,4.140625 2.953125,0 4.84375,-1.625 4.84375,-4.140625 v -8.84375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-3-61"
overflow="visible"
style="overflow:visible">
<path
id="path12939"
d="M 3.296875,-1.796875 H 1.5 V 0 h 1.796875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-4-0"
overflow="visible"
style="overflow:visible">
<path
id="path12942"
d="m 4.75,-12.5 c -1.140625,0 -2.171875,0.53125 -2.8125,1.375 -0.796875,1.109375 -1.1875,2.765625 -1.1875,5.078125 0,4.21875 1.375,6.4375 4,6.4375 2.59375,0 4.015625,-2.21875 4.015625,-6.328125 C 8.765625,-8.359375 8.375,-9.984375 7.5625,-11.125 6.9375,-12 5.90625,-12.5 4.75,-12.5 Z m 0,1.359375 c 1.640625,0 2.453125,1.671875 2.453125,5.0625 0,3.5625 -0.796875,5.21875 -2.484375,5.21875 -1.609375,0 -2.421875,-1.734375 -2.421875,-5.171875 0,-3.4375 0.8125,-5.109375 2.453125,-5.109375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-5-63"
overflow="visible"
style="overflow:visible">
<path
id="path12945"
d="M 8.75,-1.5 H 2.296875 C 2.453125,-2.546875 3,-3.203125 4.515625,-4.109375 l 1.71875,-0.96875 c 1.71875,-0.953125 2.59375,-2.234375 2.59375,-3.765625 0,-1.046875 -0.40625,-2.015625 -1.140625,-2.6875 C 6.96875,-12.1875 6.0625,-12.5 4.90625,-12.5 c -1.546875,0 -2.71875,0.5625 -3.390625,1.625 -0.421875,0.65625 -0.609375,1.4375 -0.65625,2.703125 h 1.53125 C 2.4375,-9.015625 2.546875,-9.515625 2.75,-9.9375 c 0.390625,-0.765625 1.1875,-1.21875 2.109375,-1.21875 1.375,0 2.421875,1 2.421875,2.34375 0,1 -0.578125,1.859375 -1.671875,2.484375 l -1.578125,0.9375 c -2.5625,1.46875 -3.3125,2.640625 -3.4375,5.375 H 8.75 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-6-20"
overflow="visible"
style="overflow:visible">
<path
id="path12948"
d="M 4.46875,-8.90625 V 0 H 6 V -12.5 H 5 c -0.546875,1.921875 -0.890625,2.1875 -3.234375,2.5 v 1.09375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-0-6"
overflow="visible"
style="overflow:visible">
<path
id="path12951"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph1-1-15"
overflow="visible"
style="overflow:visible">
<path
id="path12954"
d="M 3.25,-3.75 H 5.953125 C 7.875,-3.75 9.125,-5.109375 9.125,-7.25 9.125,-9.34375 7.921875,-10.5 5.734375,-10.5 H 1.09375 V 0 H 3.25 Z m 0,-1.796875 v -3.15625 h 2.015625 c 1.15625,0 1.6875,0.5 1.6875,1.578125 0,1.078125 -0.53125,1.578125 -1.6875,1.578125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-2-5"
overflow="visible"
style="overflow:visible">
<path
id="path12957"
d="M 0.96875,-10.5 V 0 H 2.984375 V -4.671875 C 2.984375,-5.5625 3.625,-6.1875 4.53125,-6.1875 c 0.453125,0 0.78125,0.15625 1.015625,0.46875 C 5.734375,-5.453125 5.78125,-5.25 5.78125,-4.75 V 0 H 7.796875 V -5.21875 C 7.796875,-6.1875 7.53125,-6.875 7,-7.3125 6.5625,-7.6875 5.90625,-7.90625 5.265625,-7.90625 c -1,0 -1.71875,0.390625 -2.28125,1.25 V -10.5 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-3-47"
overflow="visible"
style="overflow:visible">
<path
id="path12960"
d="M 7.671875,-4.1875 H 5.0625 v -2.625 H 3.34375 v 2.625 h -2.625 v 1.703125 h 2.625 v 2.625 H 5.0625 v -2.625 h 2.609375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-0"
overflow="visible"
style="overflow:visible">
<path
id="path12963"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph2-1"
overflow="visible"
style="overflow:visible">
<path
id="path12966"
d="m 2.65625,-4.453125 h 3.296875 c 0.8125,0 1.46875,-0.25 2.03125,-0.75 0.625,-0.578125 0.90625,-1.25 0.90625,-2.21875 0,-1.96875 -1.171875,-3.078125 -3.25,-3.078125 H 1.3125 V 0 h 1.34375 z m 0,-1.1875 v -3.6875 h 2.796875 c 1.28125,0 2.03125,0.703125 2.03125,1.84375 0,1.15625 -0.75,1.84375 -2.03125,1.84375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-2"
overflow="visible"
style="overflow:visible">
<path
id="path12969"
d="M 1,-7.546875 V 0 H 2.203125 V -3.921875 C 2.21875,-5.734375 2.96875,-6.546875 4.625,-6.5 V -7.71875 C 4.421875,-7.75 4.3125,-7.765625 4.15625,-7.765625 c -0.765625,0 -1.359375,0.46875 -2.046875,1.578125 v -1.359375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-3"
overflow="visible"
style="overflow:visible">
<path
id="path12972"
d="m 3.921875,-7.765625 c -2.140625,0 -3.40625,1.515625 -3.40625,4.046875 0,2.546875 1.265625,4.046875 3.421875,4.046875 2.125,0 3.40625,-1.515625 3.40625,-3.984375 0,-2.625 -1.234375,-4.109375 -3.421875,-4.109375 z M 3.9375,-6.65625 c 1.34375,0 2.15625,1.109375 2.15625,2.984375 0,1.78125 -0.828125,2.890625 -2.15625,2.890625 -1.34375,0 -2.171875,-1.109375 -2.171875,-2.9375 0,-1.828125 0.828125,-2.9375 2.171875,-2.9375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-4"
overflow="visible"
style="overflow:visible">
<path
id="path12975"
d="m 4.203125,-3.90625 2.53125,-3.640625 H 5.390625 L 3.578125,-4.8125 1.75,-7.546875 H 0.390625 L 2.90625,-3.84375 0.25,0 H 1.609375 L 3.53125,-2.890625 5.421875,0 H 6.8125 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-5"
overflow="visible"
style="overflow:visible">
<path
id="path12978"
d="M 2.15625,-7.546875 H 0.96875 V 0 h 1.1875 z m 0,-2.953125 H 0.953125 v 1.515625 H 2.15625 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-6"
overflow="visible"
style="overflow:visible">
<path
id="path12981"
d="M 1.015625,-7.546875 V 0 H 2.21875 v -4.734375 c 0,-1.09375 0.796875,-1.984375 1.765625,-1.984375 0.90625,0 1.40625,0.546875 1.40625,1.515625 V 0 H 6.59375 v -4.734375 c 0,-1.09375 0.796875,-1.984375 1.78125,-1.984375 0.875,0 1.390625,0.5625 1.390625,1.515625 V 0 h 1.21875 v -5.65625 c 0,-1.359375 -0.78125,-2.109375 -2.203125,-2.109375 -1,0 -1.609375,0.296875 -2.3125,1.15625 -0.453125,-0.8125 -1.046875,-1.15625 -2.03125,-1.15625 -1.015625,0 -1.6875,0.375 -2.3125,1.28125 v -1.0625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-7"
overflow="visible"
style="overflow:visible">
<path
id="path12984"
d="M 3.65625,-7.546875 H 2.421875 V -9.625 H 1.21875 v 2.078125 H 0.203125 V -6.5625 H 1.21875 v 5.703125 c 0,0.765625 0.53125,1.1875 1.453125,1.1875 C 3,0.328125 3.25,0.296875 3.65625,0.234375 V -0.78125 c -0.171875,0.046875 -0.328125,0.0625 -0.578125,0.0625 -0.515625,0 -0.65625,-0.140625 -0.65625,-0.671875 V -6.5625 H 3.65625 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-8"
overflow="visible"
style="overflow:visible">
<path
id="path12987"
d="m 5.59375,-7.546875 -2.09375,5.875 -1.9375,-5.875 H 0.28125 L 2.84375,0.03125 2.375,1.21875 C 2.171875,1.75 1.921875,1.953125 1.40625,1.953125 1.203125,1.953125 1.03125,1.9375 0.78125,1.875 v 1.078125 c 0.234375,0.125 0.484375,0.1875 0.796875,0.1875 0.390625,0 0.8125,-0.125 1.125,-0.359375 C 3.078125,2.5 3.296875,2.1875 3.53125,1.578125 l 3.359375,-9.125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-9"
overflow="visible"
style="overflow:visible">
<path
id="path12990"
d="m 3.078125,-1.5 h -1.5 V 0 h 1.5 z m 0,-6.046875 h -1.5 v 1.5 h 1.5 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-10"
overflow="visible"
style="overflow:visible">
<path
id="path12993"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph2-11"
overflow="visible"
style="overflow:visible">
<path
id="path12996"
d="m 0.765625,-2.375 c 0.25,1.703125 1.34375,2.703125 2.890625,2.703125 1.140625,0 2.15625,-0.546875 2.75,-1.484375 0.640625,-1.015625 0.921875,-2.28125 0.921875,-4.171875 0,-1.765625 -0.25,-2.875 -0.859375,-3.796875 -0.5625,-0.84375 -1.453125,-1.296875 -2.578125,-1.296875 -1.953125,0 -3.34375,1.46875 -3.34375,3.484375 0,1.90625 1.296875,3.265625 3.140625,3.265625 0.96875,0 1.6875,-0.34375 2.328125,-1.140625 C 6,-2.21875 5.203125,-0.796875 3.75,-0.796875 2.859375,-0.796875 2.234375,-1.375 2.03125,-2.375 Z M 3.875,-9.3125 c 1.1875,0 2.078125,1 2.078125,2.34375 0,1.28125 -0.875,2.171875 -2.125,2.171875 -1.21875,0 -1.984375,-0.859375 -1.984375,-2.25 0,-1.3125 0.84375,-2.265625 2.03125,-2.265625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-12"
overflow="visible"
style="overflow:visible">
<path
id="path12999"
d="m 5.640625,-5.484375 c 1.0625,-0.65625 1.390625,-1.171875 1.390625,-2.15625 0,-1.640625 -1.25,-2.78125 -3.0625,-2.78125 -1.8125,0 -3.078125,1.140625 -3.078125,2.765625 0,1 0.328125,1.5 1.390625,2.171875 -1.171875,0.59375 -1.75,1.4375 -1.75,2.59375 0,1.890625 1.40625,3.21875 3.4375,3.21875 2.015625,0 3.421875,-1.328125 3.421875,-3.21875 0,-1.15625 -0.578125,-2 -1.75,-2.59375 z m -1.671875,-3.8125 c 1.078125,0 1.765625,0.65625 1.765625,1.6875 0,0.984375 -0.703125,1.625 -1.765625,1.625 -1.09375,0 -1.78125,-0.640625 -1.78125,-1.65625 0,-1 0.6875,-1.65625 1.78125,-1.65625 z m 0,4.390625 c 1.265625,0 2.125,0.828125 2.125,2.046875 0,1.25 -0.84375,2.0625 -2.15625,2.0625 -1.25,0 -2.109375,-0.84375 -2.109375,-2.0625 0,-1.234375 0.84375,-2.046875 2.140625,-2.046875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-13"
overflow="visible"
style="overflow:visible">
<path
id="path13002"
d="m 2.859375,-9.875 c -1.34375,0 -2.4375,1.109375 -2.4375,2.46875 0,1.359375 1.09375,2.46875 2.453125,2.46875 1.34375,0 2.453125,-1.109375 2.453125,-2.4375 0,-1.390625 -1.078125,-2.5 -2.46875,-2.5 z m 0,1.015625 c 0.828125,0 1.484375,0.640625 1.484375,1.46875 0,0.796875 -0.671875,1.4375 -1.46875,1.4375 -0.796875,0 -1.46875,-0.640625 -1.46875,-1.453125 0,-0.8125 0.65625,-1.453125 1.453125,-1.453125 z m 5.90625,-1.359375 -5.6875,10.5 H 4.03125 l 5.6875,-10.5 z m 1.140625,5.578125 c -1.34375,0 -2.4375,1.09375 -2.4375,2.453125 0,1.359375 1.09375,2.46875 2.453125,2.46875 1.34375,0 2.453125,-1.109375 2.453125,-2.4375 0,-1.390625 -1.078125,-2.484375 -2.46875,-2.484375 z m 0,1.015625 c 0.828125,0 1.46875,0.640625 1.46875,1.46875 0,0.765625 -0.65625,1.421875 -1.453125,1.421875 -0.8125,0 -1.46875,-0.65625 -1.46875,-1.453125 0,-0.796875 0.65625,-1.4375 1.453125,-1.4375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-14"
overflow="visible"
style="overflow:visible">
<path
id="path13005"
d="m 2.640625,-4.78125 h 5.71875 v -1.1875 h -5.71875 v -3.359375 h 5.9375 V -10.5 H 1.296875 V 0 h 7.53125 v -1.1875 h -6.1875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-15"
overflow="visible"
style="overflow:visible">
<path
id="path13008"
d="m 6.78125,-5.015625 c -0.046875,-0.734375 -0.21875,-1.203125 -0.5,-1.625 -0.515625,-0.703125 -1.421875,-1.125 -2.484375,-1.125 -2.046875,0 -3.34375,1.609375 -3.34375,4.125 0,2.4375 1.296875,3.96875 3.328125,3.96875 1.8125,0 2.953125,-1.078125 3.09375,-2.921875 H 5.65625 c -0.203125,1.203125 -0.8125,1.8125 -1.84375,1.8125 -1.3125,0 -2.109375,-1.078125 -2.109375,-2.859375 0,-1.890625 0.78125,-3.015625 2.078125,-3.015625 1.015625,0 1.65625,0.59375 1.796875,1.640625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-16"
overflow="visible"
style="overflow:visible">
<path
id="path13011"
d="M 2.1875,-10.5 H 0.984375 V 0 H 2.1875 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-17"
overflow="visible"
style="overflow:visible">
<path
id="path13014"
d="M 6.9375,0 V -7.546875 H 5.75 v 4.28125 c 0,1.53125 -0.8125,2.546875 -2.0625,2.546875 -0.953125,0 -1.5625,-0.578125 -1.5625,-1.484375 v -5.34375 H 0.9375 v 5.8125 c 0,1.265625 0.9375,2.0625 2.40625,2.0625 1.109375,0 1.8125,-0.390625 2.515625,-1.375 V 0 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-18"
overflow="visible"
style="overflow:visible">
<path
id="path13017"
d="m 6.3125,-5.453125 c -0.015625,-1.46875 -1,-2.3125 -2.734375,-2.3125 -1.765625,0 -2.90625,0.90625 -2.90625,2.3125 0,1.171875 0.609375,1.734375 2.390625,2.171875 l 1.125,0.265625 C 5.03125,-2.8125 5.359375,-2.5 5.359375,-1.96875 c 0,0.71875 -0.703125,1.1875 -1.765625,1.1875 -0.640625,0 -1.1875,-0.1875 -1.484375,-0.5 C 1.921875,-1.5 1.828125,-1.71875 1.75,-2.25 H 0.484375 C 0.546875,-0.5 1.53125,0.328125 3.5,0.328125 c 1.90625,0 3.109375,-0.9375 3.109375,-2.390625 0,-1.125 -0.625,-1.734375 -2.125,-2.09375 L 3.328125,-4.4375 C 2.34375,-4.671875 1.9375,-4.984375 1.9375,-5.515625 c 0,-0.703125 0.609375,-1.140625 1.59375,-1.140625 0.96875,0 1.484375,0.421875 1.515625,1.203125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-19"
overflow="visible"
style="overflow:visible">
<path
id="path13020"
d="M 4.109375,0 7,-7.546875 H 5.640625 l -2.125,6.125 L 1.5,-7.546875 H 0.140625 L 2.796875,0 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-20"
overflow="visible"
style="overflow:visible">
<path
id="path13023"
d="M 3.734375,-7.421875 V 0 H 5 V -10.421875 H 4.15625 C 3.71875,-8.8125 3.421875,-8.59375 1.46875,-8.34375 v 0.921875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-21"
overflow="visible"
style="overflow:visible">
<path
id="path13026"
d="m 3.96875,-10.421875 c -0.953125,0 -1.828125,0.4375 -2.359375,1.140625 -0.65625,0.921875 -0.984375,2.3125 -0.984375,4.234375 0,3.515625 1.140625,5.375 3.34375,5.375 2.15625,0 3.328125,-1.859375 3.328125,-5.28125 0,-2.015625 -0.3125,-3.375 -0.984375,-4.328125 C 5.78125,-10 4.921875,-10.421875 3.96875,-10.421875 Z m 0,1.125 c 1.359375,0 2.03125,1.40625 2.03125,4.21875 0,2.96875 -0.65625,4.359375 -2.0625,4.359375 -1.34375,0 -2.015625,-1.4375 -2.015625,-4.3125 0,-2.859375 0.671875,-4.265625 2.046875,-4.265625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-22"
overflow="visible"
style="overflow:visible">
<path
id="path13029"
d="M 9.53125,-7.25 C 9.125,-9.546875 7.796875,-10.671875 5.484375,-10.671875 c -1.40625,0 -2.546875,0.4375 -3.328125,1.3125 -0.953125,1.03125 -1.46875,2.53125 -1.46875,4.234375 0,1.71875 0.53125,3.203125 1.515625,4.234375 0.828125,0.828125 1.859375,1.21875 3.234375,1.21875 2.5625,0 4,-1.375 4.3125,-4.15625 H 8.375 C 8.25,-3.109375 8.109375,-2.625 7.890625,-2.203125 7.46875,-1.34375 6.5625,-0.84375 5.453125,-0.84375 3.359375,-0.84375 2.03125,-2.515625 2.03125,-5.140625 2.03125,-7.84375 3.28125,-9.5 5.328125,-9.5 6.1875,-9.5 6.96875,-9.25 7.40625,-8.828125 7.796875,-8.46875 8.015625,-8.03125 8.171875,-7.25 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-23"
overflow="visible"
style="overflow:visible">
<path
id="path13032"
d="m 7.703125,-0.703125 c -0.125,0.03125 -0.1875,0.03125 -0.25,0.03125 -0.421875,0 -0.65625,-0.21875 -0.65625,-0.59375 v -4.4375 c 0,-1.34375 -0.984375,-2.0625 -2.828125,-2.0625 -1.109375,0 -2,0.3125 -2.515625,0.875 C 1.109375,-6.5 0.96875,-6.0625 0.9375,-5.3125 h 1.203125 c 0.109375,-0.921875 0.65625,-1.34375 1.78125,-1.34375 1.09375,0 1.6875,0.40625 1.6875,1.125 v 0.3125 C 5.59375,-4.703125 5.328125,-4.515625 4.34375,-4.375 2.65625,-4.15625 2.390625,-4.109375 1.9375,-3.921875 1.046875,-3.546875 0.609375,-2.875 0.609375,-1.90625 c 0,1.375 0.953125,2.234375 2.46875,2.234375 0.953125,0 1.71875,-0.328125 2.5625,-1.109375 0.09375,0.78125 0.46875,1.109375 1.25,1.109375 0.25,0 0.40625,-0.03125 0.8125,-0.125 z M 5.609375,-2.375 c 0,0.40625 -0.125,0.640625 -0.484375,0.984375 -0.484375,0.4375 -1.078125,0.671875 -1.78125,0.671875 -0.9375,0 -1.484375,-0.453125 -1.484375,-1.21875 0,-0.78125 0.515625,-1.1875 1.8125,-1.375 1.28125,-0.171875 1.53125,-0.234375 1.9375,-0.421875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-24"
overflow="visible"
style="overflow:visible">
<path
id="path13035"
d="m 7.390625,-3.375 c 0,-1.15625 -0.09375,-1.84375 -0.296875,-2.40625 -0.5,-1.234375 -1.640625,-1.984375 -3.0625,-1.984375 -2.09375,0 -3.453125,1.59375 -3.453125,4.09375 0,2.484375 1.296875,4 3.421875,4 1.734375,0 2.921875,-0.96875 3.234375,-2.625 h -1.21875 c -0.328125,1 -1,1.515625 -1.96875,1.515625 -0.765625,0 -1.40625,-0.34375 -1.8125,-0.96875 C 1.9375,-2.1875 1.84375,-2.625 1.828125,-3.375 Z m -5.53125,-0.96875 c 0.09375,-1.40625 0.953125,-2.3125 2.15625,-2.3125 1.234375,0 2.078125,0.953125 2.078125,2.3125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-25"
overflow="visible"
style="overflow:visible">
<path
id="path13038"
d="m 5.8125,-7.546875 v 1.09375 c -0.59375,-0.90625 -1.265625,-1.3125 -2.21875,-1.3125 -1.828125,0 -3.09375,1.703125 -3.09375,4.125 0,1.265625 0.3125,2.1875 0.953125,2.953125 0.5625,0.65625 1.28125,1.015625 2.0625,1.015625 0.90625,0 1.5625,-0.40625 2.1875,-1.34375 v 0.375 c 0,2.03125 -0.5625,2.765625 -2.0625,2.765625 C 2.625,2.125 2.09375,1.734375 1.96875,0.859375 H 0.75 c 0.109375,1.40625 1.21875,2.28125 2.859375,2.28125 1.109375,0 2.03125,-0.359375 2.53125,-0.96875 0.578125,-0.703125 0.78125,-1.640625 0.78125,-3.40625 v -6.3125 z M 3.71875,-6.65625 c 1.265625,0 1.984375,1.0625 1.984375,2.984375 0,1.828125 -0.734375,2.890625 -1.984375,2.890625 -1.234375,0 -1.96875,-1.078125 -1.96875,-2.9375 0,-1.84375 0.734375,-2.9375 1.96875,-2.9375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-26"
overflow="visible"
style="overflow:visible">
<path
id="path13041"
d="M 1.140625,0 H 5.875 c 1,0 1.734375,-0.28125 2.296875,-0.875 C 8.6875,-1.421875 8.96875,-2.171875 8.96875,-3 8.96875,-4.265625 8.40625,-5.03125 7.0625,-5.546875 8.03125,-6 8.515625,-6.75 8.515625,-7.84375 c 0,-0.765625 -0.296875,-1.4375 -0.84375,-1.921875 C 7.109375,-10.265625 6.40625,-10.5 5.40625,-10.5 H 1.140625 Z m 1.34375,-5.984375 v -3.34375 h 2.59375 c 0.734375,0 1.15625,0.109375 1.515625,0.375 0.375,0.296875 0.578125,0.734375 0.578125,1.296875 0,0.578125 -0.203125,1.015625 -0.578125,1.296875 -0.359375,0.28125 -0.78125,0.375 -1.515625,0.375 z m 0,4.796875 V -4.796875 H 5.75 c 1.171875,0 1.890625,0.671875 1.890625,1.8125 0,1.125 -0.71875,1.796875 -1.890625,1.796875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-27"
overflow="visible"
style="overflow:visible">
<path
id="path13044"
d="M 2.5,-10.5 H 1.15625 V 0 H 7.671875 V -1.1875 H 2.5 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-28"
overflow="visible"
style="overflow:visible">
<path
id="path13047"
d="m 7.296875,-1.25 h -5.375 C 2.046875,-2.125 2.5,-2.671875 3.765625,-3.421875 l 1.4375,-0.8125 C 6.625,-5.03125 7.359375,-6.09375 7.359375,-7.375 c 0,-0.859375 -0.34375,-1.671875 -0.953125,-2.234375 -0.59375,-0.546875 -1.34375,-0.8125 -2.3125,-0.8125 -1.296875,0 -2.265625,0.46875 -2.828125,1.359375 C 0.90625,-8.515625 0.75,-7.859375 0.71875,-6.8125 H 1.984375 C 2.03125,-7.515625 2.125,-7.9375 2.296875,-8.28125 2.625,-8.921875 3.28125,-9.3125 4.046875,-9.3125 c 1.15625,0 2.015625,0.84375 2.015625,1.96875 0,0.828125 -0.46875,1.546875 -1.375,2.078125 L 3.359375,-4.5 c -2.140625,1.234375 -2.75,2.203125 -2.875,4.484375 h 6.8125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-29"
overflow="visible"
style="overflow:visible">
<path
id="path13050"
d="m 3.296875,-10.5 -3.40625,10.78125 h 0.78125 L 4.09375,-10.5 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-30"
overflow="visible"
style="overflow:visible">
<path
id="path13053"
d="m 6.734375,0 2.96875,-8.796875 V 0 H 10.96875 V -10.5 H 9.109375 L 6.046875,-1.359375 2.9375,-10.5 H 1.078125 V 0 H 2.34375 V -8.796875 L 5.328125,0 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-31"
overflow="visible"
style="overflow:visible">
<path
id="path13056"
d="m 5.578125,-4.125 3.9375,-6.375 h -1.59375 l -3,5.109375 L 1.84375,-10.5 H 0.1875 l 4.046875,6.375 V 0 h 1.34375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-32"
overflow="visible"
style="overflow:visible">
<path
id="path13059"
d="m 2.671875,-4.53125 h 3.46875 c 1.1875,0 1.71875,0.578125 1.71875,1.875 l -0.015625,0.9375 c 0,0.65625 0.125,1.28125 0.3125,1.71875 h 1.625 v -0.328125 c -0.5,-0.34375 -0.609375,-0.71875 -0.640625,-2.125 0,-1.71875 -0.28125,-2.25 -1.421875,-2.734375 C 8.90625,-5.78125 9.375,-6.484375 9.375,-7.6875 9.375,-9.515625 8.25,-10.5 6.1875,-10.5 H 1.34375 V 0 h 1.328125 z m 0,-1.171875 v -3.625 h 3.25 c 0.75,0 1.1875,0.125 1.515625,0.40625 0.359375,0.3125 0.546875,0.78125 0.546875,1.40625 0,1.25 -0.640625,1.8125 -2.0625,1.8125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-33"
overflow="visible"
style="overflow:visible">
<path
id="path13062"
d="M 2.640625,-4.78125 H 7.65625 v -1.1875 H 2.640625 V -9.328125 H 8.34375 V -10.5 H 1.296875 V 0 h 1.34375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-34"
overflow="visible"
style="overflow:visible">
<path
id="path13065"
d="m 1.28125,0 h 4.046875 c 2.65625,0 4.28125,-1.984375 4.28125,-5.265625 C 9.609375,-8.515625 8,-10.5 5.328125,-10.5 H 1.28125 Z M 2.625,-1.1875 v -8.140625 h 2.46875 c 2.078125,0 3.171875,1.40625 3.171875,4.078125 0,2.671875 -1.09375,4.0625 -3.171875,4.0625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-35"
overflow="visible"
style="overflow:visible">
<path
id="path13068"
d="m 7.953125,-10.5 v 7.375 c 0,1.40625 -1.03125,2.28125 -2.703125,2.28125 -0.78125,0 -1.421875,-0.1875 -1.921875,-0.546875 C 2.8125,-1.796875 2.5625,-2.328125 2.5625,-3.125 V -10.5 H 1.21875 v 7.375 C 1.21875,-1 2.75,0.328125 5.25,0.328125 c 2.453125,0 4.046875,-1.34375 4.046875,-3.453125 V -10.5 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-36"
overflow="visible"
style="overflow:visible">
<path
id="path13071"
d="M 5.640625,-5.390625 9.171875,-10.5 H 7.578125 L 4.875,-6.375 2.171875,-10.5 h -1.625 L 4.03125,-5.390625 0.3125,0 h 1.625 L 4.828125,-4.375 7.6875,0 h 1.65625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-37"
overflow="visible"
style="overflow:visible">
<path
id="path13074"
d="M 4.703125,-2.515625 V 0 h 1.28125 v -2.515625 h 1.5 V -3.65625 h -1.5 v -6.765625 h -0.9375 l -4.640625,6.5625 v 1.34375 z m 0,-1.140625 h -3.1875 L 4.703125,-8.25 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-38"
overflow="visible"
style="overflow:visible">
<path
id="path13077"
d="M 5.09375,-9.328125 H 8.546875 V -10.5 h -8.25 v 1.171875 h 3.46875 V 0 H 5.09375 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-39"
overflow="visible"
style="overflow:visible">
<path
id="path13080"
d="m 5.640625,0 3.65625,-10.5 h -1.4375 L 4.953125,-1.609375 1.875,-10.5 H 0.4375 L 4.203125,0 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-40"
overflow="visible"
style="overflow:visible">
<path
id="path13083"
d="m 7.171875,-7.703125 c -0.25,-1.703125 -1.34375,-2.71875 -2.890625,-2.71875 -1.125,0 -2.140625,0.546875 -2.734375,1.484375 C 0.890625,-7.90625 0.625,-6.640625 0.625,-4.75 c 0,1.75 0.234375,2.859375 0.859375,3.78125 0.546875,0.859375 1.4375,1.296875 2.5625,1.296875 1.953125,0 3.34375,-1.453125 3.34375,-3.484375 0,-1.921875 -1.296875,-3.265625 -3.125,-3.265625 -1.015625,0 -1.796875,0.375 -2.34375,1.140625 0.015625,-2.578125 0.8125,-4.015625 2.265625,-4.015625 0.890625,0 1.515625,0.578125 1.71875,1.59375 z m -3.0625,2.40625 c 1.21875,0 1.984375,0.859375 1.984375,2.25 0,1.296875 -0.859375,2.25 -2.03125,2.25 -1.1875,0 -2.078125,-0.984375 -2.078125,-2.3125 0,-1.296875 0.875,-2.1875 2.125,-2.1875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-41"
overflow="visible"
style="overflow:visible">
<path
id="path13086"
d="m 4.09375,-4.5 h -3.4375 v 1.046875 h 3.4375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-42"
overflow="visible"
style="overflow:visible">
<path
id="path13089"
d="M 9.3125,-10.5 H 8.03125 v 8.578125 L 2.546875,-10.5 H 1.09375 V 0 H 2.359375 V -8.515625 L 7.796875,0 H 9.3125 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-43"
overflow="visible"
style="overflow:visible">
<path
id="path13092"
d="M 7.9375,-4.78125 V 0 H 9.28125 V -10.5 H 7.9375 v 4.53125 H 2.53125 V -10.5 H 1.203125 V 0 H 2.53125 v -4.78125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-44"
overflow="visible"
style="overflow:visible">
<path
id="path13095"
d="m 0.78125,3.140625 h 1.203125 v -3.9375 c 0.640625,0.78125 1.34375,1.125 2.328125,1.125 1.953125,0 3.21875,-1.5625 3.21875,-3.96875 0,-2.546875 -1.234375,-4.125 -3.234375,-4.125 -1.03125,0 -1.84375,0.46875 -2.40625,1.359375 V -7.546875 H 0.78125 Z m 3.3125,-9.78125 c 1.328125,0 2.1875,1.171875 2.1875,2.96875 0,1.71875 -0.875,2.875 -2.1875,2.875 -1.28125,0 -2.109375,-1.140625 -2.109375,-2.921875 0,-1.765625 0.828125,-2.921875 2.109375,-2.921875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-45"
overflow="visible"
style="overflow:visible">
<path
id="path13098"
d="M 7.125,-10.5 H 5.9375 v 3.90625 C 5.4375,-7.359375 4.625,-7.765625 3.609375,-7.765625 1.65625,-7.765625 0.375,-6.1875 0.375,-3.78125 c 0,2.546875 1.234375,4.109375 3.28125,4.109375 C 4.703125,0.328125 5.421875,-0.0625 6.0625,-1 V 0 H 7.125 Z m -3.3125,3.859375 c 1.296875,0 2.125,1.140625 2.125,2.953125 0,1.75 -0.84375,2.890625 -2.109375,2.890625 C 2.5,-0.796875 1.625,-1.953125 1.625,-3.71875 c 0,-1.75 0.875,-2.921875 2.1875,-2.921875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-46"
overflow="visible"
style="overflow:visible">
<path
id="path13101"
d="M 6.828125,-3.15625 7.90625,0 h 1.5 L 5.71875,-10.5 H 3.984375 L 0.25,0 H 1.671875 L 2.78125,-3.15625 Z m -0.375,-1.125 H 3.109375 L 4.84375,-9.0625 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-47"
overflow="visible"
style="overflow:visible">
<path
id="path13104"
d="M 2.796875,-10.5 H 1.4375 V 0 h 1.359375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-48"
overflow="visible"
style="overflow:visible">
<path
id="path13107"
d="M 2.484375,-3.671875 4.1875,-5.390625 7.890625,0 h 1.59375 L 5.15625,-6.21875 9.4375,-10.5 H 7.703125 l -5.21875,5.3125 V -10.5 H 1.140625 V 0 h 1.34375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-49"
overflow="visible"
style="overflow:visible">
<path
id="path13110"
d="M 8.375,-10.5 H 0.8125 v 1.171875 H 6.71875 L 0.40625,-1.1875 V 0 h 8 V -1.1875 H 2.09375 L 8.375,-9.296875 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-50"
overflow="visible"
style="overflow:visible">
<path
id="path13113"
d="m 6.859375,-10.21875 h -5.28125 l -0.75,5.5625 h 1.15625 C 2.578125,-5.359375 3.0625,-5.609375 3.875,-5.609375 c 1.375,0 2.21875,0.9375 2.21875,2.453125 0,1.46875 -0.84375,2.359375 -2.234375,2.359375 -1.109375,0 -1.78125,-0.5625 -2.09375,-1.703125 H 0.5 c 0.171875,0.828125 0.328125,1.234375 0.625,1.609375 0.578125,0.78125 1.609375,1.21875 2.765625,1.21875 2.0625,0 3.5,-1.5 3.5,-3.65625 0,-2.015625 -1.34375,-3.40625 -3.296875,-3.40625 -0.71875,0 -1.296875,0.1875 -1.890625,0.625 l 0.40625,-2.84375 h 4.25 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-51"
overflow="visible"
style="overflow:visible">
<path
id="path13116"
d="M 2.75,-1.5 H 1.25 V 0 h 1.5 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-52"
overflow="visible"
style="overflow:visible">
<path
id="path13119"
d="M 1.015625,-10.5 V 0 h 1.1875 v -4.15625 c 0,-1.546875 0.8125,-2.5625 2.046875,-2.5625 0.40625,0 0.78125,0.125 1.0625,0.34375 0.34375,0.25 0.5,0.609375 0.5,1.140625 V 0 H 7 v -5.703125 c 0,-1.265625 -0.90625,-2.0625 -2.375,-2.0625 -1.0625,0 -1.71875,0.328125 -2.421875,1.25 V -10.5 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-53"
overflow="visible"
style="overflow:visible">
<path
id="path13122"
d="M 7.6875,-3.84375 H 4.703125 v -2.984375 h -1 V -3.84375 H 0.71875 v 1 h 2.984375 v 2.984375 h 1 V -2.84375 H 7.6875 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-54"
overflow="visible"
style="overflow:visible">
<path
id="path13125"
d="M 3.1875,-4.796875 H 3.875 c 1.390625,0 2.125,0.640625 2.125,1.90625 0,1.3125 -0.796875,2.09375 -2.109375,2.09375 C 2.5,-0.796875 1.8125,-1.5 1.734375,-3.03125 H 0.46875 c 0.046875,0.84375 0.1875,1.390625 0.4375,1.84375 0.53125,1.015625 1.53125,1.515625 2.921875,1.515625 2.109375,0 3.46875,-1.265625 3.46875,-3.234375 0,-1.328125 -0.515625,-2.046875 -1.734375,-2.484375 C 6.515625,-5.78125 6.984375,-6.5 6.984375,-7.546875 c 0,-1.78125 -1.171875,-2.875 -3.109375,-2.875 -2.0625,0 -3.15625,1.15625 -3.203125,3.359375 H 1.9375 c 0.015625,-0.625 0.078125,-0.984375 0.234375,-1.3125 0.296875,-0.578125 0.921875,-0.9375 1.71875,-0.9375 1.125,0 1.796875,0.6875 1.796875,1.8125 0,0.734375 -0.25,1.171875 -0.8125,1.421875 C 4.53125,-5.9375 4.0625,-5.875 3.1875,-5.859375 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-55"
overflow="visible"
style="overflow:visible">
<path
id="path13128"
d="M 7.484375,-10.21875 H 0.65625 v 1.265625 H 6.1875 C 3.75,-5.484375 2.75,-3.359375 1.984375,0 H 3.34375 c 0.5625,-3.265625 1.84375,-6.078125 4.140625,-9.140625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-56"
overflow="visible"
style="overflow:visible">
<path
id="path13131"
d="M 10.21875,-5.546875 H 5.828125 v 1.1875 H 9.03125 v 0.28125 c 0,1.875 -1.375,3.234375 -3.296875,3.234375 -1.0625,0 -2.03125,-0.390625 -2.65625,-1.078125 -0.6875,-0.75 -1.109375,-2 -1.109375,-3.296875 0,-2.578125 1.46875,-4.28125 3.6875,-4.28125 1.609375,0 2.75,0.828125 3.046875,2.1875 H 10.0625 c -0.359375,-2.140625 -1.984375,-3.359375 -4.390625,-3.359375 -1.28125,0 -2.3125,0.328125 -3.140625,1 -1.21875,1.015625 -1.890625,2.640625 -1.890625,4.53125 0,3.21875 1.96875,5.46875 4.8125,5.46875 C 6.875,0.328125 8,-0.203125 9.03125,-1.34375 L 9.359375,0.0625 h 0.859375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-57"
overflow="visible"
style="overflow:visible">
<path
id="path13134"
d="M 1.015625,-7.546875 V 0 H 2.21875 v -4.15625 c 0,-1.546875 0.8125,-2.5625 2.046875,-2.5625 0.953125,0 1.546875,0.578125 1.546875,1.484375 V 0 h 1.203125 v -5.703125 c 0,-1.25 -0.9375,-2.0625 -2.390625,-2.0625 -1.125,0 -1.84375,0.4375 -2.5,1.484375 v -1.265625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-58"
overflow="visible"
style="overflow:visible">
<path
id="path13137"
d="m 5.609375,-10.671875 c -3.015625,0 -5.0625,2.21875 -5.0625,5.5 0,3.296875 2.03125,5.5 5.078125,5.5 1.28125,0 2.40625,-0.390625 3.25,-1.109375 1.140625,-0.96875 1.8125,-2.59375 1.8125,-4.296875 0,-3.390625 -2,-5.59375 -5.078125,-5.59375 z m 0,1.171875 c 2.265625,0 3.734375,1.71875 3.734375,4.390625 0,2.53125 -1.5,4.265625 -3.71875,4.265625 -2.25,0 -3.734375,-1.734375 -3.734375,-4.328125 C 1.890625,-7.765625 3.375,-9.5 5.609375,-9.5 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-59"
overflow="visible"
style="overflow:visible">
<path
id="path13140"
d="m 8.59375,-7.421875 c 0,-0.71875 -0.046875,-0.921875 -0.28125,-1.40625 -0.578125,-1.21875 -1.796875,-1.84375 -3.578125,-1.84375 -2.296875,0 -3.71875,1.171875 -3.71875,3.078125 0,1.28125 0.671875,2.09375 2.046875,2.453125 l 2.609375,0.6875 c 1.34375,0.34375 1.9375,0.875 1.9375,1.703125 0,0.5625 -0.3125,1.140625 -0.75,1.453125 C 6.4375,-1 5.78125,-0.84375 4.921875,-0.84375 3.78125,-0.84375 3.015625,-1.125 2.5,-1.734375 2.125,-2.1875 1.9375,-2.6875 1.953125,-3.34375 H 0.6875 c 0.015625,0.96875 0.203125,1.59375 0.625,2.171875 0.71875,1 1.921875,1.5 3.53125,1.5 1.25,0 2.265625,-0.28125 2.953125,-0.796875 0.703125,-0.5625 1.15625,-1.5 1.15625,-2.40625 0,-1.296875 -0.8125,-2.25 -2.234375,-2.640625 L 4.078125,-6.21875 C 2.8125,-6.5625 2.34375,-6.96875 2.34375,-7.78125 c 0,-1.0625 0.9375,-1.765625 2.359375,-1.765625 1.671875,0 2.59375,0.75 2.609375,2.125 z m 0,0"
style="stroke:none" />
</symbol>
</g>
</defs>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0,-254.66665)"
id="layer1">
<rect
y="254.66664"
x="0"
height="42.333332"
width="171.97917"
id="rect29"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.20445883;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g>
<g
transform="translate(0,-89.958333)"
id="layer2">
<flowRoot
transform="translate(160.2619,-225.08482)"
xml:space="preserve"
id="flowRoot1183"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.33333302px;line-height:1;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"><flowRegion
id="flowRegion1185"><rect
id="rect1187"
width="1.2069778"
height="15.690712"
x="75.436111"
y="556.19049" /></flowRegion><flowPara
id="flowPara1189" /></flowRoot> <text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="182.5074"
y="-33.97517"
id="text329"><tspan
id="tspan327"
x="182.5074"
y="-33.97517"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332">Unadjusted</tspan><tspan
x="182.5074"
y="-30.094614"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332"
id="tspan331">RNA data</tspan></text>
<text
id="text252"
y="-33.97517"
x="226.26772"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332"
y="-33.97517"
x="226.26772"
id="tspan248">Adjusted</tspan><tspan
id="tspan250"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332"
y="-30.094614"
x="226.26772">RNA data</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.23333311px;line-height:1.25;font-family:'Nimbus Sans';-inkscape-font-specification:'Nimbus Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="218.26079"
y="-31.358486"
id="text3351"><tspan
id="tspan3349"
x="218.26079"
y="-27.743219"
style="stroke-width:0.26458332" /></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.23333311px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="311.44803"
y="-128.11108"
id="text178"><tspan
id="tspan176"
x="311.44803"
y="-124.36558"
style="stroke-width:0.26458332" /></text>
<flowRoot
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.33333302px;line-height:1;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
id="flowRoot1183-1"
xml:space="preserve"
transform="translate(382.39372,-235.50136)"><flowRegion
id="flowRegion1185-9"><rect
y="556.19049"
x="75.436111"
height="15.690712"
width="1.2069778"
id="rect1187-4" /></flowRegion><flowPara
id="flowPara1189-7" /></flowRoot> <text
id="text329-8"
y="-44.39172"
x="404.63922"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332"
y="-44.39172"
x="404.63922"
id="tspan327-4">Unadjusted</tspan><tspan
id="tspan331-5"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332"
y="-40.511166"
x="404.63922">RNA data</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="448.39954"
y="-44.39172"
id="text252-0"><tspan
id="tspan248-3"
x="448.39954"
y="-44.39172"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332">Adjusted</tspan><tspan
x="448.39954"
y="-40.511166"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332"
id="tspan250-6">RNA data</tspan></text>
<text
id="text3351-6"
y="-41.775036"
x="440.39261"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.23333311px;line-height:1.25;font-family:'Nimbus Sans';-inkscape-font-specification:'Nimbus Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
xml:space="preserve"><tspan
style="stroke-width:0.26458332"
y="-38.159771"
x="440.39261"
id="tspan3349-3" /></text>
<text
id="text2854"
y="-128.22043"
x="339.50894"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.23333311px;line-height:1.25;font-family:'Nimbus Sans';-inkscape-font-specification:'Nimbus Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
xml:space="preserve"><tspan
style="stroke-width:0.26458332"
y="-124.60516"
x="339.50894"
id="tspan2852" /></text>
<g
transform="matrix(0.3159036,0,0,0.3159036,-64.910107,90.359885)"
id="g887">
<path
id="path94"
d="m 524.84054,71.575175 c -0.43311,-5.932451 -21.36876,-14.585386 -47.22528,-2.851408 -2.68203,1.217136 -5.76235,1.39478 -8.66362,2.533866 1.41618,0.912559 -0.76378,3.052972 -0.23751,2.551564 1.37653,-1.311515 6.56248,-2.884787 8.58222,-1.51651 28.71353,19.452075 47.97032,5.348276 47.54419,-0.717512 z"
style="fill:#e7cbca;fill-opacity:1;stroke:none;stroke-width:0.15337786px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
style="fill:#6c5d53;fill-opacity:0.78431373;stroke:none;stroke-width:1.19728899;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 430.93491,1.3528154 c 4.25013,-1.55399239 32.6067,11.5076446 30.56357,53.2798726 -0.3079,6.295094 9.36194,15.938708 10.42081,17.726999 0.40027,0.676074 -2.45951,0.425612 -2.72391,1.173304 -2.6782,-1.640157 -9.00632,-14.911175 -11.4828,-16.181673 C 423.3284,39.71135 426.9999,2.7630497 430.93492,1.3528088 Z"
id="path92" />
<path
id="path80"
style="fill:#918ebe;fill-opacity:1;stroke:#ffffff;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 485.10948,106.28175 c 0,0 -14.15967,-33.306723 -12.68766,-35.945381 1.472,-2.638657 19.45308,-16.752464 19.45308,-16.752464 l -7.64163,-6.960826 c 0,0 -12.46658,19.099595 -15.57167,21.947594 -3.1051,2.847999 -46.35299,10.415468 -46.35299,10.415468 l 9.7669,21.095389 c 0,0 34.39874,-27.143412 35.62666,-24.971947 1.22792,2.171464 5.28298,33.304807 5.28298,33.304807 z" />
<path
style="fill:#ebadff;fill-opacity:1;stroke:#ffffff;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 493.9447,126.81357 c -7.11424,4.6343 -11.88321,4.84438 -20.95137,2.13822 -19.81116,-9.80533 -13.61314,-35.495623 -0.21756,-39.72234 13.39558,-4.226719 24.398,1.620676 28.35893,10.93884 3.96094,9.31817 -0.0757,22.01099 -7.19,26.64528 z"
id="path36" />
<path
style="fill:#890a71;fill-opacity:0.57843137;stroke:none;stroke-width:0.28116623;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="m 490.09784,124.99658 c -2.85624,3.24207 -15.3735,1.35186 -15.87461,-1.14947 -1.68935,-3.00507 1.10023,-12.84586 4.8268,-14.07055 2.7585,-2.89052 15.76963,-0.27577 16.55867,2.14723 1.64668,2.4778 -1.95933,12.1023 -5.51086,13.07279 z m -0.32253,-0.42959 c -3.26552,-3.17095 -1.04847,-5.8045 4.66899,-11.70335 -5.64544,2.79196 -10.83529,4.81336 -14.80116,-1.13556 2.62991,4.00551 0.44741,7.29883 -3.94777,11.41338 -0.2359,0.0907 -0.47619,0.18705 -0.72124,0.28997 0.24842,-0.0961 0.48818,-0.1928 0.72124,-0.28997 6.94744,-1.11856 10.13746,-0.046 14.07994,1.42553 z"
id="rect51" />
<path
style="fill:#ee93fd;fill-opacity:1;stroke:#ffffff;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 450.9714,108.56581 c 7.59705,-11.772433 11.26758,-24.959531 0.32371,-39.344596 -10.94388,-14.385065 -38.36337,-13.104521 -48.1698,2.153156 -9.80644,15.257677 -8.27748,29.48217 3.16122,39.71368 11.43869,10.23154 34.46073,9.48175 44.68487,-2.52224 z"
id="path40" />
<path
id="path58"
d="m 432.39443,101.72157 c -3.05438,2.34677 -6.07482,5.82708 -8.05618,4.87554 -4.90768,1.34839 -15.46644,-9.647281 -14.57389,-13.130879 -4.15475,-0.564182 9.61676,-19.5093 13.69916,-16.143113 3.54749,-2.772271 15.48998,8.333232 14.12088,12.927908 1.24075,2.843906 -0.54283,7.900009 -5.18997,11.470544 z m -8.01481,4.41387 c -1.22417,-11.148949 5.05714,-13.119033 12.94075,-15.820888 -6.54471,-4.697394 -12.62594,-2.251853 -13.97512,-12.532558 -1.11025,6.932898 -3.52276,13.206181 -12.01549,15.865475 -0.29971,-0.02135 -0.41202,-0.07439 -0.72949,-0.08233 0.31603,0.02152 0.42805,0.07361 0.72949,0.08233 7.97564,0.552802 9.32048,7.152671 13.04986,12.487971 z"
style="fill:#803766;fill-opacity:1;stroke:none;stroke-width:0.27449244;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<path
style="fill:#ebadff;fill-opacity:1;stroke:#ffffff;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 474.7348,64.48489 c 12.71219,9.742455 26.39644,1.6764 29.00579,-8.547708 1.87847,-7.584606 -4.31727,-16.491395 -11.65721,-18.770246 -19.25351,-5.293294 -27.07011,16.275467 -17.34858,27.317954 z"
id="path38" />
<path
id="path60"
d="m 499.25123,41.685619 c -0.73638,-4.358676 -9.1967,-4.673336 -11.31061,-2.308633 -1.80286,1.559231 -1.9883,8.554986 0.36615,10.133184 1.09045,2.509312 9.55485,3.835772 11.78258,1.732368 1.815,-1.565124 0.75966,-10.142418 -0.83816,-9.556917 z m -0.69171,0.462434 c -2.93996,1.328676 -1.62541,3.687184 1.15655,8.676899 -2.88315,-5.666542 -6.3088,-6.909296 -10.59109,-2.434989 3.33926,-3.16174 3.37898,-7.268591 -0.40447,-8.13514 -0.14636,-0.108317 -0.29457,-0.221188 -0.44478,-0.33926 0.15401,0.114452 0.30175,0.227417 0.44478,0.33926 4.96484,1.993106 6.08623,1.136265 9.83901,1.89323 z"
style="fill:#b048b2;fill-opacity:1;stroke:none;stroke-width:0.2811662;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<g
aria-label="Allspice"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;line-height:1.25;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:0.26458332"
id="text825">
<path
d="m 468.643,4.5745775 h 1.10795 l 5.03535,12.1212235 h -1.24024 l -1.52135,-3.671094 h -5.45703 l -1.43867,3.671094 h -1.21543 z m 0.57051,1.6784504 q -0.55397,1.4304036 -1.10794,2.8277342 -0.5457,1.3890629 -1.09141,2.8029299 h 4.53099 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path852" />
<path
d="M 477.48174,4.5828457 V 16.695801 h -1.14102 V 4.5828457 Z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path854" />
<path
d="M 481.343,4.5828457 V 16.695801 h -1.14101 V 4.5828457 Z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path856" />
<path
d="m 489.05726,10.188705 q -0.008,-0.570508 -0.63665,-0.9260418 -0.62839,-0.3555339 -1.55443,-0.3555339 -0.92604,0 -1.42214,0.2480469 -0.48782,0.2480468 -0.69453,0.4878255 -0.2067,0.2397786 -0.2067,0.6614583 0,0.42168 0.80201,0.785482 0.47129,0.214974 1.4056,0.429948 2.79466,0.644921 3.3569,1.554427 0.28939,0.46302 0.22325,1.058333 0.16536,1.182357 -1.26504,2.091862 -1.08314,0.677994 -2.33164,0.677994 -1.24024,0.0083 -2.38125,-0.851627 -1.14929,-0.859896 -1.14929,-1.976107 h 1.14102 q 0,0.661459 0.79375,1.174089 0.80202,0.51263 1.67018,0.51263 0.86817,0 1.62884,-0.396875 0.24805,-0.14056 0.53744,-0.479557 0.28939,-0.347266 0.21497,-0.752409 0.14056,-0.578776 -0.63665,-0.917774 -0.48783,-0.223242 -1.43867,-0.438216 -0.94258,-0.23151 -1.55443,-0.396875 -0.61185,-0.165364 -1.09141,-0.429948 -1.0666,-0.595312 -1.0666,-1.728059 0,-1.1327477 1.05833,-1.794206 1.05834,-0.6614582 2.43086,-0.6614582 1.37253,0 2.33991,0.6697265 0.96738,0.6697265 0.96738,1.7528647 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path858" />
<path
d="m 492.48031,7.9232101 h 1.14101 v 1.0583333 q 1.05007,-0.8516276 1.5875,-1.0335286 0.53744,-0.181901 0.93431,-0.1901693 1.68672,0.00827 2.69544,1.4138671 1.00873,1.4055994 1.00873,3.1998044 0,1.794206 -0.83509,3.050977 -0.96739,1.471744 -2.7864,1.471744 -1.81901,0 -2.60449,-0.868164 v 4.043164 h -1.14101 z m 5.53971,2.0505207 q -0.68626,-1.0748697 -1.90996,-1.0748697 -1.2237,0 -2.48874,1.7197919 v 3.464388 q 0.57051,1.058333 1.7446,1.504817 0.42994,0.165365 0.8847,0.165365 0.46302,0 0.80202,-0.14056 0.34726,-0.14056 0.73587,-0.487826 0.39687,-0.347265 0.66146,-1.099674 0.25631,-0.760677 0.25631,-1.86862 0,-1.107942 -0.68626,-2.1828122 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path860" />
<path
d="m 503.08844,7.9149419 v 8.7891271 h -1.14101 V 7.9149419 Z M 501.94743,6.2612961 V 4.5828457 h 1.14101 v 1.6784504 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path862" />
<path
d="m 511.39802,10.577312 q 0.008,-0.7937504 -0.66973,-1.2319666 -0.678,-0.4382161 -1.63711,-0.4382161 -1.00872,0 -1.90169,0.9095052 -0.89297,0.9095055 -0.89297,2.5548825 0,1.645378 0.74414,2.52181 0.74414,0.876432 1.98437,0.876432 1.24024,0 1.81075,-0.537435 0.5705,-0.537435 0.56224,-1.107942 h 1.14101 q -0.008,0.942578 -0.76894,1.769401 -0.93431,1.008723 -2.67891,1.008723 -2.80293,0 -3.64629,-2.554882 -0.28939,-0.876432 -0.28939,-2.033984 0,-1.157552 0.38034,-1.992644 0.38034,-0.8433589 0.95912,-1.4055985 0.58704,-0.5705077 1.2733,-0.8598957 0.69453,-0.289388 1.71979,-0.289388 1.03353,0 2.04226,0.7276041 1.00872,0.7276041 1.00872,2.0835941 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path864" />
<path
d="m 514.79625,12.627832 q 0.11576,1.35599 0.89297,2.248958 0.77722,0.892969 2.02572,0.884701 1.14928,-0.0083 1.90996,-0.669727 0.31419,-0.264583 0.45475,-0.537434 0.14883,-0.28112 0.14883,-0.438217 h 1.14102 q 0.008,0.719336 -0.86817,1.653646 -1.0666,1.132747 -2.42259,1.132747 -1.34772,0 -2.1084,-0.37207 -0.75241,-0.380338 -1.2733,-1.02526 -1.05834,-1.30638 -1.05834,-3.224609 0,-1.918229 1.0418,-3.2163413 1.0418,-1.2981119 2.96003,-1.2981119 1.91822,0 2.96002,1.2485025 1.0418,1.2402347 1.0418,3.6132157 z m 5.67201,-1.141015 q -0.28939,-2.5796877 -2.93522,-2.5796877 -1.10794,0 -1.81901,0.7441406 -0.71107,0.7441401 -0.8847,1.8355471 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path866" />
</g>
</g>
<text
id="text2069"
y="129.65414"
x="12.249987"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.14235115px;line-height:1.25;font-family:'Nimbus Sans';-inkscape-font-specification:'Nimbus Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:0.08629897"
xml:space="preserve"><tspan
style="font-size:4.14235115px;fill:#4d4d4d;stroke-width:0.08629897"
y="129.65414"
x="12.249987"
id="tspan2067">mRNA-seq</tspan></text>
<g
style="fill:#ce6a2a;fill-opacity:1"
transform="matrix(0.28148654,0,0,0.38790612,-1.4186311,89.236646)"
id="g5513">
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5397"
width="54.545269"
height="4.0908952"
x="13.825336"
y="46.84251" />
<rect
y="40.09288"
x="20.574968"
height="4.0908952"
width="54.545269"
id="rect5399"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5401"
width="54.545269"
height="4.0908952"
x="34.074234"
y="73.841057" />
<rect
y="67.091415"
x="40.823864"
height="4.0908952"
width="54.545269"
id="rect5403"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5405"
width="54.545269"
height="4.0908952"
x="47.573498"
y="53.592136" />
<rect
y="60.34177"
x="67.822403"
height="4.0908952"
width="54.545269"
id="rect5407"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5409"
width="54.545269"
height="4.0908952"
x="7.0757051"
y="80.590675" />
<rect
y="67.0914"
x="101.57056"
height="4.0908952"
width="54.545269"
id="rect5411"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5413"
width="54.545269"
height="4.0908952"
x="94.820923"
y="73.841042" />
<rect
y="80.590668"
x="67.822395"
height="4.0908952"
width="54.545269"
id="rect5415"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5417"
width="54.545269"
height="4.0908952"
x="34.07423"
y="87.340294" />
<rect
y="33.343246"
x="-149.3662"
height="4.0908952"
width="54.545269"
id="rect5419"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
transform="scale(-1,1)" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5421"
width="54.545269"
height="4.0908952"
x="-142.61655"
y="87.340363"
transform="scale(-1,1)" />
<rect
y="26.593597"
x="-129.11729"
height="4.0908952"
width="54.545269"
id="rect5423"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
transform="scale(-1,1)" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5425"
width="54.545269"
height="4.0908952"
x="-122.36766"
y="5.6697354"
transform="scale(-1,1)" />
<rect
y="13.094329"
x="-115.61803"
height="4.0908952"
width="54.545269"
id="rect5427"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
transform="scale(-1,1)" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5429"
width="54.545269"
height="4.0908952"
x="-95.369125"
y="19.843964"
transform="scale(-1,1)" />
<rect
y="40.09288"
x="-156.11583"
height="4.0908952"
width="54.545269"
id="rect5431"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
transform="scale(-1,1)" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5433"
width="54.545269"
height="4.0908952"
x="-61.620968"
y="26.593603"
transform="scale(-1,1)" />
<rect
y="60.341797"
x="-68.370598"
height="4.0908952"
width="54.545269"
id="rect5435"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
transform="scale(-1,1)" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5437"
width="54.545269"
height="4.0908952"
x="-95.369125"
y="33.343246"
transform="scale(-1,1)" />
<rect
y="46.842522"
x="-129.11729"
height="4.0908952"
width="54.545269"
id="rect5439"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
transform="scale(-1,1)" />
</g>
<g
transform="matrix(0.35710458,0,0,0.35710458,-16.552211,86.299641)"
id="g5561">
<g
id="g5395"
transform="matrix(1.2231511,0,0,1.0342076,53.092274,-3.221107)">
<path
style="fill:#ff45bd;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,37.902172 h 3.41634 v -9.115606 h -3.41634 z m 0,0"
id="path13543" />
<path
style="fill:#ff3f54;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,48.786372 h 3.41634 v -9.115617 h -3.41634 z m 0,0"
id="path13547" />
<path
style="fill:#ff5e23;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,59.670563 h 3.41634 v -9.115582 h -3.41634 z m 0,0"
id="path13551" />
<path
style="fill:#f59411;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,70.554798 h 6.06217 v -9.115625 h -6.06217 z"
id="path13555" />
<path
style="fill:#dcd400;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,81.438998 h 3.41634 v -9.115589 h -3.41634 z m 0,0"
id="path13559" />
<path
style="fill:#6eeb23;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,92.323231 h 3.41634 v -9.115619 h -3.41634 z m 0,0"
id="path13563" />
<path
style="fill:#28d982;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,103.20743 h 3.41634 v -9.115623 h -3.41634 z m 0,0"
id="path13567" />
<path
style="fill:#0faede;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.45891759"
d="m 276.99832,114.0916 h 36.40689 v -9.11559 h -36.40689 z m 0,0"
id="path13571" />
<path
style="fill:#217fff;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,124.97579 h 3.41634 v -9.11558 h -3.41634 z m 0,0"
id="path13575" />
<path
id="path5312"
d="m 319.33168,37.902172 h 3.41634 v -9.115606 h -3.41634 z m 0,0"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
id="path5314"
d="m 319.33168,48.786372 h 3.41634 v -9.115617 h -3.41634 z m 0,0"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
id="path5316"
d="m 319.33168,59.670563 h 3.41634 v -9.115582 h -3.41634 z m 0,0"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
id="path5318"
d="m 319.33168,70.554798 h 35.16634 v -9.115625 h -35.16634 z"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
id="path5320"
d="m 319.33168,81.438998 h 3.41634 v -9.115589 h -3.41634 z m 0,0"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
id="path5322"
d="m 319.33168,92.323231 h 9.23717 v -9.115619 h -9.23717 z"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
id="path5324"
d="m 319.33168,103.20743 h 3.41634 v -9.115623 h -3.41634 z m 0,0"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
id="path5326"
d="m 319.33168,114.0916 h 3.41503 v -9.11559 h -3.41503 z"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.45891759" />
<path
id="path5328"
d="m 319.33168,124.97579 h 3.41634 v -9.11558 h -3.41634 z m 0,0"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,115.86019 h 3.41634 v 9.1156 h -3.41634 z m 0,0"
id="path5330" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,104.97599 h 4.24237 v 9.11562 h -4.24237 z"
id="path5332" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,94.091797 h 3.41634 v 9.115583 h -3.41634 z m 0,0"
id="path5334" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,83.207562 h 24.2433 v 9.115625 h -24.2433 z"
id="path5336" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,72.323362 h 3.41634 v 9.115589 h -3.41634 z m 0,0"
id="path5338" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,61.439129 h 3.41634 v 9.115619 h -3.41634 z m 0,0"
id="path5340" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,50.55493 h 3.41634 v 9.115623 h -3.41634 z m 0,0"
id="path5342" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.45891759"
d="m 361.66504,39.67076 h 4.13495 v 9.11559 h -4.13495 z"
id="path5344" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,28.78657 h 3.41634 v 9.11558 h -3.41634 z m 0,0"
id="path5346" />
</g>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:9.87777805px;line-height:1.25;font-family:'Nimbus Sans';-inkscape-font-specification:'Nimbus Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#666666;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="393.85269"
y="21.642082"
id="text5517"><tspan
id="tspan5515"
x="393.85269"
y="21.642082"
style="font-size:9.87777805px;text-align:center;text-anchor:middle;fill:#666666;stroke-width:0.26458332">Subtypes</tspan></text>
<text
id="text5521"
y="21.642082"
x="445.52206"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:9.87777805px;line-height:1.25;font-family:'Nimbus Sans';-inkscape-font-specification:'Nimbus Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#666666;fill-opacity:1;stroke:none;stroke-width:0.26458332"
xml:space="preserve"><tspan
style="font-size:9.87777805px;text-align:center;text-anchor:middle;fill:#666666;stroke-width:0.26458332"
y="21.642082"
x="445.52206"
id="tspan5519">Drivers</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:9.87777805px;line-height:1.25;font-family:'Nimbus Sans';-inkscape-font-specification:'Nimbus Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#666666;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="497.38028"
y="21.642082"
id="text5525"><tspan
id="tspan5523"
x="497.38028"
y="21.642082"
style="font-size:9.87777805px;text-align:center;text-anchor:middle;fill:#666666;stroke-width:0.26458332">Tissues</tspan></text>
</g>
<path
id="path5563"
d="m 47.093837,108.94591 h 4.736834 v -1.75769 l 5.236444,3.12196 -5.240514,2.97101 v -1.61947 h -4.732764 z"
style="fill:none;stroke:#666666;stroke-width:0.34519589;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:none;stroke:#666666;stroke-width:0.34519589;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 106.09962,108.94591 h 4.73683 v -1.75769 l 5.23645,3.12196 -5.24052,2.97101 v -1.61947 h -4.73276 z"
id="path5567" />
</g>
</svg>
``` {r echo=FALSE, results="hide"}
opt <- options(digits=3)
set.seed(1)
```
# Getting started
You can install Allspice using the standard procedure:
``` {r eval=FALSE}
# Install the package from a remote repository.
install.packages("Allspice")
```
To activate and list the library functions, type
``` {r}
# Activate the library.
library("Allspice")
packageVersion("Allspice")
ls("package:Allspice")
```
Each Allspice function comes with a help page that contains a code example,
such as
``` {r eval=FALSE}
# Access function documentation (not shown in vignette).
? Allspice::classifier
```
You can run all the code examples in one go by typing
``` {r eval=FALSE}
# Run all code examples (not shown in vignette).
fn <- system.file("examples.R", package = "Allspice")
source(fn)
```
# Dataset
To run this tutorial, we will use simulated data that mimics B-cell
acute lymphoblast leukemia samples:
``` {r}
# Generate gene RNA read counts.
simu <- bcellALL(300)
print(simu$counts[1:5,1:6])
print(simu$metadata[1:6,])
```
The output contains the unadjusted read counts as would be produced by
a standard RNA-seq pipeline and patients' sex and age are also simulated.
Please note that these data are artificial and meant only for demonstration
purposes; they do not reflect the complex biology of ALL accurately.
The read counts must be stored in a matrix that has the samples organized
into columns and the genes are listed as rows. For the meta-data, patients
can be listed in rows as that is more convenient in most situations.
# Classify samples {.tabset}
## Predict labels
The first step is to create a new classifier:
``` {r}
# Set up a classifier for genetic B-cell ALL subtypes.
cls <- classifier()
```
By default, the command creates an object that contains three models:
i) ALL subtype prediction, ii) driver gene prediction and iii) tissue
profiling to make sure the RNA data are suitable for analyses.
The next step is to import the covariates (e.g. sex and age) into the
classifier. If there are no covariate data available, this step can be
skipped. The default classifier uses MALE and AGE as column headings,
see the format of the metadata in the first section of the vignette. The
names of covariates are also available as
``` {r}
# List covariates.
info <- information(cls)
print(info$covariates[,c("ASSET","TITLE","COVAR")])
```
To set the covariates, use the command
``` {r}
# Set covariates.
covariates(cls) <- simu$metadata
```
Missing values or incomplete data are allowed, however, a warning will be
produced when the subtypes are predicted. Also, it is important to set the
covariates **before** loading the RNA read counts.
Once the covariates have been set, the RNA-seq read counts are next:
``` {r}
# Load RNA-seq profiles.
profiles(cls) <- simu$counts
```
The above command pre-processes the data and predicts the subtypes based on
the combined information from covariates and read counts. To get the results,
use the command
``` {r}
# Prediction results.
pred <- predictions(cls)
primary <- pred[[1]]
print(primary[1:6,c("LABEL","FREQ","PROX","EXCL")])
```
The output is a list of data frames, where each element contains the results
generated by a classification asset (see the section on how to create your own
classifier for more information on assets). Here, we are interested in the ALL
subtype which is the primary asset in the classifier.
Please use the tabs at the top to navigate to the next page.
## Metrics
Here are selected results from the previous page again:
``` {r}
# Prediction results.
ambig <- which(primary$CATEG == "Ambiguous")
uncla <- which(primary$CATEG == "Unclassified")
rows <- unique(c(1:5, ambig[1], uncla[1]))
print(primary[rows,c("LABEL","MATCH","FREQ","PROX","EXCL")])
```
The data frame includes additional information besides the most plausible
ALL subtype **LABEL**. The ALL subtype that most resembles the patient's
profile is defined as the best-matching subtype **MATCH**. For most cases,
LABEL will refer to the same subtype as MATCH, but failure to pass quality
checks and the rarity of a subtype may sometimes lead to conflicting
results.
The next column named **FREQ** tells the frequency of the predicted subtype
given the observed RNA profile and covariates. For example, if FREQ is 0.9,
then you would expect to see 9 out of 10 patients that share this data profile
to have that predicted ALL subtype. This metric depends on the training set
that was used when the classification asset was created. Thus rare subtypes
are likely to get lower frequency estimates even if the RNA profile would be
a close match.
The frequency metric does not capture mutual exclusivity because it is
evaluated independently for each subtype. For example, Allspice allows
patients to have more than one subtype in parallel when the statistical model
is trained. In this scenario, parallel subtypes may all get high frequencies,
of which the highest would be chosen as the predicted subtype. To identify
samples with mixed transcriptional characteristics, the results also includes
a probabilistic estimate for exclusivity in the column **EXCL** that tells
how likely it is that a sample comes from a single ALL subtype.
**PROX** (proximity) and **EXCL** (exclusivity) are used as quality metrics.
By default, Allspice labels any samples with <50% proximity as
'Unclassified'. Of those that pass the probability threshold, samples
with <50% exclusivity are labelled as 'Ambiguous'. The proximity measure
is conceptually the same as subtype frequency, however, any differences
in subtype prevalence are adjusted away.
You may have noticed that the subtype labels and the matched subtype
names are slightly different. This is because text labels with
non-alphanumeric characters may be automatically changed by R when used as
row or column names in data structures, thus the subtype identities are
made safe compared to the human readable labels. You can access
subtype labels by typing:
``` {r}
# Access subtype labelling information.
info <- information(cls)
print(info$categories[1:5,c("ASSET","TITLE","CATEG","LABEL")])
```
See also the Iris data example in the section on creating new classifiers.
It contains instructions on how to set the labels for a classification asset.
Please use the tabs at the top to navigate to the next page.
## Visual report
Detailed classification results can be visualised on a case-by-case basis.
In the first example, we first identify a patient sample that passed quality
control and did not show mixed characteristics:
``` {r}
# Select successful classification.
rows <- which((primary$CATEG != "Ambiguous") & (primary$FREQ > 0.9))
print(primary[rows[1],c("LABEL","MATCH","FREQ","PROX","EXCL")])
```
``` {r results="hide", fig.width=8, fig.height=6, fig.align="center", fig.cap="Figure: Classification results. The predicted subtype label is written on the top left corner. The expected frequency of the subtype given the data profile is written as a percentage after the predicted label. RNA biomarker scores were also calculated for the presence of alterations in specific genes (center bar chart), note that a patient may have multiple driver genes in parallel. The right-most chart shows RNA biomarker scores for the predicted source tissue of the sample (in this simulated dataset, all samples were generated from B-cell ALL profiles). "}
# Show patient report.
report(cls, name = rows[1], file = NULL)
```
The second example shows a case where the subtype is less obvious due to mixed
transcriptional characteristics. Sometimes this can be caused by random
incidental fluctuations that are always present in biological data, but some
of these cases will be "real" in the sense that the same individual can
harbour multiple cancer driving mutations or some alterations affect wide
regions of the genome (e.g. deletions or duplications of chromosomal
segments) and thus multiple genes would be involved.
``` {r}
# Select ambiguous classification.
rows <- which((primary$CATEG == "Ambiguous") & (primary$PROX > 0.9))
print(primary[rows[1],c("LABEL","MATCH","FREQ","PROX","EXCL")])
```
Mixed profiles typically manifest multiple indicators for driver genes while
still being identified as a B-cell ALL tissue type:
``` {r results="hide", fig.width=8, fig.height=6, fig.align="center", fig.cap="Figure: Classification results for a case with mixed transcriptional characteristics."}
# Show patient report.
report(cls, name = rows[1], file = NULL)
```
Lastly, the simulated dataset includes samples with randomized data:
``` {r}
# Select poor quality samples.
rows <- which(primary$CATEG == "Unclassified")
print(primary[rows[1],c("LABEL","MATCH","FREQ","PROX","EXCL")])
```
``` {r results="hide", fig.width=8, fig.height=6, fig.align="center", fig.cap="Figure: Classification results for a case with atypical data."}
# Show patient report.
report(cls, name = rows[1], file = NULL)
```
# Train new classifier {.tabset}
## Configuration
In Allspice, a classifier is actually a collection of classification models.
These models are enclosed in classification *assets* (objects of the Asset
class). As was observed in the previous sections, the default Allspice
classifier contains three assets (ALL subtypes, driver genes and tissues).
This section describes how to create a new RNA-seq classification asset from
the simulated B-cell ALL dataset. Another example that uses the classisal
Iris flower dataset is also presented as a demonstration on how to use
Allspice for any type of dataset with category labels.
Before creating the assets, it is important to configure the models for
different types of datasets. The default configuration is shown below:
``` {r}
# Create a new empty asset.
bALL <- asset()
print(configuration(bALL))
```
RNA-seq normalization parameters include **norm** (if set to 0,
normalization is not performed), **nonzero.min** (the minimum read
count considered non-neglible expression) and **nonzero.ratio**
(minimum ratio of non-neglible values for a transcript to be included
in the output). Allspice uses the DESeq2 method for the normalization
of read counts (Genome Biol 15, 550, 2014).
Standardization parameters include **standard** (if set to 0,
standardization is not performed) and **logarithm** (if set to 0,
data values are used without taking the logarithm). The exact
logarithmic transformation is log2(x + 1).
Feature selection parameters include **ninput.max** (the maximum
number of features to be used for classification) and
**rrinput.max** (the maximum correlation r-squared to be allowed
between features).
Classification parameters include **proximity.min** (minimum
similarity rating considered for reliable classification) and
**exclusivity.min** (minimum exclusivity for non-ambiguous
classification).
Only empty assets can be re-configured. To change the parameters,
use a numeric vector with appropriately named elements:
``` {r}
# Re-configure asset.
configuration(bALL) <- c(ninput.max=30, nonzero.min=90)
print(configuration(bALL)[c("ninput.max","nonzero.min")])
```
Please use the tabs at the top to navigate to the next page.
## RNA-seq
To populate an empty asset, some data organization is required. The first
thing to decide is the title of the asset, which will be displayed in
the visual report (see figures in the previous section). The process begins
with a list:
``` {r}
# Prepare asset title.
materials <- list(title="Simutypes")
```
Next, non-normalized RNA data are included. The dataset needs to be a
numerical matrix with samples in columns:
``` {r}
# Prepare RNA-seq read counts.
materials$dat <- simu$counts
```
Covariates can be in a data frame or a matrix with samples on rows, just
make sure all the columns are numeric:
``` {r}
# Prepare covariate data.
materials$covariates <- simu$metadata[,c("MALE","AGE")]
```
It is very important that all the rows and columns are named in each
data structure since they will be used later to link the inputs together.
It is good practice to always ensure that the row and column names
are written with alphanumeric characters without white spaces, otherwise
the automatic R filters may change some of the characters and cause
unexpected errors.
The last remaining source of information are the pre-defined subtypes
themselves that will be used to train the classification model. In this
example, the subtypes are mutually exclusive (a patient can only exhibit a
single subtype), therefore the subtypes can be obtained from the single
column in the metadata:
``` {r}
# Prepare subtype information.
categ <- simu$metadata[,"SUBTYPE",drop=FALSE]
rows <- which(categ != "Contaminated")
materials$bits <- categ[rows,,drop=FALSE]
```
Note the drop flag in the code above; this ensures that the row names are
carried forward to the bits element and can therefore be used to link the
subtype information with the rest of the patient data. The dataset contains
simulated cases where the category is undefined or the data are contaminated.
These are excluded from training.
If necessary, Allspice also allows overlapping categories, but then the
bits need to be supplied in a binary matrix where 1s indicate category
membership (the name of a column is the name of the corresponding category).
Samples should be organized into rows similarly to the covariates.
In the final step, the materials are assembled into the final classification
asset:
``` {r}
# Assemble the classification asset.
bALL <- asset()
assemble(bALL) <- materials
```
Since we excluded the category labels of "bad" samples, the training set
includes a subset of all samples. Categories that are too small (too few
samples) are ignored and will produce a warning. It is good practice to
prepare your dataset in such a way that all categories have at least
five members.
``` {r}
# Save asset to disk.
tpath <- tempfile()
export(bALL, folder = tpath)
```
The asset can now be loaded into a classifier:
``` {r}
# Create a classifier.
clstest <- classifier(tpath)
```
``` {r}
# Classify samples.
simutest <- bcellALL(5)
covariates(clstest) <- simutest$metadata
profiles(clstest) <- simutest$counts
primtest <- predictions(clstest)[[1]]
print(primtest[,c("LABEL","MATCH","FREQ","PROX","EXCL")])
```
``` {r}
# Show correct subtypes.
print(simutest$metadata)
```
Please use the tabs at the top to navigate to the next page.
## Iris data
Base R containts the classic Iris dataset that is attributed to Edgar
Anderson who collected it and Ronald Fisher who used it as an example of
linear discriminant analysis:
``` {r}
# Iris flower dataset.
print(head(iris))
```
To create a classification asset, it is good to make sure that the data are
properly identified:
``` {r}
# Set row names.
flowers <- iris
rownames(flowers) <- paste0("flower", 1:nrow(flowers))
print(flowers[c(1,80,150),])
```
The training dataset can now be finalized (note the format of the data
matrix):
``` {r}
# Prepare training set.
materials <- list(title="Iris species")
materials$dat <- t(flowers[,1:4]) # vars on rows, samples on columns
materials$bits <- flowers[,"Species",drop=FALSE]
```
The original species labels are short, however, it is nice to have the
full species names in the results as well. Adding labels can be accomplished
by
``` {r}
# Set human-readable category labels.
model <- asset()
labels <- c("Iris Setosa", "Iris Virginica", "Iris Versicolor")
names(labels) <- c("setosa", "virginica", "versicolor")
visuals(model) <- labels
```
Next, the RNA-seq normalization and logarithm needs to be disabled since this
is not RNA-seq data:
``` {r}
# Configure a new asset.
configuration(model) <- c(norm=FALSE, logarithm=FALSE)
configuration(model) <- c(nonzero.min=0, nonzero.ratio=0)
print(configuration(model))
```
The asset can now be finished
``` {r}
# Assemble the classification asset.
assemble(model) <- materials
tpath <- tempfile()
export(model, folder = tpath)
```
and tested:
``` {r}
# Classify samples.
clsiris <- classifier(tpath)
profiles(clsiris) <- t(flowers[,1:4])
iristest <- predictions(clsiris)[[1]]
print(iristest[c(1,80,150),c("LABEL","MATCH","PROX","EXCL")])
```
We know that the Setosa species is easiest to distinguish of the three
(see e.g. the Wikipedia page on the Iris study) and this is manifested
as an increase in ambiguous results for the two other categories:
``` {r}
# Summary of results.
print(table(iristest$LABEL, flowers$Species))
```
Please use the tabs at the top to navigate to the next page.
## Supercategories
On the previous tab, we changed the labels of the categories. It is also
possible to set duplicated labels, indeed, the default classifier contains
a tissue detection asset where the B-cell ALL covers multiple ALL
subtype centroids. Let's revisit the ALL classifier:
``` {r results="hide"}
# Default ALL classifier.
cls <- classifier()
```
``` {r}
# Predict source tissue.
simu <- bcellALL(5)
covariates(cls) <- simu$metadata
profiles(cls) <- simu$counts
tissues <- predictions(cls)[[3]]
print(tissues[,c("LABEL","CATEG","MATCH","MATCH.2nd")])
```
Notice how the predicted categories are different ALL subtypes, but the label
for every one of them is "B-cell ALL". In the visual report, only the
supercategory is displayed (see the figures in the section on sample
classification). The output also shows the second best matching category,
which in this case is the T-cell ALL RNA centroid. This is expected,
since it is another similar form of leukemia.
Why would you use labels to define these supercategories? The answer is a
technical one. You could put all the ALL samples together and calculate
a single B-cell ALL centroid, however, this model would be at risk of being
too coarse considering the great diversity of RNA profiles associated with
specific subtypes. For example, the rare but distinctive subtype driven by
the N159Y alteration in IKZF1 could be considered an outlier as it is far
from the overall ALL centroid, and thus these samples could be
incorrectly classified if the IKZF1 N159Y was not defined as
an explicit subtype.
## Asset contents
Classification assets are stored as text files on the disk and, although
not recommended, it is possible to view and edit them directly. For instance,
the files for ALL subtypes that were imported into the default classifier
can be found via system files that are part of the R library:
``` {r}
# Show asset contents.
base <- system.file(package = "Allspice")
folder <- file.path(base, "subtypes")
print(dir(folder))
```
**Categories** file contains information on the subtypes and their visual
attributes:
``` {r}
# Category information.
dat <- read.delim(file.path(folder, "categories.txt"))
print(dat)
```
**Centroids** file contains subtype profiles for pre-processed data values:
``` {r}
# Standardized subtype profiles.
dat <- read.delim(file.path(folder, "centroids.txt"))
print(dat[1:5,1:6])
cat(nrow(dat), " genes, ", ncol(dat), " subtypes\n", sep="")
```
**Coefficients** file contains the parameters for the back-end regression
analysis that combines the RNA biomarker from the centroid model with
the covariates. B0 is the intercept and B1 is the coefficient for the RNA
biomarker. Note that the coefficients depend on the scale of the inputs
(covariates are never standardized):
``` {r}
# Regression coefficients.
dat <- read.delim(file.path(folder, "coefficients.txt"))
print(dat[1:5,])
```
**Configuration** file contains the settings to determine how data
should be processed:
``` {r}
# Asset settings.
dat <- read.delim(file.path(folder, "configuration.txt"))
print(dat)
```
**Covariates** file contains the basic statistics of the covariates.
The MEAN is used as replacements for missing values:
``` {r}
# Covariate statistics.
dat <- read.delim(file.path(folder, "covariates.txt"))
print(dat)
```
**Nomenclature** file contains a dictionary for converting gene names
from one system to another. In this example, the asset uses Hugo symbols
but can translate ENSEMBL gene names as well:
``` {r}
# Gene names.
dat <- read.delim(file.path(folder, "nomenclature.txt"))
print(dat[1:5,])
```
**Reference** file contains basic statistics of the RNA-seq training data.
Only genes that are usable under the asset settings are included. The VALUE
column is the median of original values, whereas the mean and standard
deviation are calculated from the logarithms if the asset is so configured:
``` {r}
# RNA reference profile.
dat <- read.delim(file.path(folder, "reference.txt"))
print(dat[1:5,])
cat(nrow(dat), " genes\n", sep="")
```
# Build information
```{r echo=FALSE}
sessionInfo()
Sys.time()
```
``` {r echo=FALSE, results="hide"}
options(opt)
```
| /scratch/gouwar.j/cran-all/cranData/Allspice/inst/doc/intro.rmd |
if(readline("Clear workspace? [y/N] ") != "y")
stop("Examples not run.")
library("Allspice")
prevopt <- options(); options(digits=3)
set.seed(1)
cat("\nAsset.assemble.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Prepare training data.
simu <- bcellALL(200)
materials <- list(title="Simutypes")
materials$dat <- simu$counts
materials$covariates <- simu$metadata[,c("MALE","AGE")]
materials$bits <- simu$metadata[,"SUBTYPE",drop=FALSE]
# Assemble classification asset.
bALL <- asset()
assemble(bALL) <- materials
# Export asset into a new folder.
tpath <- tempfile()
export(bALL, folder = tpath)
# Create a classifier.
cls <- classifier(tpath, verbose = FALSE)
# Classify new samples.
simu <- bcellALL(5)
covariates(cls) <- simu$metadata
profiles(cls) <- simu$counts
primary <- predictions(cls)[[1]]
print(primary[,c("LABEL","PROX","EXCL")])
Sys.sleep(1)
cat("\nAsset.classify.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Import ALL subtyping asset.
base <- system.file(package = "Allspice")
folder <- file.path(base, "subtypes")
a <- asset(folder)
# Simulated data.
simu <- bcellALL(5)
# Standardize RNA read counts.
expres <- normalize(a, dat = simu$counts)
expres <- standardize(a, dat = expres)
# Predict categories.
res <- classify(a, dat = expres, covariates = simu$metadata)
print(res[,c("LABEL","PROX","EXCL")])
Sys.sleep(1)
cat("\nAsset.configuration.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Change asset configuration.
a <- asset()
print(configuration(a))
configuration(a) <- c(nonzero.min=0, nonzero.ratio=0)
print(configuration(a))
Sys.sleep(1)
cat("\nAsset.export.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Import ALL subtyping asset.
base <- system.file(package = "Allspice")
folder <- file.path(base, "subtypes")
a <- asset(folder)
# Export asset into a new folder.
tpath <- tempfile()
fnames <- export(a, folder = tpath)
print(dir(tpath))
Sys.sleep(1)
cat("\nAsset.nomenclature.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Import nomenclature from a system file.
base <- system.file(package = "Allspice")
fname <- file.path(base, "subtypes", "nomenclature.txt")
info <- read.delim(fname, stringsAsFactors = FALSE)
# Set ENSEMBLE identities as row names.
rownames(info) <- info$ENSEMBL
info$ENSEMBL <- NULL
print(head(info))
# Create a new asset and set nomenclature.
a <- asset()
nomenclature(a) <- info
# Prepare training data.
simu <- bcellALL(200)
materials <- list(title="Simutypes")
materials$dat <- simu$counts
materials$covariates <- simu$metadata[,c("MALE","AGE")]
materials$bits <- simu$metadata[,"SUBTYPE",drop=FALSE]
# Assemble classification asset.
assemble(a) <- materials
# Check that nomenclature was set.
simu <- bcellALL(5)
expres <- normalize(a, dat = simu$counts)
print(head(simu$counts))
print(head(expres))
Sys.sleep(1)
cat("\nAsset.normalize.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Import ALL subtyping asset.
base <- system.file(package = "Allspice")
folder <- file.path(base, "subtypes")
a <- asset(folder)
# Simulated data.
simu <- bcellALL(5)
# Normalize RNA read counts.
expres <- normalize(a, dat = simu$counts)
print(head(simu$counts))
print(head(expres))
Sys.sleep(1)
cat("\nAsset.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Set up an ALL subtyping asset.
folder <- system.file("subtypes", package="Allspice")
a <- asset(folder)
Sys.sleep(1)
cat("\nAsset.standardize.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Import ALL subtyping asset.
base <- system.file(package = "Allspice")
folder <- file.path(base, "subtypes")
a <- asset(folder)
# Simulated data.
simu <- bcellALL(5)
# Standardize RNA read counts.
expres <- normalize(a, dat = simu$counts)
zscores <- standardize(a, dat = expres)
print(head(simu$counts))
print(head(expres))
print(head(zscores))
Sys.sleep(1)
cat("\nAsset.visuals.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Create a new asset and set nomenclature.
a <- asset()
# Set category labels with automatic colors.
labels <- paste("Category", 1:8)
names(labels) <- paste0("cat", 1:8)
visuals(a) <- labels
print(a@categories)
# Add color information.
info <- data.frame(stringsAsFactors = FALSE,
LABEL = labels, COLOR = "red")
rownames(info) <- names(labels)
visuals(a) <- info
print(a@categories)
Sys.sleep(1)
cat("\nbcellALL.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Simulate B-cell ALL samples.
simu <- bcellALL(5)
print(head(simu$counts))
print(simu$metadata)
Sys.sleep(1)
cat("\nClassifier.covariates.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Simulated data.
simu <- bcellALL(5)
# Predict subtypes without covariates.
cls <- classifier(verbose = FALSE)
profiles(cls) <- simu$counts
primary <- predictions(cls)[[1]]
print(primary[,c("LABEL","PROX","EXCL")])
# Predict subtypes with covariates.
cls <- classifier(verbose = FALSE)
covariates(cls) <- simu$metadata
profiles(cls) <- simu$counts
primary <- predictions(cls)[[1]]
print(primary[,c("LABEL","PROX","EXCL")])
Sys.sleep(1)
cat("\nClassifier.information.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Show the contents of the b-cell ALL classifier.
cls <- classifier(verbose=FALSE)
info <- information(cls)
print(info$covariates)
print(info$configuration)
print(head(info$categories))
print(tail(info$categories))
Sys.sleep(1)
cat("\nClassifier.predictions.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Simulated data.
simu <- bcellALL(5)
# Predict subtypes.
cls <- classifier(verbose = FALSE)
covariates(cls) <- simu$metadata
profiles(cls) <- simu$counts
pred <- predictions(cls)
print(pred[[1]][,c("LABEL","PROX","EXCL")])
print(pred[[2]][,c("LABEL","PROX","EXCL")])
print(pred[[3]][,c("LABEL","PROX","EXCL")])
Sys.sleep(1)
cat("\nClassifier.profiles.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Simulated data.
simu <- bcellALL(5)
# Predict subtypes.
cls <- classifier(verbose = FALSE)
covariates(cls) <- simu$metadata
profiles(cls) <- simu$counts
primary <- predictions(cls)[[1]]
print(primary[,c("LABEL","PROX","EXCL")])
Sys.sleep(1)
cat("\nClassifier.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Set up an ALL classifier object.
cls <- classifier()
Sys.sleep(1)
cat("\nClassifier.report.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Simulated data.
simu <- bcellALL(5)
keys <- colnames(simu$counts)
# Predict subtypes.
cls <- classifier(verbose = FALSE)
covariates(cls) <- simu$metadata
profiles(cls) <- simu$counts
# Show visual report by name.
dev.new()
report(cls, name = keys[3])
# Show visual report by sample index.
dev.new()
report(cls, name = 3)
Sys.sleep(1)
cat("\nClassifier.scores.Rd\n")
rm(list=setdiff(ls(),"prevopt"))
# Simulated data.
simu <- bcellALL(5)
# Predict subtypes.
cls <- classifier(verbose = FALSE)
covariates(cls) <- simu$metadata
profiles(cls) <- simu$counts
z <- scores(cls)
print(z[[1]][,1:5])
print(z[[2]][,1:5])
print(z[[3]][,1:5])
Sys.sleep(1)
options(prevopt)
cat("\nAll examples completed.\n\n")
| /scratch/gouwar.j/cran-all/cranData/Allspice/inst/examples.R |
---
title: Introduction to Allspice
output:
html_document:
toc: true
toc_float: true
toc_depth: 2
number_sections: true
vignette: >
%\VignetteIndexEntry{intro}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
<style>
body {
text-align: justify;
}
p.caption {
display: inline-block;
padding-left: 0.5em;
padding-right: 0.5em;
border-color: #F4F4F4;
border-width: 1px;
border-style: solid;
border-radius: 4px;
background-color: #F6F6F6;
text-align: justify;
}
div.caption {
display: inline-block;
padding-left: 0.5em;
padding-right: 0.5em;
border-color: #F4F4F4;
border-width: 1px;
border-style: solid;
border-radius: 4px;
background-color: #F6F6F6;
text-align: justify;
}
h1 {
margin-top: 1em;
margin-bottom: 0.1em;
}
h2 {
margin-top: 0.2em;
margin-bottom: 0.1em;
}
</style>
**Author:** Ville-Petteri Mäkinen
**Version:** `r packageVersion("Allspice")`
**Abstract:** Allspice is a lightweight machine learning tool that was
initially developed for RNA profiling of acute lymphoplastic leukemia,
but it can be used for any problem where multiple classes need
to be identified from multi-dimensional data. The classifier contains
optimized mean profiles for the classes (centroids) as observed in the
training data, and new samples are matched to these centroids using the
shortest Euclidean distance. Allspice produces both numerical and visual
output of the classification results and flags samples with mixed features
from multiple classes or atypical values.
**Citation:** Ville-Petteri Mäkinen, Jacqueline Rehn, James Breen, David Yeung, Deborah L White (2022) Multi-cohort transcriptomic subtyping of B-cell acute lymphoblastic leukemia, Int J Mol Sci 2022, 23(9), 4574, https://doi.org/10.3390/ijms23094574
**Resources:** Additional assets were created from tissue-specific RNA-seq data from the Genotype-Tissue Expression Project v8 [Lonsdale J et al. Nat Genet 45, 580–585 (2013) https://doi.org/10.1038/ng.2653], from lymphoblastoid cell lines [Lappalainen et al. Nature 2013 September 26; 501(7468): 506–511. doi:10.1038/nature12531], from pediatric T-cell leukemia samples [Drobna-Śledzińska et al. ArrayExpress E-MTAB-11759, accessed 2022], and from 11 EPT and 134 T-cell ALL samples (South Australian Health and Medical Research Institute, 2022, unpublished).
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="svg8"
version="1.1"
viewBox="0 0 171.97917 42.333334"
height="160"
width="650">
<defs
id="defs2">
<marker
style="overflow:visible"
id="marker3621"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path3619" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker1319"
style="overflow:visible">
<path
id="path1317"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker2702"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2700" />
</marker>
<marker
style="overflow:visible"
id="marker2470"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2468" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker10633"
style="overflow:visible">
<path
id="path10631"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker8705"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path8703" />
</marker>
<marker
style="overflow:visible"
id="marker8577"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path8575" />
</marker>
<marker
style="overflow:visible"
id="marker7895"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path7893" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker7273"
style="overflow:visible">
<path
id="path7271"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker4786"
style="overflow:visible">
<path
id="path4784"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker20325"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path20323" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker19827"
style="overflow:visible">
<path
id="path19825"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker15111"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path15109" />
</marker>
<marker
style="overflow:visible"
id="marker10869"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path10867" />
</marker>
<marker
style="overflow:visible"
id="marker5520"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path5518" />
</marker>
<marker
style="overflow:visible"
id="marker3450"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path3448" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2910"
style="overflow:visible">
<path
id="path2908"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2792"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2790" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2680"
style="overflow:visible">
<path
id="path2678"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2288"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2286" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2194"
style="overflow:visible">
<path
id="path2192"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2106"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2104" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2006"
style="overflow:visible">
<path
id="path2004"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker1260"
style="overflow:visible">
<path
id="path1258"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker9062"
style="overflow:visible">
<path
id="path9060"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker6764"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path6762" />
</marker>
<marker
style="overflow:visible"
id="marker6184"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path6182" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker4074"
style="overflow:visible">
<path
id="path4072"
style="fill:#c837ab;fill-opacity:1;fill-rule:evenodd;stroke:#c837ab;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2646"
style="overflow:visible">
<path
id="path2644"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker1794"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path1792" />
</marker>
<marker
style="overflow:visible"
id="marker3621-9"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path3619-1" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker1319-2"
style="overflow:visible">
<path
id="path1317-7"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker2702-0"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2700-9" />
</marker>
<marker
style="overflow:visible"
id="marker2470-3"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2468-6" />
</marker>
<marker
style="overflow:visible"
id="marker8705-0"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path8703-6" />
</marker>
<marker
style="overflow:visible"
id="marker8577-2"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path8575-6" />
</marker>
<marker
style="overflow:visible"
id="marker7895-1"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path7893-8" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker7273-7"
style="overflow:visible">
<path
id="path7271-9"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker4786-20"
style="overflow:visible">
<path
id="path4784-2"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker15111-5"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path15109-9" />
</marker>
<marker
style="overflow:visible"
id="marker5520-9"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path5518-7" />
</marker>
<marker
style="overflow:visible"
id="marker3450-3"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path3448-6" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2910-1"
style="overflow:visible">
<path
id="path2908-29"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2792-3"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2790-1" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2680-9"
style="overflow:visible">
<path
id="path2678-4"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2288-7"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2286-8" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2194-4"
style="overflow:visible">
<path
id="path2192-5"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2106-0"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2104-3" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2006-6"
style="overflow:visible">
<path
id="path2004-1"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker15111-3"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path15109-6" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker49830"
style="overflow:visible">
<path
id="path49828"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker49422"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path49420" />
</marker>
<marker
style="overflow:visible"
id="marker10633-0"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path10631-6" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker8705-7"
style="overflow:visible">
<path
id="path8703-5"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker8577-3"
style="overflow:visible">
<path
id="path8575-5"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker7895-6"
style="overflow:visible">
<path
id="path7893-2"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker7273-9"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path7271-1" />
</marker>
<marker
style="overflow:visible"
id="marker4786-2"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path4784-7" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker20325-0"
style="overflow:visible">
<path
id="path20323-9"
style="fill:#d35fbc;fill-opacity:1;fill-rule:evenodd;stroke:#d35fbc;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
style="overflow:visible"
id="marker19827-3"
refX="0"
refY="0"
orient="auto">
<path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path19825-2" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker15633"
style="overflow:visible">
<path
id="path15631"
style="fill:#5f8dd3;fill-opacity:1;fill-rule:evenodd;stroke:#5f8dd3;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker15111-36"
style="overflow:visible">
<path
id="path15109-0"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker10869-6"
style="overflow:visible">
<path
id="path10867-2"
style="fill:#d35f5f;fill-opacity:1;fill-rule:evenodd;stroke:#d35f5f;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker5520-6"
style="overflow:visible">
<path
id="path5518-1"
style="fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:#808080;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker3450-8"
style="overflow:visible">
<path
id="path3448-7"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2910-9"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2908-2" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2792-0"
style="overflow:visible">
<path
id="path2790-2"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2680-3"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#de87aa;fill-opacity:1;fill-rule:evenodd;stroke:#de87aa;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2678-7" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2288-5"
style="overflow:visible">
<path
id="path2286-9"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2194-2"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2192-2" />
</marker>
<marker
orient="auto"
refY="0"
refX="0"
id="marker2106-8"
style="overflow:visible">
<path
id="path2104-9"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-0.3,0,0,-0.3,0.69,0)" />
</marker>
<marker
style="overflow:visible"
id="marker2006-7"
refX="0"
refY="0"
orient="auto">
<path
transform="matrix(-0.3,0,0,-0.3,0.69,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#55ddff;fill-opacity:1;fill-rule:evenodd;stroke:#55ddff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path2004-3" />
</marker>
<g
id="g16974">
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-0">
<path
style="stroke:none"
d=""
id="path16947" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-1">
<path
style="stroke:none"
d="M 5.6875,-2.625 6.59375,0 h 1.25 L 4.765625,-8.75 h -1.4375 L 0.203125,0 h 1.1875 L 2.3125,-2.625 Z M 5.375,-3.5625 H 2.59375 l 1.4375,-3.984375 z m 0,0"
id="path16950" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-2">
<path
style="stroke:none"
d="M 1.828125,-8.75 H 0.8125 V 0 h 1.015625 z m 0,0"
id="path16953" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-3">
<path
style="stroke:none"
d=""
id="path16956" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-4">
<path
style="stroke:none"
d="m 5.25,-4.53125 c 0,-1.234375 -0.828125,-1.9375 -2.28125,-1.9375 -1.453125,0 -2.40625,0.75 -2.40625,1.921875 0,0.984375 0.5,1.453125 2,1.8125 l 0.921875,0.21875 c 0.703125,0.171875 0.984375,0.421875 0.984375,0.875 0,0.59375 -0.59375,1 -1.46875,1 -0.546875,0 -1,-0.15625 -1.25,-0.421875 C 1.59375,-1.25 1.53125,-1.421875 1.46875,-1.875 h -1.0625 c 0.046875,1.453125 0.859375,2.15625 2.515625,2.15625 1.578125,0 2.59375,-0.78125 2.59375,-2 0,-0.9375 -0.53125,-1.453125 -1.78125,-1.75 l -0.96875,-0.234375 c -0.8125,-0.1875 -1.15625,-0.453125 -1.15625,-0.890625 0,-0.59375 0.515625,-0.953125 1.328125,-0.953125 0.8125,0 1.234375,0.34375 1.265625,1.015625 z m 0,0"
id="path16959" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-5">
<path
style="stroke:none"
d="M 6.421875,-0.59375 C 6.3125,-0.5625 6.265625,-0.5625 6.203125,-0.5625 c -0.34375,0 -0.546875,-0.1875 -0.546875,-0.5 V -4.75 c 0,-1.125 -0.8125,-1.71875 -2.359375,-1.71875 -0.921875,0 -1.65625,0.265625 -2.078125,0.734375 -0.296875,0.328125 -0.421875,0.6875 -0.4375,1.3125 h 1 c 0.09375,-0.78125 0.546875,-1.125 1.484375,-1.125 0.90625,0 1.40625,0.34375 1.40625,0.9375 V -4.34375 C 4.65625,-3.90625 4.4375,-3.75 3.625,-3.640625 2.203125,-3.46875 1.984375,-3.421875 1.609375,-3.265625 0.875,-2.953125 0.5,-2.40625 0.5,-1.578125 0.5,-0.4375 1.296875,0.28125 2.5625,0.28125 3.359375,0.28125 4,0 4.703125,-0.640625 4.78125,0 5.09375,0.28125 5.734375,0.28125 c 0.21875,0 0.34375,-0.03125 0.6875,-0.109375 z m -1.75,-1.390625 c 0,0.34375 -0.09375,0.546875 -0.40625,0.828125 -0.40625,0.359375 -0.890625,0.5625 -1.484375,0.5625 -0.78125,0 -1.234375,-0.375 -1.234375,-1.015625 0,-0.65625 0.4375,-1 1.515625,-1.15625 1.0625,-0.140625 1.265625,-0.1875 1.609375,-0.34375 z m 0,0"
id="path16962" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-6">
<path
style="stroke:none"
d="M 0.84375,-6.28125 V 0 h 1 v -3.953125 c 0,-0.90625 0.671875,-1.640625 1.484375,-1.640625 0.734375,0 1.15625,0.453125 1.15625,1.265625 V 0 H 5.5 v -3.953125 c 0,-0.90625 0.65625,-1.640625 1.46875,-1.640625 0.734375,0 1.171875,0.46875 1.171875,1.265625 V 0 h 1 v -4.71875 c 0,-1.125 -0.640625,-1.75 -1.828125,-1.75 -0.828125,0 -1.34375,0.25 -1.921875,0.953125 -0.375,-0.671875 -0.875,-0.953125 -1.6875,-0.953125 -0.84375,0 -1.40625,0.3125 -1.9375,1.0625 v -0.875 z m 0,0"
id="path16965" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-7">
<path
style="stroke:none"
d="M 0.640625,2.609375 H 1.65625 V -0.65625 c 0.53125,0.640625 1.109375,0.9375 1.9375,0.9375 1.625,0 2.6875,-1.3125 2.6875,-3.3125 0,-2.109375 -1.03125,-3.4375 -2.703125,-3.4375 -0.859375,0 -1.53125,0.390625 -2,1.125 v -0.9375 h -0.9375 z M 3.40625,-5.53125 c 1.109375,0 1.828125,0.96875 1.828125,2.46875 0,1.4375 -0.734375,2.40625 -1.828125,2.40625 -1.0625,0 -1.75,-0.96875 -1.75,-2.4375 0,-1.484375 0.6875,-2.4375 1.75,-2.4375 z m 0,0"
id="path16968" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-8">
<path
style="stroke:none"
d="m 6.15625,-2.8125 c 0,-0.953125 -0.078125,-1.53125 -0.25,-2 C 5.5,-5.84375 4.53125,-6.46875 3.359375,-6.46875 c -1.75,0 -2.875,1.328125 -2.875,3.40625 0,2.078125 1.078125,3.34375 2.859375,3.34375 1.4375,0 2.421875,-0.828125 2.6875,-2.1875 H 5.015625 C 4.734375,-1.078125 4.171875,-0.640625 3.375,-0.640625 2.734375,-0.640625 2.203125,-0.9375 1.859375,-1.46875 1.625,-1.828125 1.53125,-2.1875 1.53125,-2.8125 Z M 1.546875,-3.625 C 1.625,-4.78125 2.34375,-5.546875 3.34375,-5.546875 4.375,-5.546875 5.078125,-4.75 5.078125,-3.625 Z m 0,0"
id="path16971" />
</symbol>
</g>
<g
id="g46644">
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-0-3">
<path
style="stroke:none"
d=""
id="path46503" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-1-6">
<path
style="stroke:none"
d="M 5.6875,-2.625 6.59375,0 h 1.25 L 4.765625,-8.75 h -1.4375 L 0.203125,0 h 1.1875 L 2.3125,-2.625 Z M 5.375,-3.5625 H 2.59375 l 1.4375,-3.984375 z m 0,0"
id="path46506" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-2-7">
<path
style="stroke:none"
d="M 1.828125,-8.75 H 0.8125 V 0 h 1.015625 z m 0,0"
id="path46509" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-3-5">
<path
style="stroke:none"
d=""
id="path46512" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-4-3">
<path
style="stroke:none"
d="m 5.25,-4.53125 c 0,-1.234375 -0.828125,-1.9375 -2.28125,-1.9375 -1.453125,0 -2.40625,0.75 -2.40625,1.921875 0,0.984375 0.5,1.453125 2,1.8125 l 0.921875,0.21875 c 0.703125,0.171875 0.984375,0.421875 0.984375,0.875 0,0.59375 -0.59375,1 -1.46875,1 -0.546875,0 -1,-0.15625 -1.25,-0.421875 C 1.59375,-1.25 1.53125,-1.421875 1.46875,-1.875 h -1.0625 c 0.046875,1.453125 0.859375,2.15625 2.515625,2.15625 1.578125,0 2.59375,-0.78125 2.59375,-2 0,-0.9375 -0.53125,-1.453125 -1.78125,-1.75 l -0.96875,-0.234375 c -0.8125,-0.1875 -1.15625,-0.453125 -1.15625,-0.890625 0,-0.59375 0.515625,-0.953125 1.328125,-0.953125 0.8125,0 1.234375,0.34375 1.265625,1.015625 z m 0,0"
id="path46515" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-5-5">
<path
style="stroke:none"
d="M 6.421875,-0.59375 C 6.3125,-0.5625 6.265625,-0.5625 6.203125,-0.5625 c -0.34375,0 -0.546875,-0.1875 -0.546875,-0.5 V -4.75 c 0,-1.125 -0.8125,-1.71875 -2.359375,-1.71875 -0.921875,0 -1.65625,0.265625 -2.078125,0.734375 -0.296875,0.328125 -0.421875,0.6875 -0.4375,1.3125 h 1 c 0.09375,-0.78125 0.546875,-1.125 1.484375,-1.125 0.90625,0 1.40625,0.34375 1.40625,0.9375 V -4.34375 C 4.65625,-3.90625 4.4375,-3.75 3.625,-3.640625 2.203125,-3.46875 1.984375,-3.421875 1.609375,-3.265625 0.875,-2.953125 0.5,-2.40625 0.5,-1.578125 0.5,-0.4375 1.296875,0.28125 2.5625,0.28125 3.359375,0.28125 4,0 4.703125,-0.640625 4.78125,0 5.09375,0.28125 5.734375,0.28125 c 0.21875,0 0.34375,-0.03125 0.6875,-0.109375 z m -1.75,-1.390625 c 0,0.34375 -0.09375,0.546875 -0.40625,0.828125 -0.40625,0.359375 -0.890625,0.5625 -1.484375,0.5625 -0.78125,0 -1.234375,-0.375 -1.234375,-1.015625 0,-0.65625 0.4375,-1 1.515625,-1.15625 1.0625,-0.140625 1.265625,-0.1875 1.609375,-0.34375 z m 0,0"
id="path46518" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-6-6">
<path
style="stroke:none"
d="M 0.84375,-6.28125 V 0 h 1 v -3.953125 c 0,-0.90625 0.671875,-1.640625 1.484375,-1.640625 0.734375,0 1.15625,0.453125 1.15625,1.265625 V 0 H 5.5 v -3.953125 c 0,-0.90625 0.65625,-1.640625 1.46875,-1.640625 0.734375,0 1.171875,0.46875 1.171875,1.265625 V 0 h 1 v -4.71875 c 0,-1.125 -0.640625,-1.75 -1.828125,-1.75 -0.828125,0 -1.34375,0.25 -1.921875,0.953125 -0.375,-0.671875 -0.875,-0.953125 -1.6875,-0.953125 -0.84375,0 -1.40625,0.3125 -1.9375,1.0625 v -0.875 z m 0,0"
id="path46521" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-7-2">
<path
style="stroke:none"
d="M 0.640625,2.609375 H 1.65625 V -0.65625 c 0.53125,0.640625 1.109375,0.9375 1.9375,0.9375 1.625,0 2.6875,-1.3125 2.6875,-3.3125 0,-2.109375 -1.03125,-3.4375 -2.703125,-3.4375 -0.859375,0 -1.53125,0.390625 -2,1.125 v -0.9375 h -0.9375 z M 3.40625,-5.53125 c 1.109375,0 1.828125,0.96875 1.828125,2.46875 0,1.4375 -0.734375,2.40625 -1.828125,2.40625 -1.0625,0 -1.75,-0.96875 -1.75,-2.4375 0,-1.484375 0.6875,-2.4375 1.75,-2.4375 z m 0,0"
id="path46524" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-8-9">
<path
style="stroke:none"
d="m 6.15625,-2.8125 c 0,-0.953125 -0.078125,-1.53125 -0.25,-2 C 5.5,-5.84375 4.53125,-6.46875 3.359375,-6.46875 c -1.75,0 -2.875,1.328125 -2.875,3.40625 0,2.078125 1.078125,3.34375 2.859375,3.34375 1.4375,0 2.421875,-0.828125 2.6875,-2.1875 H 5.015625 C 4.734375,-1.078125 4.171875,-0.640625 3.375,-0.640625 2.734375,-0.640625 2.203125,-0.9375 1.859375,-1.46875 1.625,-1.828125 1.53125,-2.1875 1.53125,-2.8125 Z M 1.546875,-3.625 C 1.625,-4.78125 2.34375,-5.546875 3.34375,-5.546875 4.375,-5.546875 5.078125,-4.75 5.078125,-3.625 Z m 0,0"
id="path46527" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-9">
<path
style="stroke:none"
d="m 0.953125,0 h 3.9375 C 5.71875,0 6.34375,-0.234375 6.796875,-0.734375 7.234375,-1.1875 7.46875,-1.8125 7.46875,-2.5 7.46875,-3.546875 7,-4.1875 5.875,-4.625 c 0.8125,-0.359375 1.21875,-1 1.21875,-1.90625 0,-0.640625 -0.234375,-1.203125 -0.703125,-1.609375 C 5.921875,-8.5625 5.34375,-8.75 4.5,-8.75 H 0.953125 Z M 2.0625,-4.984375 v -2.78125 h 2.15625 c 0.625,0 0.984375,0.078125 1.28125,0.3125 0.3125,0.234375 0.46875,0.59375 0.46875,1.078125 0,0.484375 -0.15625,0.84375 -0.46875,1.078125 -0.296875,0.234375 -0.65625,0.3125 -1.28125,0.3125 z m 0,4 V -4 h 2.71875 c 0.984375,0 1.578125,0.5625 1.578125,1.515625 0,0.9375 -0.59375,1.5 -1.578125,1.5 z m 0,0"
id="path46530" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-10">
<path
style="stroke:none"
d="M 7.9375,-6.03125 C 7.59375,-7.953125 6.484375,-8.890625 4.578125,-8.890625 c -1.1875,0 -2.125,0.375 -2.78125,1.09375 -0.78125,0.859375 -1.21875,2.109375 -1.21875,3.53125 0,1.4375 0.4375,2.671875 1.265625,3.515625 0.671875,0.703125 1.546875,1.03125 2.6875,1.03125 2.125,0 3.328125,-1.15625 3.59375,-3.46875 H 6.96875 C 6.875,-2.59375 6.75,-2.1875 6.578125,-1.84375 6.21875,-1.109375 5.46875,-0.703125 4.53125,-0.703125 c -1.734375,0 -2.84375,-1.390625 -2.84375,-3.578125 0,-2.25 1.046875,-3.625 2.75,-3.625 0.703125,0 1.375,0.203125 1.734375,0.546875 0.3125,0.296875 0.5,0.65625 0.625,1.328125 z m 0,0"
id="path46533" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-11">
<path
style="stroke:none"
d="m 2.078125,-8.75 h -1.125 V 0 h 5.4375 v -0.984375 h -4.3125 z m 0,0"
id="path46536" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-12">
<path
style="stroke:none"
d="M 6.078125,-1.046875 H 1.59375 c 0.109375,-0.71875 0.5,-1.171875 1.53125,-1.8125 L 4.328125,-3.53125 C 5.515625,-4.1875 6.125,-5.078125 6.125,-6.140625 6.125,-6.859375 5.84375,-7.53125 5.34375,-8 c -0.5,-0.453125 -1.125,-0.671875 -1.9375,-0.671875 -1.078125,0 -1.875,0.375 -2.34375,1.125 -0.3125,0.453125 -0.4375,1 -0.46875,1.875 h 1.0625 c 0.03125,-0.59375 0.109375,-0.9375 0.25,-1.234375 C 2.1875,-7.421875 2.734375,-7.75 3.375,-7.75 c 0.953125,0 1.671875,0.6875 1.671875,1.625 0,0.703125 -0.390625,1.296875 -1.140625,1.734375 L 2.796875,-3.75 C 1.015625,-2.71875 0.5,-1.90625 0.40625,-0.015625 h 5.671875 z m 0,0"
id="path46539" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-13">
<path
style="stroke:none"
d="m 6.9375,1.515625 h -7.203125 v 0.59375 H 6.9375 Z m 0,0"
id="path46542" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-14">
<path
style="stroke:none"
d="m 5.609375,0 2.46875,-7.328125 V 0 H 9.125 V -8.75 H 7.578125 L 5.046875,-1.125 2.453125,-8.75 H 0.90625 V 0 H 1.953125 V -7.328125 L 4.4375,0 Z m 0,0"
id="path46545" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-15">
<path
style="stroke:none"
d="M 4.640625,-3.4375 7.9375,-8.75 H 6.59375 L 4.109375,-4.484375 1.53125,-8.75 h -1.375 l 3.375,5.3125 V 0 h 1.109375 z m 0,0"
id="path46548" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-16">
<path
style="stroke:none"
d="m 2.234375,-3.765625 h 2.875 c 1,0 1.4375,0.484375 1.4375,1.5625 v 0.78125 c 0,0.53125 0.09375,1.0625 0.25,1.421875 h 1.34375 V -0.28125 C 7.734375,-0.5625 7.640625,-0.875 7.625,-2.046875 7.609375,-3.484375 7.375,-3.90625 6.4375,-4.3125 c 0.984375,-0.5 1.375,-1.09375 1.375,-2.09375 C 7.8125,-7.921875 6.875,-8.75 5.140625,-8.75 H 1.109375 V 0 h 1.125 z m 0,-0.984375 V -7.765625 H 4.9375 c 0.625,0 0.984375,0.09375 1.25,0.34375 0.296875,0.25 0.453125,0.640625 0.453125,1.15625 C 6.640625,-5.21875 6.125,-4.75 4.9375,-4.75 Z m 0,0"
id="path46551" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-17">
<path
style="stroke:none"
d="M 2.203125,-3.984375 H 6.375 V -4.96875 H 2.203125 v -2.796875 h 4.75 V -8.75 h -5.875 V 0 h 1.125 z m 0,0"
id="path46554" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-18">
<path
style="stroke:none"
d="m 1.0625,0 h 3.375 C 6.640625,0 8,-1.65625 8,-4.375 8,-7.09375 6.65625,-8.75 4.4375,-8.75 h -3.375 z m 1.125,-0.984375 v -6.78125 H 4.25 c 1.71875,0 2.640625,1.171875 2.640625,3.390625 0,2.234375 -0.921875,3.390625 -2.640625,3.390625 z m 0,0"
id="path46557" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-19">
<path
style="stroke:none"
d="m 6.625,-8.75 v 6.140625 c 0,1.1875 -0.859375,1.90625 -2.25,1.90625 -0.65625,0 -1.1875,-0.15625 -1.609375,-0.453125 C 2.34375,-1.5 2.140625,-1.9375 2.140625,-2.609375 V -8.75 h -1.125 v 6.140625 c 0,1.78125 1.28125,2.890625 3.359375,2.890625 2.046875,0 3.359375,-1.140625 3.359375,-2.890625 V -8.75 Z m 0,0"
id="path46560" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-20">
<path
style="stroke:none"
d="M 4.6875,-4.484375 7.640625,-8.75 H 6.3125 l -2.25,3.4375 -2.25,-3.4375 H 0.453125 L 3.359375,-4.484375 0.265625,0 H 1.625 L 4.015625,-3.640625 6.40625,0 h 1.375 z m 0,0"
id="path46563" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-21">
<path
style="stroke:none"
d="M 3.921875,-2.09375 V 0 h 1.0625 v -2.09375 h 1.25 v -0.953125 h -1.25 v -5.625 H 4.203125 L 0.34375,-3.21875 v 1.125 z m 0,-0.953125 H 1.265625 L 3.921875,-6.875 Z m 0,0"
id="path46566" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-22">
<path
style="stroke:none"
d="m 2.203125,-3.984375 h 4.75 V -4.96875 h -4.75 v -2.796875 h 4.9375 V -8.75 h -6.0625 V 0 h 6.28125 v -0.984375 h -5.15625 z m 0,0"
id="path46569" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-23">
<path
style="stroke:none"
d="M 4.25,-7.765625 H 7.109375 V -8.75 H 0.25 v 0.984375 H 3.125 V 0 H 4.25 Z m 0,0"
id="path46572" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-24">
<path
style="stroke:none"
d="m 4.703125,0 3.03125,-8.75 h -1.1875 L 4.125,-1.34375 1.5625,-8.75 H 0.359375 L 3.5,0 Z m 0,0"
id="path46575" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-25">
<path
style="stroke:none"
d="m 5.96875,-6.421875 c -0.203125,-1.421875 -1.109375,-2.25 -2.40625,-2.25 -0.9375,0 -1.78125,0.453125 -2.28125,1.234375 -0.53125,0.84375 -0.765625,1.90625 -0.765625,3.484375 0,1.453125 0.203125,2.375 0.71875,3.15625 C 1.6875,-0.09375 2.4375,0.28125 3.375,0.28125 c 1.609375,0 2.78125,-1.21875 2.78125,-2.90625 0,-1.59375 -1.078125,-2.734375 -2.609375,-2.734375 -0.828125,0 -1.5,0.3125 -1.953125,0.953125 0.015625,-2.140625 0.6875,-3.328125 1.890625,-3.328125 0.75,0 1.265625,0.46875 1.4375,1.3125 z m -2.546875,2 c 1.015625,0 1.65625,0.71875 1.65625,1.875 0,1.09375 -0.71875,1.890625 -1.6875,1.890625 -0.984375,0 -1.734375,-0.828125 -1.734375,-1.9375 0,-1.078125 0.71875,-1.828125 1.765625,-1.828125 z m 0,0"
id="path46578" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-26">
<path
style="stroke:none"
d="m 2.296875,-1.25 h -1.25 V 0 h 1.25 z m 0,0"
id="path46581" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-27">
<path
style="stroke:none"
d="M 7.75,-8.75 H 6.703125 v 7.15625 L 2.125,-8.75 H 0.90625 V 0 h 1.0625 V -7.09375 L 6.484375,0 H 7.75 Z m 0,0"
id="path46584" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-28">
<path
style="stroke:none"
d="M 3.109375,-6.1875 V 0 H 4.15625 v -8.671875 h -0.6875 c -0.375,1.328125 -0.609375,1.515625 -2.25,1.71875 V -6.1875 Z m 0,0"
id="path46587" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-29">
<path
style="stroke:none"
d="M 6.609375,-3.984375 V 0 h 1.125 v -8.75 h -1.125 v 3.78125 h -4.5 V -8.75 H 1 V 0 h 1.109375 v -3.984375 z m 0,0"
id="path46590" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-30">
<path
style="stroke:none"
d="M 4.65625,-6.28125 2.921875,-1.390625 1.3125,-6.28125 H 0.234375 l 2.125,6.3125 -0.375,0.984375 C 1.8125,1.46875 1.59375,1.625 1.171875,1.625 c -0.15625,0 -0.3125,-0.015625 -0.53125,-0.0625 V 2.453125 C 0.859375,2.5625 1.0625,2.609375 1.3125,2.609375 c 0.328125,0 0.671875,-0.09375 0.9375,-0.296875 0.3125,-0.21875 0.5,-0.484375 0.6875,-1 l 2.796875,-7.59375 z m 0,0"
id="path46593" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-31">
<path
style="stroke:none"
d="M 0.828125,-6.28125 V 0 H 1.84375 v -3.265625 c 0,-1.515625 0.625,-2.1875 2.015625,-2.140625 V -6.4375 C 3.6875,-6.453125 3.59375,-6.46875 3.46875,-6.46875 2.8125,-6.46875 2.328125,-6.078125 1.75,-5.140625 V -6.28125 Z m 0,0"
id="path46596" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-32">
<path
style="stroke:none"
d="m 5.9375,-8.75 h -1 V -5.5 C 4.53125,-6.125 3.859375,-6.46875 3.015625,-6.46875 c -1.640625,0 -2.703125,1.3125 -2.703125,3.3125 0,2.125 1.03125,3.4375 2.734375,3.4375 0.859375,0 1.46875,-0.328125 2,-1.109375 V 0 H 5.9375 Z m -2.75,3.21875 c 1.078125,0 1.75,0.953125 1.75,2.453125 0,1.453125 -0.6875,2.421875 -1.75,2.421875 -1.09375,0 -1.828125,-0.96875 -1.828125,-2.4375 0,-1.46875 0.734375,-2.4375 1.828125,-2.4375 z m 0,0"
id="path46599" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-33">
<path
style="stroke:none"
d="m 1.796875,-6.28125 h -1 V 0 h 1 z m 0,-2.46875 h -1 v 1.265625 h 1 z m 0,0"
id="path46602" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-34">
<path
style="stroke:none"
d="m 3.265625,-6.46875 c -1.78125,0 -2.828125,1.265625 -2.828125,3.375 0,2.125 1.046875,3.375 2.84375,3.375 1.765625,0 2.84375,-1.265625 2.84375,-3.328125 0,-2.1875 -1.03125,-3.421875 -2.859375,-3.421875 z m 0.015625,0.921875 c 1.125,0 1.796875,0.921875 1.796875,2.484375 0,1.484375 -0.703125,2.421875 -1.796875,2.421875 -1.125,0 -1.8125,-0.9375 -1.8125,-2.453125 0,-1.53125 0.6875,-2.453125 1.8125,-2.453125 z m 0,0"
id="path46605" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-35">
<path
style="stroke:none"
d="m 2.203125,-3.703125 h 2.75 c 0.6875,0 1.234375,-0.203125 1.6875,-0.625 C 7.171875,-4.8125 7.40625,-5.375 7.40625,-6.1875 7.40625,-7.828125 6.4375,-8.75 4.703125,-8.75 H 1.09375 V 0 h 1.109375 z m 0,-0.984375 V -7.765625 H 4.53125 c 1.078125,0 1.703125,0.578125 1.703125,1.53125 0,0.96875 -0.625,1.546875 -1.703125,1.546875 z m 0,0"
id="path46608" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-36">
<path
style="stroke:none"
d="m 2.328125,-8.75 h -1.125 V 0 h 1.125 z m 0,0"
id="path46611" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-37">
<path
style="stroke:none"
d="M 2.0625,-3.0625 3.484375,-4.484375 6.578125,0 h 1.3125 l -3.59375,-5.1875 3.5625,-3.5625 h -1.4375 L 2.0625,-4.3125 V -8.75 H 0.953125 V 0 H 2.0625 Z m 0,0"
id="path46614" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-38">
<path
style="stroke:none"
d="M 6.96875,-8.75 H 0.671875 v 0.984375 H 5.59375 l -5.25,6.78125 V 0 H 7 V -0.984375 H 1.734375 l 5.234375,-6.75 z m 0,0"
id="path46617" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-39">
<path
style="stroke:none"
d="M 0.84375,-6.28125 V 0 h 1 v -3.46875 c 0,-1.28125 0.671875,-2.125 1.703125,-2.125 0.796875,0 1.296875,0.484375 1.296875,1.234375 V 0 h 1 v -4.75 c 0,-1.046875 -0.78125,-1.71875 -1.984375,-1.71875 -0.9375,0 -1.546875,0.359375 -2.09375,1.234375 V -6.28125 Z m 0,0"
id="path46620" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-40">
<path
style="stroke:none"
d="M 5.71875,-8.515625 H 1.3125 L 0.6875,-3.875 h 0.96875 c 0.484375,-0.59375 0.90625,-0.796875 1.578125,-0.796875 1.140625,0 1.84375,0.78125 1.84375,2.046875 0,1.21875 -0.703125,1.96875 -1.859375,1.96875 -0.921875,0 -1.484375,-0.46875 -1.75,-1.4375 H 0.421875 C 0.5625,-1.390625 0.6875,-1.0625 0.9375,-0.75 c 0.484375,0.65625 1.34375,1.03125 2.296875,1.03125 1.71875,0 2.921875,-1.25 2.921875,-3.046875 0,-1.6875 -1.109375,-2.84375 -2.75,-2.84375 -0.59375,0 -1.078125,0.15625 -1.5625,0.515625 l 0.328125,-2.375 H 5.71875 Z m 0,0"
id="path46623" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-41">
<path
style="stroke:none"
d="M 0.640625,-1.984375 C 0.84375,-0.5625 1.75,0.28125 3.046875,0.28125 4,0.28125 4.84375,-0.1875 5.34375,-0.953125 5.875,-1.8125 6.109375,-2.875 6.109375,-4.4375 c 0,-1.46875 -0.21875,-2.390625 -0.71875,-3.15625 -0.46875,-0.703125 -1.21875,-1.078125 -2.15625,-1.078125 -1.609375,0 -2.78125,1.203125 -2.78125,2.890625 0,1.59375 1.078125,2.71875 2.625,2.71875 0.796875,0 1.390625,-0.28125 1.9375,-0.953125 C 5,-1.84375 4.328125,-0.65625 3.125,-0.65625 c -0.75,0 -1.265625,-0.484375 -1.4375,-1.328125 z M 3.234375,-7.75 c 0.984375,0 1.71875,0.828125 1.71875,1.9375 C 4.953125,-4.734375 4.234375,-4 3.1875,-4 2.171875,-4 1.53125,-4.71875 1.53125,-5.875 1.53125,-6.953125 2.25,-7.75 3.234375,-7.75 Z m 0,0"
id="path46626" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-42">
<path
style="stroke:none"
d="m 3.046875,-6.28125 h -1.03125 v -1.734375 h -1 v 1.734375 h -0.84375 v 0.8125 h 0.84375 v 4.75 c 0,0.640625 0.4375,1 1.21875,1 C 2.5,0.28125 2.71875,0.25 3.046875,0.1875 V -0.640625 C 2.90625,-0.609375 2.765625,-0.59375 2.5625,-0.59375 c -0.421875,0 -0.546875,-0.125 -0.546875,-0.5625 v -4.3125 h 1.03125 z m 0,0"
id="path46629" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-43">
<path
style="stroke:none"
d="m 4.6875,-4.578125 c 0.890625,-0.53125 1.171875,-0.96875 1.171875,-1.78125 0,-1.375 -1.046875,-2.3125 -2.5625,-2.3125 -1.5,0 -2.546875,0.9375 -2.546875,2.296875 0,0.828125 0.265625,1.25 1.140625,1.796875 -0.96875,0.5 -1.453125,1.203125 -1.453125,2.171875 0,1.578125 1.171875,2.6875 2.859375,2.6875 1.6875,0 2.859375,-1.109375 2.859375,-2.6875 0,-0.96875 -0.484375,-1.671875 -1.46875,-2.171875 z m -1.390625,-3.15625 c 0.90625,0 1.484375,0.53125 1.484375,1.390625 0,0.828125 -0.59375,1.359375 -1.484375,1.359375 -0.890625,0 -1.46875,-0.53125 -1.46875,-1.375 0,-0.84375 0.578125,-1.375 1.46875,-1.375 z m 0,3.640625 c 1.0625,0 1.78125,0.703125 1.78125,1.703125 0,1.046875 -0.703125,1.734375 -1.796875,1.734375 -1.03125,0 -1.75,-0.71875 -1.75,-1.71875 0,-1.03125 0.703125,-1.71875 1.765625,-1.71875 z m 0,0"
id="path46632" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-44">
<path
style="stroke:none"
d="m 3.296875,-8.671875 c -0.78125,0 -1.515625,0.359375 -1.953125,0.9375 -0.546875,0.78125 -0.828125,1.921875 -0.828125,3.53125 0,2.9375 0.953125,4.484375 2.78125,4.484375 1.796875,0 2.78125,-1.546875 2.78125,-4.40625 0,-1.6875 -0.265625,-2.8125 -0.828125,-3.609375 -0.4375,-0.59375 -1.140625,-0.9375 -1.953125,-0.9375 z m 0,0.9375 C 4.4375,-7.734375 5,-6.578125 5,-4.21875 c 0,2.46875 -0.546875,3.625 -1.71875,3.625 -1.125,0 -1.6875,-1.203125 -1.6875,-3.59375 0,-2.390625 0.5625,-3.546875 1.703125,-3.546875 z m 0,0"
id="path46635" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-45">
<path
style="stroke:none"
d="M 0.84375,-8.75 V 0 h 1 v -3.46875 c 0,-1.28125 0.671875,-2.125 1.703125,-2.125 0.328125,0 0.640625,0.09375 0.875,0.28125 0.296875,0.21875 0.421875,0.515625 0.421875,0.953125 V 0 h 0.984375 v -4.75 c 0,-1.0625 -0.75,-1.71875 -1.96875,-1.71875 -0.890625,0 -1.4375,0.28125 -2.015625,1.046875 V -8.75 Z m 0,0"
id="path46638" />
</symbol>
<symbol
style="overflow:visible"
overflow="visible"
id="glyph0-46">
<path
style="stroke:none"
d="m 2.65625,-4 h 0.578125 c 1.140625,0 1.75,0.546875 1.75,1.59375 0,1.09375 -0.65625,1.75 -1.75,1.75 -1.15625,0 -1.71875,-0.59375 -1.796875,-1.859375 H 0.390625 c 0.046875,0.6875 0.15625,1.140625 0.359375,1.53125 0.453125,0.84375 1.28125,1.265625 2.4375,1.265625 1.75,0 2.890625,-1.0625 2.890625,-2.703125 C 6.078125,-3.53125 5.65625,-4.125 4.625,-4.484375 5.421875,-4.8125 5.8125,-5.40625 5.8125,-6.28125 c 0,-1.5 -0.96875,-2.390625 -2.578125,-2.390625 -1.71875,0 -2.640625,0.953125 -2.671875,2.796875 H 1.625 c 0,-0.53125 0.0625,-0.828125 0.1875,-1.09375 0.234375,-0.5 0.765625,-0.78125 1.421875,-0.78125 0.9375,0 1.5,0.5625 1.5,1.5 0,0.609375 -0.203125,0.984375 -0.671875,1.1875 -0.296875,0.125 -0.671875,0.171875 -1.40625,0.171875 z m 0,0"
id="path46641" />
</symbol>
</g>
<g
id="g450">
<symbol
id="glyph0-0-36"
overflow="visible"
style="overflow:visible">
<path
id="path405"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph0-1-7"
overflow="visible"
style="overflow:visible">
<path
id="path408"
d="M 8.1875,-3.78125 9.484375,0 H 11.28125 L 6.859375,-12.59375 H 4.78125 L 0.296875,0 H 2 L 3.328125,-3.78125 Z M 7.734375,-5.125 h -4 l 2.078125,-5.75 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-2-5"
overflow="visible"
style="overflow:visible">
<path
id="path411"
d="M 9.546875,-12.59375 V -3.75 c 0,1.6875 -1.234375,2.734375 -3.25,2.734375 -0.9375,0 -1.703125,-0.234375 -2.3125,-0.65625 C 3.375,-2.15625 3.078125,-2.796875 3.078125,-3.75 v -8.84375 H 1.46875 V -3.75 c 0,2.5625 1.828125,4.140625 4.828125,4.140625 2.953125,0 4.84375,-1.625 4.84375,-4.140625 v -8.84375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-3-3"
overflow="visible"
style="overflow:visible">
<path
id="path414"
d="M 3.296875,-1.796875 H 1.5 V 0 h 1.796875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-4-5"
overflow="visible"
style="overflow:visible">
<path
id="path417"
d="M 4.46875,-8.90625 V 0 H 6 V -12.5 H 5 c -0.546875,1.921875 -0.890625,2.1875 -3.234375,2.5 v 1.09375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-5-6"
overflow="visible"
style="overflow:visible">
<path
id="path420"
d="M 8.75,-1.5 H 2.296875 C 2.453125,-2.546875 3,-3.203125 4.515625,-4.109375 l 1.71875,-0.96875 c 1.71875,-0.953125 2.59375,-2.234375 2.59375,-3.765625 0,-1.046875 -0.40625,-2.015625 -1.140625,-2.6875 C 6.96875,-12.1875 6.0625,-12.5 4.90625,-12.5 c -1.546875,0 -2.71875,0.5625 -3.390625,1.625 -0.421875,0.65625 -0.609375,1.4375 -0.65625,2.703125 h 1.53125 C 2.4375,-9.015625 2.546875,-9.515625 2.75,-9.9375 c 0.390625,-0.765625 1.1875,-1.21875 2.109375,-1.21875 1.375,0 2.421875,1 2.421875,2.34375 0,1 -0.578125,1.859375 -1.671875,2.484375 l -1.578125,0.9375 c -2.5625,1.46875 -3.3125,2.640625 -3.4375,5.375 H 8.75 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-6-2"
overflow="visible"
style="overflow:visible">
<path
id="path423"
d="m 3.8125,-5.75 h 0.84375 c 1.65625,0 2.53125,0.765625 2.53125,2.28125 0,1.5625 -0.953125,2.515625 -2.515625,2.515625 -1.6875,0 -2.5,-0.84375 -2.59375,-2.671875 h -1.53125 c 0.078125,1 0.25,1.65625 0.546875,2.203125 0.640625,1.21875 1.828125,1.8125 3.5,1.8125 C 7.125,0.390625 8.75,-1.125 8.75,-3.484375 8.75,-5.078125 8.140625,-5.9375 6.671875,-6.46875 7.8125,-6.9375 8.375,-7.796875 8.375,-9.0625 8.375,-11.203125 6.984375,-12.5 4.65625,-12.5 c -2.484375,0 -3.796875,1.390625 -3.84375,4.03125 h 1.515625 c 0.015625,-0.765625 0.09375,-1.1875 0.28125,-1.578125 0.34375,-0.703125 1.109375,-1.109375 2.0625,-1.109375 1.34375,0 2.15625,0.8125 2.15625,2.15625 0,0.875 -0.3125,1.40625 -0.984375,1.703125 C 5.421875,-7.125 4.875,-7.046875 3.8125,-7.03125 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-0"
overflow="visible"
style="overflow:visible">
<path
id="path426"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph1-1"
overflow="visible"
style="overflow:visible">
<path
id="path429"
d="m 1.1875,0 h 4.71875 c 1.203125,0 2.015625,-0.234375 2.65625,-0.765625 0.625,-0.53125 1.03125,-1.40625 1.03125,-2.265625 0,-1.03125 -0.546875,-1.859375 -1.75,-2.546875 1.046875,-0.65625 1.453125,-1.265625 1.453125,-2.15625 0,-0.734375 -0.359375,-1.484375 -0.953125,-2 C 7.71875,-10.265625 6.984375,-10.5 5.859375,-10.5 H 1.1875 Z M 3.34375,-8.703125 H 5.6875 c 1.015625,0 1.53125,0.40625 1.53125,1.1875 0,0.78125 -0.515625,1.1875 -1.53125,1.1875 H 3.34375 Z m 0,4.171875 h 2.578125 c 1.046875,0 1.59375,0.46875 1.59375,1.375 0,0.890625 -0.546875,1.359375 -1.59375,1.359375 H 3.34375 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-2"
overflow="visible"
style="overflow:visible">
<path
id="path432"
d="M 9.828125,-6.9375 C 9.75,-7.84375 9.5625,-8.421875 9.125,-9.015625 c -0.8125,-1.0625 -2.109375,-1.65625 -3.671875,-1.65625 -2.96875,0 -4.8125,2.109375 -4.8125,5.515625 0,3.390625 1.828125,5.484375 4.75,5.484375 2.625,0 4.34375,-1.515625 4.484375,-3.921875 H 7.765625 C 7.625,-2.25 6.78125,-1.484375 5.453125,-1.484375 c -1.671875,0 -2.65625,-1.359375 -2.65625,-3.640625 0,-2.328125 1.015625,-3.703125 2.71875,-3.703125 1.25,0 1.96875,0.609375 2.25,1.890625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-3"
overflow="visible"
style="overflow:visible">
<path
id="path435"
d="M 3.3125,-10.5 H 1.15625 V 0 h 7.1875 V -1.796875 H 3.3125 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-4"
overflow="visible"
style="overflow:visible">
<path
id="path438"
d="M 7.375,-1.796875 H 3.046875 C 3.3125,-2.34375 3.625,-2.65625 5.125,-3.734375 6.90625,-5.03125 7.421875,-5.796875 7.421875,-7.1875 c 0,-1.96875 -1.375,-3.25 -3.5,-3.25 -2.125,0 -3.359375,1.265625 -3.359375,3.421875 V -6.65625 H 2.5 V -6.984375 C 2.5,-8.125 3.046875,-8.78125 3.96875,-8.78125 c 0.890625,0 1.4375,0.609375 1.4375,1.640625 C 5.40625,-6 5.0625,-5.59375 2.78125,-3.96875 1.046875,-2.796875 0.515625,-1.90625 0.4375,0 H 7.375 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-5"
overflow="visible"
style="overflow:visible">
<path
id="path441"
d="M 3,-10.28125 0.03125,0.203125 H 1 L 3.96875,-10.28125 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-6"
overflow="visible"
style="overflow:visible">
<path
id="path444"
d="M 3.109375,-8.1875 5,0 H 7.15625 L 9.015625,-8.1875 V 0 h 2.15625 v -10.5 h -3.25 L 6.078125,-2.140625 4.171875,-10.5 H 0.953125 V 0 h 2.15625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-7"
overflow="visible"
style="overflow:visible">
<path
id="path447"
d="M 6.03125,-3.890625 9.359375,-10.5 H 6.9375 l -2,4.640625 L 2.796875,-10.5 H 0.390625 L 3.875,-3.890625 V 0 h 2.15625 z m 0,0"
style="stroke:none" />
</symbol>
</g>
<g
id="g6718">
<symbol
id="glyph0-0-8"
overflow="visible"
style="overflow:visible">
<path
id="path6685"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph0-1-9"
overflow="visible"
style="overflow:visible">
<path
id="path6688"
d="M 8.1875,-3.78125 9.484375,0 H 11.28125 L 6.859375,-12.59375 H 4.78125 L 0.296875,0 H 2 L 3.328125,-3.78125 Z M 7.734375,-5.125 h -4 l 2.078125,-5.75 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-2-73"
overflow="visible"
style="overflow:visible">
<path
id="path6691"
d="M 9.546875,-12.59375 V -3.75 c 0,1.6875 -1.234375,2.734375 -3.25,2.734375 -0.9375,0 -1.703125,-0.234375 -2.3125,-0.65625 C 3.375,-2.15625 3.078125,-2.796875 3.078125,-3.75 v -8.84375 H 1.46875 V -3.75 c 0,2.5625 1.828125,4.140625 4.828125,4.140625 2.953125,0 4.84375,-1.625 4.84375,-4.140625 v -8.84375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-3-6"
overflow="visible"
style="overflow:visible">
<path
id="path6694"
d="M 3.296875,-1.796875 H 1.5 V 0 h 1.796875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-4-1"
overflow="visible"
style="overflow:visible">
<path
id="path6697"
d="m 4.75,-12.5 c -1.140625,0 -2.171875,0.53125 -2.8125,1.375 -0.796875,1.109375 -1.1875,2.765625 -1.1875,5.078125 0,4.21875 1.375,6.4375 4,6.4375 2.59375,0 4.015625,-2.21875 4.015625,-6.328125 C 8.765625,-8.359375 8.375,-9.984375 7.5625,-11.125 6.9375,-12 5.90625,-12.5 4.75,-12.5 Z m 0,1.359375 c 1.640625,0 2.453125,1.671875 2.453125,5.0625 0,3.5625 -0.796875,5.21875 -2.484375,5.21875 -1.609375,0 -2.421875,-1.734375 -2.421875,-5.171875 0,-3.4375 0.8125,-5.109375 2.453125,-5.109375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-5-2"
overflow="visible"
style="overflow:visible">
<path
id="path6700"
d="M 8.75,-1.5 H 2.296875 C 2.453125,-2.546875 3,-3.203125 4.515625,-4.109375 l 1.71875,-0.96875 c 1.71875,-0.953125 2.59375,-2.234375 2.59375,-3.765625 0,-1.046875 -0.40625,-2.015625 -1.140625,-2.6875 C 6.96875,-12.1875 6.0625,-12.5 4.90625,-12.5 c -1.546875,0 -2.71875,0.5625 -3.390625,1.625 -0.421875,0.65625 -0.609375,1.4375 -0.65625,2.703125 h 1.53125 C 2.4375,-9.015625 2.546875,-9.515625 2.75,-9.9375 c 0.390625,-0.765625 1.1875,-1.21875 2.109375,-1.21875 1.375,0 2.421875,1 2.421875,2.34375 0,1 -0.578125,1.859375 -1.671875,2.484375 l -1.578125,0.9375 c -2.5625,1.46875 -3.3125,2.640625 -3.4375,5.375 H 8.75 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-6-9"
overflow="visible"
style="overflow:visible">
<path
id="path6703"
d="M 4.46875,-8.90625 V 0 H 6 V -12.5 H 5 c -0.546875,1.921875 -0.890625,2.1875 -3.234375,2.5 v 1.09375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-0-3"
overflow="visible"
style="overflow:visible">
<path
id="path6706"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph1-1-1"
overflow="visible"
style="overflow:visible">
<path
id="path6709"
d="M 3.25,-3.75 H 5.953125 C 7.875,-3.75 9.125,-5.109375 9.125,-7.25 9.125,-9.34375 7.921875,-10.5 5.734375,-10.5 H 1.09375 V 0 H 3.25 Z m 0,-1.796875 v -3.15625 h 2.015625 c 1.15625,0 1.6875,0.5 1.6875,1.578125 0,1.078125 -0.53125,1.578125 -1.6875,1.578125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-2-9"
overflow="visible"
style="overflow:visible">
<path
id="path6712"
d="M 0.96875,-10.5 V 0 H 2.984375 V -4.671875 C 2.984375,-5.5625 3.625,-6.1875 4.53125,-6.1875 c 0.453125,0 0.78125,0.15625 1.015625,0.46875 C 5.734375,-5.453125 5.78125,-5.25 5.78125,-4.75 V 0 H 7.796875 V -5.21875 C 7.796875,-6.1875 7.53125,-6.875 7,-7.3125 6.5625,-7.6875 5.90625,-7.90625 5.265625,-7.90625 c -1,0 -1.71875,0.390625 -2.28125,1.25 V -10.5 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-3-4"
overflow="visible"
style="overflow:visible">
<path
id="path6715"
d="M 7.671875,-4.1875 H 5.0625 v -2.625 H 3.34375 v 2.625 h -2.625 v 1.703125 h 2.625 v 2.625 H 5.0625 v -2.625 h 2.609375 z m 0,0"
style="stroke:none" />
</symbol>
</g>
<g
id="g13143">
<symbol
id="glyph0-0-5"
overflow="visible"
style="overflow:visible">
<path
id="path12930"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph0-1-0"
overflow="visible"
style="overflow:visible">
<path
id="path12933"
d="M 8.1875,-3.78125 9.484375,0 H 11.28125 L 6.859375,-12.59375 H 4.78125 L 0.296875,0 H 2 L 3.328125,-3.78125 Z M 7.734375,-5.125 h -4 l 2.078125,-5.75 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-2-3"
overflow="visible"
style="overflow:visible">
<path
id="path12936"
d="M 9.546875,-12.59375 V -3.75 c 0,1.6875 -1.234375,2.734375 -3.25,2.734375 -0.9375,0 -1.703125,-0.234375 -2.3125,-0.65625 C 3.375,-2.15625 3.078125,-2.796875 3.078125,-3.75 v -8.84375 H 1.46875 V -3.75 c 0,2.5625 1.828125,4.140625 4.828125,4.140625 2.953125,0 4.84375,-1.625 4.84375,-4.140625 v -8.84375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-3-61"
overflow="visible"
style="overflow:visible">
<path
id="path12939"
d="M 3.296875,-1.796875 H 1.5 V 0 h 1.796875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-4-0"
overflow="visible"
style="overflow:visible">
<path
id="path12942"
d="m 4.75,-12.5 c -1.140625,0 -2.171875,0.53125 -2.8125,1.375 -0.796875,1.109375 -1.1875,2.765625 -1.1875,5.078125 0,4.21875 1.375,6.4375 4,6.4375 2.59375,0 4.015625,-2.21875 4.015625,-6.328125 C 8.765625,-8.359375 8.375,-9.984375 7.5625,-11.125 6.9375,-12 5.90625,-12.5 4.75,-12.5 Z m 0,1.359375 c 1.640625,0 2.453125,1.671875 2.453125,5.0625 0,3.5625 -0.796875,5.21875 -2.484375,5.21875 -1.609375,0 -2.421875,-1.734375 -2.421875,-5.171875 0,-3.4375 0.8125,-5.109375 2.453125,-5.109375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-5-63"
overflow="visible"
style="overflow:visible">
<path
id="path12945"
d="M 8.75,-1.5 H 2.296875 C 2.453125,-2.546875 3,-3.203125 4.515625,-4.109375 l 1.71875,-0.96875 c 1.71875,-0.953125 2.59375,-2.234375 2.59375,-3.765625 0,-1.046875 -0.40625,-2.015625 -1.140625,-2.6875 C 6.96875,-12.1875 6.0625,-12.5 4.90625,-12.5 c -1.546875,0 -2.71875,0.5625 -3.390625,1.625 -0.421875,0.65625 -0.609375,1.4375 -0.65625,2.703125 h 1.53125 C 2.4375,-9.015625 2.546875,-9.515625 2.75,-9.9375 c 0.390625,-0.765625 1.1875,-1.21875 2.109375,-1.21875 1.375,0 2.421875,1 2.421875,2.34375 0,1 -0.578125,1.859375 -1.671875,2.484375 l -1.578125,0.9375 c -2.5625,1.46875 -3.3125,2.640625 -3.4375,5.375 H 8.75 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph0-6-20"
overflow="visible"
style="overflow:visible">
<path
id="path12948"
d="M 4.46875,-8.90625 V 0 H 6 V -12.5 H 5 c -0.546875,1.921875 -0.890625,2.1875 -3.234375,2.5 v 1.09375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-0-6"
overflow="visible"
style="overflow:visible">
<path
id="path12951"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph1-1-15"
overflow="visible"
style="overflow:visible">
<path
id="path12954"
d="M 3.25,-3.75 H 5.953125 C 7.875,-3.75 9.125,-5.109375 9.125,-7.25 9.125,-9.34375 7.921875,-10.5 5.734375,-10.5 H 1.09375 V 0 H 3.25 Z m 0,-1.796875 v -3.15625 h 2.015625 c 1.15625,0 1.6875,0.5 1.6875,1.578125 0,1.078125 -0.53125,1.578125 -1.6875,1.578125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-2-5"
overflow="visible"
style="overflow:visible">
<path
id="path12957"
d="M 0.96875,-10.5 V 0 H 2.984375 V -4.671875 C 2.984375,-5.5625 3.625,-6.1875 4.53125,-6.1875 c 0.453125,0 0.78125,0.15625 1.015625,0.46875 C 5.734375,-5.453125 5.78125,-5.25 5.78125,-4.75 V 0 H 7.796875 V -5.21875 C 7.796875,-6.1875 7.53125,-6.875 7,-7.3125 6.5625,-7.6875 5.90625,-7.90625 5.265625,-7.90625 c -1,0 -1.71875,0.390625 -2.28125,1.25 V -10.5 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph1-3-47"
overflow="visible"
style="overflow:visible">
<path
id="path12960"
d="M 7.671875,-4.1875 H 5.0625 v -2.625 H 3.34375 v 2.625 h -2.625 v 1.703125 h 2.625 v 2.625 H 5.0625 v -2.625 h 2.609375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-0"
overflow="visible"
style="overflow:visible">
<path
id="path12963"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph2-1"
overflow="visible"
style="overflow:visible">
<path
id="path12966"
d="m 2.65625,-4.453125 h 3.296875 c 0.8125,0 1.46875,-0.25 2.03125,-0.75 0.625,-0.578125 0.90625,-1.25 0.90625,-2.21875 0,-1.96875 -1.171875,-3.078125 -3.25,-3.078125 H 1.3125 V 0 h 1.34375 z m 0,-1.1875 v -3.6875 h 2.796875 c 1.28125,0 2.03125,0.703125 2.03125,1.84375 0,1.15625 -0.75,1.84375 -2.03125,1.84375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-2"
overflow="visible"
style="overflow:visible">
<path
id="path12969"
d="M 1,-7.546875 V 0 H 2.203125 V -3.921875 C 2.21875,-5.734375 2.96875,-6.546875 4.625,-6.5 V -7.71875 C 4.421875,-7.75 4.3125,-7.765625 4.15625,-7.765625 c -0.765625,0 -1.359375,0.46875 -2.046875,1.578125 v -1.359375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-3"
overflow="visible"
style="overflow:visible">
<path
id="path12972"
d="m 3.921875,-7.765625 c -2.140625,0 -3.40625,1.515625 -3.40625,4.046875 0,2.546875 1.265625,4.046875 3.421875,4.046875 2.125,0 3.40625,-1.515625 3.40625,-3.984375 0,-2.625 -1.234375,-4.109375 -3.421875,-4.109375 z M 3.9375,-6.65625 c 1.34375,0 2.15625,1.109375 2.15625,2.984375 0,1.78125 -0.828125,2.890625 -2.15625,2.890625 -1.34375,0 -2.171875,-1.109375 -2.171875,-2.9375 0,-1.828125 0.828125,-2.9375 2.171875,-2.9375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-4"
overflow="visible"
style="overflow:visible">
<path
id="path12975"
d="m 4.203125,-3.90625 2.53125,-3.640625 H 5.390625 L 3.578125,-4.8125 1.75,-7.546875 H 0.390625 L 2.90625,-3.84375 0.25,0 H 1.609375 L 3.53125,-2.890625 5.421875,0 H 6.8125 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-5"
overflow="visible"
style="overflow:visible">
<path
id="path12978"
d="M 2.15625,-7.546875 H 0.96875 V 0 h 1.1875 z m 0,-2.953125 H 0.953125 v 1.515625 H 2.15625 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-6"
overflow="visible"
style="overflow:visible">
<path
id="path12981"
d="M 1.015625,-7.546875 V 0 H 2.21875 v -4.734375 c 0,-1.09375 0.796875,-1.984375 1.765625,-1.984375 0.90625,0 1.40625,0.546875 1.40625,1.515625 V 0 H 6.59375 v -4.734375 c 0,-1.09375 0.796875,-1.984375 1.78125,-1.984375 0.875,0 1.390625,0.5625 1.390625,1.515625 V 0 h 1.21875 v -5.65625 c 0,-1.359375 -0.78125,-2.109375 -2.203125,-2.109375 -1,0 -1.609375,0.296875 -2.3125,1.15625 -0.453125,-0.8125 -1.046875,-1.15625 -2.03125,-1.15625 -1.015625,0 -1.6875,0.375 -2.3125,1.28125 v -1.0625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-7"
overflow="visible"
style="overflow:visible">
<path
id="path12984"
d="M 3.65625,-7.546875 H 2.421875 V -9.625 H 1.21875 v 2.078125 H 0.203125 V -6.5625 H 1.21875 v 5.703125 c 0,0.765625 0.53125,1.1875 1.453125,1.1875 C 3,0.328125 3.25,0.296875 3.65625,0.234375 V -0.78125 c -0.171875,0.046875 -0.328125,0.0625 -0.578125,0.0625 -0.515625,0 -0.65625,-0.140625 -0.65625,-0.671875 V -6.5625 H 3.65625 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-8"
overflow="visible"
style="overflow:visible">
<path
id="path12987"
d="m 5.59375,-7.546875 -2.09375,5.875 -1.9375,-5.875 H 0.28125 L 2.84375,0.03125 2.375,1.21875 C 2.171875,1.75 1.921875,1.953125 1.40625,1.953125 1.203125,1.953125 1.03125,1.9375 0.78125,1.875 v 1.078125 c 0.234375,0.125 0.484375,0.1875 0.796875,0.1875 0.390625,0 0.8125,-0.125 1.125,-0.359375 C 3.078125,2.5 3.296875,2.1875 3.53125,1.578125 l 3.359375,-9.125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-9"
overflow="visible"
style="overflow:visible">
<path
id="path12990"
d="m 3.078125,-1.5 h -1.5 V 0 h 1.5 z m 0,-6.046875 h -1.5 v 1.5 h 1.5 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-10"
overflow="visible"
style="overflow:visible">
<path
id="path12993"
d=""
style="stroke:none" />
</symbol>
<symbol
id="glyph2-11"
overflow="visible"
style="overflow:visible">
<path
id="path12996"
d="m 0.765625,-2.375 c 0.25,1.703125 1.34375,2.703125 2.890625,2.703125 1.140625,0 2.15625,-0.546875 2.75,-1.484375 0.640625,-1.015625 0.921875,-2.28125 0.921875,-4.171875 0,-1.765625 -0.25,-2.875 -0.859375,-3.796875 -0.5625,-0.84375 -1.453125,-1.296875 -2.578125,-1.296875 -1.953125,0 -3.34375,1.46875 -3.34375,3.484375 0,1.90625 1.296875,3.265625 3.140625,3.265625 0.96875,0 1.6875,-0.34375 2.328125,-1.140625 C 6,-2.21875 5.203125,-0.796875 3.75,-0.796875 2.859375,-0.796875 2.234375,-1.375 2.03125,-2.375 Z M 3.875,-9.3125 c 1.1875,0 2.078125,1 2.078125,2.34375 0,1.28125 -0.875,2.171875 -2.125,2.171875 -1.21875,0 -1.984375,-0.859375 -1.984375,-2.25 0,-1.3125 0.84375,-2.265625 2.03125,-2.265625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-12"
overflow="visible"
style="overflow:visible">
<path
id="path12999"
d="m 5.640625,-5.484375 c 1.0625,-0.65625 1.390625,-1.171875 1.390625,-2.15625 0,-1.640625 -1.25,-2.78125 -3.0625,-2.78125 -1.8125,0 -3.078125,1.140625 -3.078125,2.765625 0,1 0.328125,1.5 1.390625,2.171875 -1.171875,0.59375 -1.75,1.4375 -1.75,2.59375 0,1.890625 1.40625,3.21875 3.4375,3.21875 2.015625,0 3.421875,-1.328125 3.421875,-3.21875 0,-1.15625 -0.578125,-2 -1.75,-2.59375 z m -1.671875,-3.8125 c 1.078125,0 1.765625,0.65625 1.765625,1.6875 0,0.984375 -0.703125,1.625 -1.765625,1.625 -1.09375,0 -1.78125,-0.640625 -1.78125,-1.65625 0,-1 0.6875,-1.65625 1.78125,-1.65625 z m 0,4.390625 c 1.265625,0 2.125,0.828125 2.125,2.046875 0,1.25 -0.84375,2.0625 -2.15625,2.0625 -1.25,0 -2.109375,-0.84375 -2.109375,-2.0625 0,-1.234375 0.84375,-2.046875 2.140625,-2.046875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-13"
overflow="visible"
style="overflow:visible">
<path
id="path13002"
d="m 2.859375,-9.875 c -1.34375,0 -2.4375,1.109375 -2.4375,2.46875 0,1.359375 1.09375,2.46875 2.453125,2.46875 1.34375,0 2.453125,-1.109375 2.453125,-2.4375 0,-1.390625 -1.078125,-2.5 -2.46875,-2.5 z m 0,1.015625 c 0.828125,0 1.484375,0.640625 1.484375,1.46875 0,0.796875 -0.671875,1.4375 -1.46875,1.4375 -0.796875,0 -1.46875,-0.640625 -1.46875,-1.453125 0,-0.8125 0.65625,-1.453125 1.453125,-1.453125 z m 5.90625,-1.359375 -5.6875,10.5 H 4.03125 l 5.6875,-10.5 z m 1.140625,5.578125 c -1.34375,0 -2.4375,1.09375 -2.4375,2.453125 0,1.359375 1.09375,2.46875 2.453125,2.46875 1.34375,0 2.453125,-1.109375 2.453125,-2.4375 0,-1.390625 -1.078125,-2.484375 -2.46875,-2.484375 z m 0,1.015625 c 0.828125,0 1.46875,0.640625 1.46875,1.46875 0,0.765625 -0.65625,1.421875 -1.453125,1.421875 -0.8125,0 -1.46875,-0.65625 -1.46875,-1.453125 0,-0.796875 0.65625,-1.4375 1.453125,-1.4375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-14"
overflow="visible"
style="overflow:visible">
<path
id="path13005"
d="m 2.640625,-4.78125 h 5.71875 v -1.1875 h -5.71875 v -3.359375 h 5.9375 V -10.5 H 1.296875 V 0 h 7.53125 v -1.1875 h -6.1875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-15"
overflow="visible"
style="overflow:visible">
<path
id="path13008"
d="m 6.78125,-5.015625 c -0.046875,-0.734375 -0.21875,-1.203125 -0.5,-1.625 -0.515625,-0.703125 -1.421875,-1.125 -2.484375,-1.125 -2.046875,0 -3.34375,1.609375 -3.34375,4.125 0,2.4375 1.296875,3.96875 3.328125,3.96875 1.8125,0 2.953125,-1.078125 3.09375,-2.921875 H 5.65625 c -0.203125,1.203125 -0.8125,1.8125 -1.84375,1.8125 -1.3125,0 -2.109375,-1.078125 -2.109375,-2.859375 0,-1.890625 0.78125,-3.015625 2.078125,-3.015625 1.015625,0 1.65625,0.59375 1.796875,1.640625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-16"
overflow="visible"
style="overflow:visible">
<path
id="path13011"
d="M 2.1875,-10.5 H 0.984375 V 0 H 2.1875 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-17"
overflow="visible"
style="overflow:visible">
<path
id="path13014"
d="M 6.9375,0 V -7.546875 H 5.75 v 4.28125 c 0,1.53125 -0.8125,2.546875 -2.0625,2.546875 -0.953125,0 -1.5625,-0.578125 -1.5625,-1.484375 v -5.34375 H 0.9375 v 5.8125 c 0,1.265625 0.9375,2.0625 2.40625,2.0625 1.109375,0 1.8125,-0.390625 2.515625,-1.375 V 0 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-18"
overflow="visible"
style="overflow:visible">
<path
id="path13017"
d="m 6.3125,-5.453125 c -0.015625,-1.46875 -1,-2.3125 -2.734375,-2.3125 -1.765625,0 -2.90625,0.90625 -2.90625,2.3125 0,1.171875 0.609375,1.734375 2.390625,2.171875 l 1.125,0.265625 C 5.03125,-2.8125 5.359375,-2.5 5.359375,-1.96875 c 0,0.71875 -0.703125,1.1875 -1.765625,1.1875 -0.640625,0 -1.1875,-0.1875 -1.484375,-0.5 C 1.921875,-1.5 1.828125,-1.71875 1.75,-2.25 H 0.484375 C 0.546875,-0.5 1.53125,0.328125 3.5,0.328125 c 1.90625,0 3.109375,-0.9375 3.109375,-2.390625 0,-1.125 -0.625,-1.734375 -2.125,-2.09375 L 3.328125,-4.4375 C 2.34375,-4.671875 1.9375,-4.984375 1.9375,-5.515625 c 0,-0.703125 0.609375,-1.140625 1.59375,-1.140625 0.96875,0 1.484375,0.421875 1.515625,1.203125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-19"
overflow="visible"
style="overflow:visible">
<path
id="path13020"
d="M 4.109375,0 7,-7.546875 H 5.640625 l -2.125,6.125 L 1.5,-7.546875 H 0.140625 L 2.796875,0 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-20"
overflow="visible"
style="overflow:visible">
<path
id="path13023"
d="M 3.734375,-7.421875 V 0 H 5 V -10.421875 H 4.15625 C 3.71875,-8.8125 3.421875,-8.59375 1.46875,-8.34375 v 0.921875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-21"
overflow="visible"
style="overflow:visible">
<path
id="path13026"
d="m 3.96875,-10.421875 c -0.953125,0 -1.828125,0.4375 -2.359375,1.140625 -0.65625,0.921875 -0.984375,2.3125 -0.984375,4.234375 0,3.515625 1.140625,5.375 3.34375,5.375 2.15625,0 3.328125,-1.859375 3.328125,-5.28125 0,-2.015625 -0.3125,-3.375 -0.984375,-4.328125 C 5.78125,-10 4.921875,-10.421875 3.96875,-10.421875 Z m 0,1.125 c 1.359375,0 2.03125,1.40625 2.03125,4.21875 0,2.96875 -0.65625,4.359375 -2.0625,4.359375 -1.34375,0 -2.015625,-1.4375 -2.015625,-4.3125 0,-2.859375 0.671875,-4.265625 2.046875,-4.265625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-22"
overflow="visible"
style="overflow:visible">
<path
id="path13029"
d="M 9.53125,-7.25 C 9.125,-9.546875 7.796875,-10.671875 5.484375,-10.671875 c -1.40625,0 -2.546875,0.4375 -3.328125,1.3125 -0.953125,1.03125 -1.46875,2.53125 -1.46875,4.234375 0,1.71875 0.53125,3.203125 1.515625,4.234375 0.828125,0.828125 1.859375,1.21875 3.234375,1.21875 2.5625,0 4,-1.375 4.3125,-4.15625 H 8.375 C 8.25,-3.109375 8.109375,-2.625 7.890625,-2.203125 7.46875,-1.34375 6.5625,-0.84375 5.453125,-0.84375 3.359375,-0.84375 2.03125,-2.515625 2.03125,-5.140625 2.03125,-7.84375 3.28125,-9.5 5.328125,-9.5 6.1875,-9.5 6.96875,-9.25 7.40625,-8.828125 7.796875,-8.46875 8.015625,-8.03125 8.171875,-7.25 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-23"
overflow="visible"
style="overflow:visible">
<path
id="path13032"
d="m 7.703125,-0.703125 c -0.125,0.03125 -0.1875,0.03125 -0.25,0.03125 -0.421875,0 -0.65625,-0.21875 -0.65625,-0.59375 v -4.4375 c 0,-1.34375 -0.984375,-2.0625 -2.828125,-2.0625 -1.109375,0 -2,0.3125 -2.515625,0.875 C 1.109375,-6.5 0.96875,-6.0625 0.9375,-5.3125 h 1.203125 c 0.109375,-0.921875 0.65625,-1.34375 1.78125,-1.34375 1.09375,0 1.6875,0.40625 1.6875,1.125 v 0.3125 C 5.59375,-4.703125 5.328125,-4.515625 4.34375,-4.375 2.65625,-4.15625 2.390625,-4.109375 1.9375,-3.921875 1.046875,-3.546875 0.609375,-2.875 0.609375,-1.90625 c 0,1.375 0.953125,2.234375 2.46875,2.234375 0.953125,0 1.71875,-0.328125 2.5625,-1.109375 0.09375,0.78125 0.46875,1.109375 1.25,1.109375 0.25,0 0.40625,-0.03125 0.8125,-0.125 z M 5.609375,-2.375 c 0,0.40625 -0.125,0.640625 -0.484375,0.984375 -0.484375,0.4375 -1.078125,0.671875 -1.78125,0.671875 -0.9375,0 -1.484375,-0.453125 -1.484375,-1.21875 0,-0.78125 0.515625,-1.1875 1.8125,-1.375 1.28125,-0.171875 1.53125,-0.234375 1.9375,-0.421875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-24"
overflow="visible"
style="overflow:visible">
<path
id="path13035"
d="m 7.390625,-3.375 c 0,-1.15625 -0.09375,-1.84375 -0.296875,-2.40625 -0.5,-1.234375 -1.640625,-1.984375 -3.0625,-1.984375 -2.09375,0 -3.453125,1.59375 -3.453125,4.09375 0,2.484375 1.296875,4 3.421875,4 1.734375,0 2.921875,-0.96875 3.234375,-2.625 h -1.21875 c -0.328125,1 -1,1.515625 -1.96875,1.515625 -0.765625,0 -1.40625,-0.34375 -1.8125,-0.96875 C 1.9375,-2.1875 1.84375,-2.625 1.828125,-3.375 Z m -5.53125,-0.96875 c 0.09375,-1.40625 0.953125,-2.3125 2.15625,-2.3125 1.234375,0 2.078125,0.953125 2.078125,2.3125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-25"
overflow="visible"
style="overflow:visible">
<path
id="path13038"
d="m 5.8125,-7.546875 v 1.09375 c -0.59375,-0.90625 -1.265625,-1.3125 -2.21875,-1.3125 -1.828125,0 -3.09375,1.703125 -3.09375,4.125 0,1.265625 0.3125,2.1875 0.953125,2.953125 0.5625,0.65625 1.28125,1.015625 2.0625,1.015625 0.90625,0 1.5625,-0.40625 2.1875,-1.34375 v 0.375 c 0,2.03125 -0.5625,2.765625 -2.0625,2.765625 C 2.625,2.125 2.09375,1.734375 1.96875,0.859375 H 0.75 c 0.109375,1.40625 1.21875,2.28125 2.859375,2.28125 1.109375,0 2.03125,-0.359375 2.53125,-0.96875 0.578125,-0.703125 0.78125,-1.640625 0.78125,-3.40625 v -6.3125 z M 3.71875,-6.65625 c 1.265625,0 1.984375,1.0625 1.984375,2.984375 0,1.828125 -0.734375,2.890625 -1.984375,2.890625 -1.234375,0 -1.96875,-1.078125 -1.96875,-2.9375 0,-1.84375 0.734375,-2.9375 1.96875,-2.9375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-26"
overflow="visible"
style="overflow:visible">
<path
id="path13041"
d="M 1.140625,0 H 5.875 c 1,0 1.734375,-0.28125 2.296875,-0.875 C 8.6875,-1.421875 8.96875,-2.171875 8.96875,-3 8.96875,-4.265625 8.40625,-5.03125 7.0625,-5.546875 8.03125,-6 8.515625,-6.75 8.515625,-7.84375 c 0,-0.765625 -0.296875,-1.4375 -0.84375,-1.921875 C 7.109375,-10.265625 6.40625,-10.5 5.40625,-10.5 H 1.140625 Z m 1.34375,-5.984375 v -3.34375 h 2.59375 c 0.734375,0 1.15625,0.109375 1.515625,0.375 0.375,0.296875 0.578125,0.734375 0.578125,1.296875 0,0.578125 -0.203125,1.015625 -0.578125,1.296875 -0.359375,0.28125 -0.78125,0.375 -1.515625,0.375 z m 0,4.796875 V -4.796875 H 5.75 c 1.171875,0 1.890625,0.671875 1.890625,1.8125 0,1.125 -0.71875,1.796875 -1.890625,1.796875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-27"
overflow="visible"
style="overflow:visible">
<path
id="path13044"
d="M 2.5,-10.5 H 1.15625 V 0 H 7.671875 V -1.1875 H 2.5 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-28"
overflow="visible"
style="overflow:visible">
<path
id="path13047"
d="m 7.296875,-1.25 h -5.375 C 2.046875,-2.125 2.5,-2.671875 3.765625,-3.421875 l 1.4375,-0.8125 C 6.625,-5.03125 7.359375,-6.09375 7.359375,-7.375 c 0,-0.859375 -0.34375,-1.671875 -0.953125,-2.234375 -0.59375,-0.546875 -1.34375,-0.8125 -2.3125,-0.8125 -1.296875,0 -2.265625,0.46875 -2.828125,1.359375 C 0.90625,-8.515625 0.75,-7.859375 0.71875,-6.8125 H 1.984375 C 2.03125,-7.515625 2.125,-7.9375 2.296875,-8.28125 2.625,-8.921875 3.28125,-9.3125 4.046875,-9.3125 c 1.15625,0 2.015625,0.84375 2.015625,1.96875 0,0.828125 -0.46875,1.546875 -1.375,2.078125 L 3.359375,-4.5 c -2.140625,1.234375 -2.75,2.203125 -2.875,4.484375 h 6.8125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-29"
overflow="visible"
style="overflow:visible">
<path
id="path13050"
d="m 3.296875,-10.5 -3.40625,10.78125 h 0.78125 L 4.09375,-10.5 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-30"
overflow="visible"
style="overflow:visible">
<path
id="path13053"
d="m 6.734375,0 2.96875,-8.796875 V 0 H 10.96875 V -10.5 H 9.109375 L 6.046875,-1.359375 2.9375,-10.5 H 1.078125 V 0 H 2.34375 V -8.796875 L 5.328125,0 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-31"
overflow="visible"
style="overflow:visible">
<path
id="path13056"
d="m 5.578125,-4.125 3.9375,-6.375 h -1.59375 l -3,5.109375 L 1.84375,-10.5 H 0.1875 l 4.046875,6.375 V 0 h 1.34375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-32"
overflow="visible"
style="overflow:visible">
<path
id="path13059"
d="m 2.671875,-4.53125 h 3.46875 c 1.1875,0 1.71875,0.578125 1.71875,1.875 l -0.015625,0.9375 c 0,0.65625 0.125,1.28125 0.3125,1.71875 h 1.625 v -0.328125 c -0.5,-0.34375 -0.609375,-0.71875 -0.640625,-2.125 0,-1.71875 -0.28125,-2.25 -1.421875,-2.734375 C 8.90625,-5.78125 9.375,-6.484375 9.375,-7.6875 9.375,-9.515625 8.25,-10.5 6.1875,-10.5 H 1.34375 V 0 h 1.328125 z m 0,-1.171875 v -3.625 h 3.25 c 0.75,0 1.1875,0.125 1.515625,0.40625 0.359375,0.3125 0.546875,0.78125 0.546875,1.40625 0,1.25 -0.640625,1.8125 -2.0625,1.8125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-33"
overflow="visible"
style="overflow:visible">
<path
id="path13062"
d="M 2.640625,-4.78125 H 7.65625 v -1.1875 H 2.640625 V -9.328125 H 8.34375 V -10.5 H 1.296875 V 0 h 1.34375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-34"
overflow="visible"
style="overflow:visible">
<path
id="path13065"
d="m 1.28125,0 h 4.046875 c 2.65625,0 4.28125,-1.984375 4.28125,-5.265625 C 9.609375,-8.515625 8,-10.5 5.328125,-10.5 H 1.28125 Z M 2.625,-1.1875 v -8.140625 h 2.46875 c 2.078125,0 3.171875,1.40625 3.171875,4.078125 0,2.671875 -1.09375,4.0625 -3.171875,4.0625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-35"
overflow="visible"
style="overflow:visible">
<path
id="path13068"
d="m 7.953125,-10.5 v 7.375 c 0,1.40625 -1.03125,2.28125 -2.703125,2.28125 -0.78125,0 -1.421875,-0.1875 -1.921875,-0.546875 C 2.8125,-1.796875 2.5625,-2.328125 2.5625,-3.125 V -10.5 H 1.21875 v 7.375 C 1.21875,-1 2.75,0.328125 5.25,0.328125 c 2.453125,0 4.046875,-1.34375 4.046875,-3.453125 V -10.5 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-36"
overflow="visible"
style="overflow:visible">
<path
id="path13071"
d="M 5.640625,-5.390625 9.171875,-10.5 H 7.578125 L 4.875,-6.375 2.171875,-10.5 h -1.625 L 4.03125,-5.390625 0.3125,0 h 1.625 L 4.828125,-4.375 7.6875,0 h 1.65625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-37"
overflow="visible"
style="overflow:visible">
<path
id="path13074"
d="M 4.703125,-2.515625 V 0 h 1.28125 v -2.515625 h 1.5 V -3.65625 h -1.5 v -6.765625 h -0.9375 l -4.640625,6.5625 v 1.34375 z m 0,-1.140625 h -3.1875 L 4.703125,-8.25 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-38"
overflow="visible"
style="overflow:visible">
<path
id="path13077"
d="M 5.09375,-9.328125 H 8.546875 V -10.5 h -8.25 v 1.171875 h 3.46875 V 0 H 5.09375 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-39"
overflow="visible"
style="overflow:visible">
<path
id="path13080"
d="m 5.640625,0 3.65625,-10.5 h -1.4375 L 4.953125,-1.609375 1.875,-10.5 H 0.4375 L 4.203125,0 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-40"
overflow="visible"
style="overflow:visible">
<path
id="path13083"
d="m 7.171875,-7.703125 c -0.25,-1.703125 -1.34375,-2.71875 -2.890625,-2.71875 -1.125,0 -2.140625,0.546875 -2.734375,1.484375 C 0.890625,-7.90625 0.625,-6.640625 0.625,-4.75 c 0,1.75 0.234375,2.859375 0.859375,3.78125 0.546875,0.859375 1.4375,1.296875 2.5625,1.296875 1.953125,0 3.34375,-1.453125 3.34375,-3.484375 0,-1.921875 -1.296875,-3.265625 -3.125,-3.265625 -1.015625,0 -1.796875,0.375 -2.34375,1.140625 0.015625,-2.578125 0.8125,-4.015625 2.265625,-4.015625 0.890625,0 1.515625,0.578125 1.71875,1.59375 z m -3.0625,2.40625 c 1.21875,0 1.984375,0.859375 1.984375,2.25 0,1.296875 -0.859375,2.25 -2.03125,2.25 -1.1875,0 -2.078125,-0.984375 -2.078125,-2.3125 0,-1.296875 0.875,-2.1875 2.125,-2.1875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-41"
overflow="visible"
style="overflow:visible">
<path
id="path13086"
d="m 4.09375,-4.5 h -3.4375 v 1.046875 h 3.4375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-42"
overflow="visible"
style="overflow:visible">
<path
id="path13089"
d="M 9.3125,-10.5 H 8.03125 v 8.578125 L 2.546875,-10.5 H 1.09375 V 0 H 2.359375 V -8.515625 L 7.796875,0 H 9.3125 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-43"
overflow="visible"
style="overflow:visible">
<path
id="path13092"
d="M 7.9375,-4.78125 V 0 H 9.28125 V -10.5 H 7.9375 v 4.53125 H 2.53125 V -10.5 H 1.203125 V 0 H 2.53125 v -4.78125 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-44"
overflow="visible"
style="overflow:visible">
<path
id="path13095"
d="m 0.78125,3.140625 h 1.203125 v -3.9375 c 0.640625,0.78125 1.34375,1.125 2.328125,1.125 1.953125,0 3.21875,-1.5625 3.21875,-3.96875 0,-2.546875 -1.234375,-4.125 -3.234375,-4.125 -1.03125,0 -1.84375,0.46875 -2.40625,1.359375 V -7.546875 H 0.78125 Z m 3.3125,-9.78125 c 1.328125,0 2.1875,1.171875 2.1875,2.96875 0,1.71875 -0.875,2.875 -2.1875,2.875 -1.28125,0 -2.109375,-1.140625 -2.109375,-2.921875 0,-1.765625 0.828125,-2.921875 2.109375,-2.921875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-45"
overflow="visible"
style="overflow:visible">
<path
id="path13098"
d="M 7.125,-10.5 H 5.9375 v 3.90625 C 5.4375,-7.359375 4.625,-7.765625 3.609375,-7.765625 1.65625,-7.765625 0.375,-6.1875 0.375,-3.78125 c 0,2.546875 1.234375,4.109375 3.28125,4.109375 C 4.703125,0.328125 5.421875,-0.0625 6.0625,-1 V 0 H 7.125 Z m -3.3125,3.859375 c 1.296875,0 2.125,1.140625 2.125,2.953125 0,1.75 -0.84375,2.890625 -2.109375,2.890625 C 2.5,-0.796875 1.625,-1.953125 1.625,-3.71875 c 0,-1.75 0.875,-2.921875 2.1875,-2.921875 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-46"
overflow="visible"
style="overflow:visible">
<path
id="path13101"
d="M 6.828125,-3.15625 7.90625,0 h 1.5 L 5.71875,-10.5 H 3.984375 L 0.25,0 H 1.671875 L 2.78125,-3.15625 Z m -0.375,-1.125 H 3.109375 L 4.84375,-9.0625 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-47"
overflow="visible"
style="overflow:visible">
<path
id="path13104"
d="M 2.796875,-10.5 H 1.4375 V 0 h 1.359375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-48"
overflow="visible"
style="overflow:visible">
<path
id="path13107"
d="M 2.484375,-3.671875 4.1875,-5.390625 7.890625,0 h 1.59375 L 5.15625,-6.21875 9.4375,-10.5 H 7.703125 l -5.21875,5.3125 V -10.5 H 1.140625 V 0 h 1.34375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-49"
overflow="visible"
style="overflow:visible">
<path
id="path13110"
d="M 8.375,-10.5 H 0.8125 v 1.171875 H 6.71875 L 0.40625,-1.1875 V 0 h 8 V -1.1875 H 2.09375 L 8.375,-9.296875 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-50"
overflow="visible"
style="overflow:visible">
<path
id="path13113"
d="m 6.859375,-10.21875 h -5.28125 l -0.75,5.5625 h 1.15625 C 2.578125,-5.359375 3.0625,-5.609375 3.875,-5.609375 c 1.375,0 2.21875,0.9375 2.21875,2.453125 0,1.46875 -0.84375,2.359375 -2.234375,2.359375 -1.109375,0 -1.78125,-0.5625 -2.09375,-1.703125 H 0.5 c 0.171875,0.828125 0.328125,1.234375 0.625,1.609375 0.578125,0.78125 1.609375,1.21875 2.765625,1.21875 2.0625,0 3.5,-1.5 3.5,-3.65625 0,-2.015625 -1.34375,-3.40625 -3.296875,-3.40625 -0.71875,0 -1.296875,0.1875 -1.890625,0.625 l 0.40625,-2.84375 h 4.25 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-51"
overflow="visible"
style="overflow:visible">
<path
id="path13116"
d="M 2.75,-1.5 H 1.25 V 0 h 1.5 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-52"
overflow="visible"
style="overflow:visible">
<path
id="path13119"
d="M 1.015625,-10.5 V 0 h 1.1875 v -4.15625 c 0,-1.546875 0.8125,-2.5625 2.046875,-2.5625 0.40625,0 0.78125,0.125 1.0625,0.34375 0.34375,0.25 0.5,0.609375 0.5,1.140625 V 0 H 7 v -5.703125 c 0,-1.265625 -0.90625,-2.0625 -2.375,-2.0625 -1.0625,0 -1.71875,0.328125 -2.421875,1.25 V -10.5 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-53"
overflow="visible"
style="overflow:visible">
<path
id="path13122"
d="M 7.6875,-3.84375 H 4.703125 v -2.984375 h -1 V -3.84375 H 0.71875 v 1 h 2.984375 v 2.984375 h 1 V -2.84375 H 7.6875 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-54"
overflow="visible"
style="overflow:visible">
<path
id="path13125"
d="M 3.1875,-4.796875 H 3.875 c 1.390625,0 2.125,0.640625 2.125,1.90625 0,1.3125 -0.796875,2.09375 -2.109375,2.09375 C 2.5,-0.796875 1.8125,-1.5 1.734375,-3.03125 H 0.46875 c 0.046875,0.84375 0.1875,1.390625 0.4375,1.84375 0.53125,1.015625 1.53125,1.515625 2.921875,1.515625 2.109375,0 3.46875,-1.265625 3.46875,-3.234375 0,-1.328125 -0.515625,-2.046875 -1.734375,-2.484375 C 6.515625,-5.78125 6.984375,-6.5 6.984375,-7.546875 c 0,-1.78125 -1.171875,-2.875 -3.109375,-2.875 -2.0625,0 -3.15625,1.15625 -3.203125,3.359375 H 1.9375 c 0.015625,-0.625 0.078125,-0.984375 0.234375,-1.3125 0.296875,-0.578125 0.921875,-0.9375 1.71875,-0.9375 1.125,0 1.796875,0.6875 1.796875,1.8125 0,0.734375 -0.25,1.171875 -0.8125,1.421875 C 4.53125,-5.9375 4.0625,-5.875 3.1875,-5.859375 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-55"
overflow="visible"
style="overflow:visible">
<path
id="path13128"
d="M 7.484375,-10.21875 H 0.65625 v 1.265625 H 6.1875 C 3.75,-5.484375 2.75,-3.359375 1.984375,0 H 3.34375 c 0.5625,-3.265625 1.84375,-6.078125 4.140625,-9.140625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-56"
overflow="visible"
style="overflow:visible">
<path
id="path13131"
d="M 10.21875,-5.546875 H 5.828125 v 1.1875 H 9.03125 v 0.28125 c 0,1.875 -1.375,3.234375 -3.296875,3.234375 -1.0625,0 -2.03125,-0.390625 -2.65625,-1.078125 -0.6875,-0.75 -1.109375,-2 -1.109375,-3.296875 0,-2.578125 1.46875,-4.28125 3.6875,-4.28125 1.609375,0 2.75,0.828125 3.046875,2.1875 H 10.0625 c -0.359375,-2.140625 -1.984375,-3.359375 -4.390625,-3.359375 -1.28125,0 -2.3125,0.328125 -3.140625,1 -1.21875,1.015625 -1.890625,2.640625 -1.890625,4.53125 0,3.21875 1.96875,5.46875 4.8125,5.46875 C 6.875,0.328125 8,-0.203125 9.03125,-1.34375 L 9.359375,0.0625 h 0.859375 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-57"
overflow="visible"
style="overflow:visible">
<path
id="path13134"
d="M 1.015625,-7.546875 V 0 H 2.21875 v -4.15625 c 0,-1.546875 0.8125,-2.5625 2.046875,-2.5625 0.953125,0 1.546875,0.578125 1.546875,1.484375 V 0 h 1.203125 v -5.703125 c 0,-1.25 -0.9375,-2.0625 -2.390625,-2.0625 -1.125,0 -1.84375,0.4375 -2.5,1.484375 v -1.265625 z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-58"
overflow="visible"
style="overflow:visible">
<path
id="path13137"
d="m 5.609375,-10.671875 c -3.015625,0 -5.0625,2.21875 -5.0625,5.5 0,3.296875 2.03125,5.5 5.078125,5.5 1.28125,0 2.40625,-0.390625 3.25,-1.109375 1.140625,-0.96875 1.8125,-2.59375 1.8125,-4.296875 0,-3.390625 -2,-5.59375 -5.078125,-5.59375 z m 0,1.171875 c 2.265625,0 3.734375,1.71875 3.734375,4.390625 0,2.53125 -1.5,4.265625 -3.71875,4.265625 -2.25,0 -3.734375,-1.734375 -3.734375,-4.328125 C 1.890625,-7.765625 3.375,-9.5 5.609375,-9.5 Z m 0,0"
style="stroke:none" />
</symbol>
<symbol
id="glyph2-59"
overflow="visible"
style="overflow:visible">
<path
id="path13140"
d="m 8.59375,-7.421875 c 0,-0.71875 -0.046875,-0.921875 -0.28125,-1.40625 -0.578125,-1.21875 -1.796875,-1.84375 -3.578125,-1.84375 -2.296875,0 -3.71875,1.171875 -3.71875,3.078125 0,1.28125 0.671875,2.09375 2.046875,2.453125 l 2.609375,0.6875 c 1.34375,0.34375 1.9375,0.875 1.9375,1.703125 0,0.5625 -0.3125,1.140625 -0.75,1.453125 C 6.4375,-1 5.78125,-0.84375 4.921875,-0.84375 3.78125,-0.84375 3.015625,-1.125 2.5,-1.734375 2.125,-2.1875 1.9375,-2.6875 1.953125,-3.34375 H 0.6875 c 0.015625,0.96875 0.203125,1.59375 0.625,2.171875 0.71875,1 1.921875,1.5 3.53125,1.5 1.25,0 2.265625,-0.28125 2.953125,-0.796875 0.703125,-0.5625 1.15625,-1.5 1.15625,-2.40625 0,-1.296875 -0.8125,-2.25 -2.234375,-2.640625 L 4.078125,-6.21875 C 2.8125,-6.5625 2.34375,-6.96875 2.34375,-7.78125 c 0,-1.0625 0.9375,-1.765625 2.359375,-1.765625 1.671875,0 2.59375,0.75 2.609375,2.125 z m 0,0"
style="stroke:none" />
</symbol>
</g>
</defs>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0,-254.66665)"
id="layer1">
<rect
y="254.66664"
x="0"
height="42.333332"
width="171.97917"
id="rect29"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.20445883;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g>
<g
transform="translate(0,-89.958333)"
id="layer2">
<flowRoot
transform="translate(160.2619,-225.08482)"
xml:space="preserve"
id="flowRoot1183"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.33333302px;line-height:1;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"><flowRegion
id="flowRegion1185"><rect
id="rect1187"
width="1.2069778"
height="15.690712"
x="75.436111"
y="556.19049" /></flowRegion><flowPara
id="flowPara1189" /></flowRoot> <text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="182.5074"
y="-33.97517"
id="text329"><tspan
id="tspan327"
x="182.5074"
y="-33.97517"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332">Unadjusted</tspan><tspan
x="182.5074"
y="-30.094614"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332"
id="tspan331">RNA data</tspan></text>
<text
id="text252"
y="-33.97517"
x="226.26772"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332"
y="-33.97517"
x="226.26772"
id="tspan248">Adjusted</tspan><tspan
id="tspan250"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332"
y="-30.094614"
x="226.26772">RNA data</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.23333311px;line-height:1.25;font-family:'Nimbus Sans';-inkscape-font-specification:'Nimbus Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="218.26079"
y="-31.358486"
id="text3351"><tspan
id="tspan3349"
x="218.26079"
y="-27.743219"
style="stroke-width:0.26458332" /></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.23333311px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="311.44803"
y="-128.11108"
id="text178"><tspan
id="tspan176"
x="311.44803"
y="-124.36558"
style="stroke-width:0.26458332" /></text>
<flowRoot
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.33333302px;line-height:1;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
id="flowRoot1183-1"
xml:space="preserve"
transform="translate(382.39372,-235.50136)"><flowRegion
id="flowRegion1185-9"><rect
y="556.19049"
x="75.436111"
height="15.690712"
width="1.2069778"
id="rect1187-4" /></flowRegion><flowPara
id="flowPara1189-7" /></flowRoot> <text
id="text329-8"
y="-44.39172"
x="404.63922"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332"
y="-44.39172"
x="404.63922"
id="tspan327-4">Unadjusted</tspan><tspan
id="tspan331-5"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332"
y="-40.511166"
x="404.63922">RNA data</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.52777767px;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="448.39954"
y="-44.39172"
id="text252-0"><tspan
id="tspan248-3"
x="448.39954"
y="-44.39172"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332">Adjusted</tspan><tspan
x="448.39954"
y="-40.511166"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:1.10000002;font-family:'Nimbus Sans L';-inkscape-font-specification:'Nimbus Sans L Bold';text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.26458332"
id="tspan250-6">RNA data</tspan></text>
<text
id="text3351-6"
y="-41.775036"
x="440.39261"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.23333311px;line-height:1.25;font-family:'Nimbus Sans';-inkscape-font-specification:'Nimbus Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
xml:space="preserve"><tspan
style="stroke-width:0.26458332"
y="-38.159771"
x="440.39261"
id="tspan3349-3" /></text>
<text
id="text2854"
y="-128.22043"
x="339.50894"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.23333311px;line-height:1.25;font-family:'Nimbus Sans';-inkscape-font-specification:'Nimbus Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
xml:space="preserve"><tspan
style="stroke-width:0.26458332"
y="-124.60516"
x="339.50894"
id="tspan2852" /></text>
<g
transform="matrix(0.3159036,0,0,0.3159036,-64.910107,90.359885)"
id="g887">
<path
id="path94"
d="m 524.84054,71.575175 c -0.43311,-5.932451 -21.36876,-14.585386 -47.22528,-2.851408 -2.68203,1.217136 -5.76235,1.39478 -8.66362,2.533866 1.41618,0.912559 -0.76378,3.052972 -0.23751,2.551564 1.37653,-1.311515 6.56248,-2.884787 8.58222,-1.51651 28.71353,19.452075 47.97032,5.348276 47.54419,-0.717512 z"
style="fill:#e7cbca;fill-opacity:1;stroke:none;stroke-width:0.15337786px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
style="fill:#6c5d53;fill-opacity:0.78431373;stroke:none;stroke-width:1.19728899;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 430.93491,1.3528154 c 4.25013,-1.55399239 32.6067,11.5076446 30.56357,53.2798726 -0.3079,6.295094 9.36194,15.938708 10.42081,17.726999 0.40027,0.676074 -2.45951,0.425612 -2.72391,1.173304 -2.6782,-1.640157 -9.00632,-14.911175 -11.4828,-16.181673 C 423.3284,39.71135 426.9999,2.7630497 430.93492,1.3528088 Z"
id="path92" />
<path
id="path80"
style="fill:#918ebe;fill-opacity:1;stroke:#ffffff;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 485.10948,106.28175 c 0,0 -14.15967,-33.306723 -12.68766,-35.945381 1.472,-2.638657 19.45308,-16.752464 19.45308,-16.752464 l -7.64163,-6.960826 c 0,0 -12.46658,19.099595 -15.57167,21.947594 -3.1051,2.847999 -46.35299,10.415468 -46.35299,10.415468 l 9.7669,21.095389 c 0,0 34.39874,-27.143412 35.62666,-24.971947 1.22792,2.171464 5.28298,33.304807 5.28298,33.304807 z" />
<path
style="fill:#ebadff;fill-opacity:1;stroke:#ffffff;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 493.9447,126.81357 c -7.11424,4.6343 -11.88321,4.84438 -20.95137,2.13822 -19.81116,-9.80533 -13.61314,-35.495623 -0.21756,-39.72234 13.39558,-4.226719 24.398,1.620676 28.35893,10.93884 3.96094,9.31817 -0.0757,22.01099 -7.19,26.64528 z"
id="path36" />
<path
style="fill:#890a71;fill-opacity:0.57843137;stroke:none;stroke-width:0.28116623;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="m 490.09784,124.99658 c -2.85624,3.24207 -15.3735,1.35186 -15.87461,-1.14947 -1.68935,-3.00507 1.10023,-12.84586 4.8268,-14.07055 2.7585,-2.89052 15.76963,-0.27577 16.55867,2.14723 1.64668,2.4778 -1.95933,12.1023 -5.51086,13.07279 z m -0.32253,-0.42959 c -3.26552,-3.17095 -1.04847,-5.8045 4.66899,-11.70335 -5.64544,2.79196 -10.83529,4.81336 -14.80116,-1.13556 2.62991,4.00551 0.44741,7.29883 -3.94777,11.41338 -0.2359,0.0907 -0.47619,0.18705 -0.72124,0.28997 0.24842,-0.0961 0.48818,-0.1928 0.72124,-0.28997 6.94744,-1.11856 10.13746,-0.046 14.07994,1.42553 z"
id="rect51" />
<path
style="fill:#ee93fd;fill-opacity:1;stroke:#ffffff;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 450.9714,108.56581 c 7.59705,-11.772433 11.26758,-24.959531 0.32371,-39.344596 -10.94388,-14.385065 -38.36337,-13.104521 -48.1698,2.153156 -9.80644,15.257677 -8.27748,29.48217 3.16122,39.71368 11.43869,10.23154 34.46073,9.48175 44.68487,-2.52224 z"
id="path40" />
<path
id="path58"
d="m 432.39443,101.72157 c -3.05438,2.34677 -6.07482,5.82708 -8.05618,4.87554 -4.90768,1.34839 -15.46644,-9.647281 -14.57389,-13.130879 -4.15475,-0.564182 9.61676,-19.5093 13.69916,-16.143113 3.54749,-2.772271 15.48998,8.333232 14.12088,12.927908 1.24075,2.843906 -0.54283,7.900009 -5.18997,11.470544 z m -8.01481,4.41387 c -1.22417,-11.148949 5.05714,-13.119033 12.94075,-15.820888 -6.54471,-4.697394 -12.62594,-2.251853 -13.97512,-12.532558 -1.11025,6.932898 -3.52276,13.206181 -12.01549,15.865475 -0.29971,-0.02135 -0.41202,-0.07439 -0.72949,-0.08233 0.31603,0.02152 0.42805,0.07361 0.72949,0.08233 7.97564,0.552802 9.32048,7.152671 13.04986,12.487971 z"
style="fill:#803766;fill-opacity:1;stroke:none;stroke-width:0.27449244;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<path
style="fill:#ebadff;fill-opacity:1;stroke:#ffffff;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 474.7348,64.48489 c 12.71219,9.742455 26.39644,1.6764 29.00579,-8.547708 1.87847,-7.584606 -4.31727,-16.491395 -11.65721,-18.770246 -19.25351,-5.293294 -27.07011,16.275467 -17.34858,27.317954 z"
id="path38" />
<path
id="path60"
d="m 499.25123,41.685619 c -0.73638,-4.358676 -9.1967,-4.673336 -11.31061,-2.308633 -1.80286,1.559231 -1.9883,8.554986 0.36615,10.133184 1.09045,2.509312 9.55485,3.835772 11.78258,1.732368 1.815,-1.565124 0.75966,-10.142418 -0.83816,-9.556917 z m -0.69171,0.462434 c -2.93996,1.328676 -1.62541,3.687184 1.15655,8.676899 -2.88315,-5.666542 -6.3088,-6.909296 -10.59109,-2.434989 3.33926,-3.16174 3.37898,-7.268591 -0.40447,-8.13514 -0.14636,-0.108317 -0.29457,-0.221188 -0.44478,-0.33926 0.15401,0.114452 0.30175,0.227417 0.44478,0.33926 4.96484,1.993106 6.08623,1.136265 9.83901,1.89323 z"
style="fill:#b048b2;fill-opacity:1;stroke:none;stroke-width:0.2811662;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<g
aria-label="Allspice"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;line-height:1.25;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:0.26458332"
id="text825">
<path
d="m 468.643,4.5745775 h 1.10795 l 5.03535,12.1212235 h -1.24024 l -1.52135,-3.671094 h -5.45703 l -1.43867,3.671094 h -1.21543 z m 0.57051,1.6784504 q -0.55397,1.4304036 -1.10794,2.8277342 -0.5457,1.3890629 -1.09141,2.8029299 h 4.53099 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path852" />
<path
d="M 477.48174,4.5828457 V 16.695801 h -1.14102 V 4.5828457 Z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path854" />
<path
d="M 481.343,4.5828457 V 16.695801 h -1.14101 V 4.5828457 Z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path856" />
<path
d="m 489.05726,10.188705 q -0.008,-0.570508 -0.63665,-0.9260418 -0.62839,-0.3555339 -1.55443,-0.3555339 -0.92604,0 -1.42214,0.2480469 -0.48782,0.2480468 -0.69453,0.4878255 -0.2067,0.2397786 -0.2067,0.6614583 0,0.42168 0.80201,0.785482 0.47129,0.214974 1.4056,0.429948 2.79466,0.644921 3.3569,1.554427 0.28939,0.46302 0.22325,1.058333 0.16536,1.182357 -1.26504,2.091862 -1.08314,0.677994 -2.33164,0.677994 -1.24024,0.0083 -2.38125,-0.851627 -1.14929,-0.859896 -1.14929,-1.976107 h 1.14102 q 0,0.661459 0.79375,1.174089 0.80202,0.51263 1.67018,0.51263 0.86817,0 1.62884,-0.396875 0.24805,-0.14056 0.53744,-0.479557 0.28939,-0.347266 0.21497,-0.752409 0.14056,-0.578776 -0.63665,-0.917774 -0.48783,-0.223242 -1.43867,-0.438216 -0.94258,-0.23151 -1.55443,-0.396875 -0.61185,-0.165364 -1.09141,-0.429948 -1.0666,-0.595312 -1.0666,-1.728059 0,-1.1327477 1.05833,-1.794206 1.05834,-0.6614582 2.43086,-0.6614582 1.37253,0 2.33991,0.6697265 0.96738,0.6697265 0.96738,1.7528647 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path858" />
<path
d="m 492.48031,7.9232101 h 1.14101 v 1.0583333 q 1.05007,-0.8516276 1.5875,-1.0335286 0.53744,-0.181901 0.93431,-0.1901693 1.68672,0.00827 2.69544,1.4138671 1.00873,1.4055994 1.00873,3.1998044 0,1.794206 -0.83509,3.050977 -0.96739,1.471744 -2.7864,1.471744 -1.81901,0 -2.60449,-0.868164 v 4.043164 h -1.14101 z m 5.53971,2.0505207 q -0.68626,-1.0748697 -1.90996,-1.0748697 -1.2237,0 -2.48874,1.7197919 v 3.464388 q 0.57051,1.058333 1.7446,1.504817 0.42994,0.165365 0.8847,0.165365 0.46302,0 0.80202,-0.14056 0.34726,-0.14056 0.73587,-0.487826 0.39687,-0.347265 0.66146,-1.099674 0.25631,-0.760677 0.25631,-1.86862 0,-1.107942 -0.68626,-2.1828122 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path860" />
<path
d="m 503.08844,7.9149419 v 8.7891271 h -1.14101 V 7.9149419 Z M 501.94743,6.2612961 V 4.5828457 h 1.14101 v 1.6784504 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path862" />
<path
d="m 511.39802,10.577312 q 0.008,-0.7937504 -0.66973,-1.2319666 -0.678,-0.4382161 -1.63711,-0.4382161 -1.00872,0 -1.90169,0.9095052 -0.89297,0.9095055 -0.89297,2.5548825 0,1.645378 0.74414,2.52181 0.74414,0.876432 1.98437,0.876432 1.24024,0 1.81075,-0.537435 0.5705,-0.537435 0.56224,-1.107942 h 1.14101 q -0.008,0.942578 -0.76894,1.769401 -0.93431,1.008723 -2.67891,1.008723 -2.80293,0 -3.64629,-2.554882 -0.28939,-0.876432 -0.28939,-2.033984 0,-1.157552 0.38034,-1.992644 0.38034,-0.8433589 0.95912,-1.4055985 0.58704,-0.5705077 1.2733,-0.8598957 0.69453,-0.289388 1.71979,-0.289388 1.03353,0 2.04226,0.7276041 1.00872,0.7276041 1.00872,2.0835941 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path864" />
<path
d="m 514.79625,12.627832 q 0.11576,1.35599 0.89297,2.248958 0.77722,0.892969 2.02572,0.884701 1.14928,-0.0083 1.90996,-0.669727 0.31419,-0.264583 0.45475,-0.537434 0.14883,-0.28112 0.14883,-0.438217 h 1.14102 q 0.008,0.719336 -0.86817,1.653646 -1.0666,1.132747 -2.42259,1.132747 -1.34772,0 -2.1084,-0.37207 -0.75241,-0.380338 -1.2733,-1.02526 -1.05834,-1.30638 -1.05834,-3.224609 0,-1.918229 1.0418,-3.2163413 1.0418,-1.2981119 2.96003,-1.2981119 1.91822,0 2.96002,1.2485025 1.0418,1.2402347 1.0418,3.6132157 z m 5.67201,-1.141015 q -0.28939,-2.5796877 -2.93522,-2.5796877 -1.10794,0 -1.81901,0.7441406 -0.71107,0.7441401 -0.8847,1.8355471 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16.93333244px;font-family:AnjaliOldLipi;-inkscape-font-specification:AnjaliOldLipi;fill:#4d4d4d;fill-opacity:1;stroke-width:0.26458332"
id="path866" />
</g>
</g>
<text
id="text2069"
y="129.65414"
x="12.249987"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.14235115px;line-height:1.25;font-family:'Nimbus Sans';-inkscape-font-specification:'Nimbus Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:0.08629897"
xml:space="preserve"><tspan
style="font-size:4.14235115px;fill:#4d4d4d;stroke-width:0.08629897"
y="129.65414"
x="12.249987"
id="tspan2067">mRNA-seq</tspan></text>
<g
style="fill:#ce6a2a;fill-opacity:1"
transform="matrix(0.28148654,0,0,0.38790612,-1.4186311,89.236646)"
id="g5513">
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5397"
width="54.545269"
height="4.0908952"
x="13.825336"
y="46.84251" />
<rect
y="40.09288"
x="20.574968"
height="4.0908952"
width="54.545269"
id="rect5399"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5401"
width="54.545269"
height="4.0908952"
x="34.074234"
y="73.841057" />
<rect
y="67.091415"
x="40.823864"
height="4.0908952"
width="54.545269"
id="rect5403"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5405"
width="54.545269"
height="4.0908952"
x="47.573498"
y="53.592136" />
<rect
y="60.34177"
x="67.822403"
height="4.0908952"
width="54.545269"
id="rect5407"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5409"
width="54.545269"
height="4.0908952"
x="7.0757051"
y="80.590675" />
<rect
y="67.0914"
x="101.57056"
height="4.0908952"
width="54.545269"
id="rect5411"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5413"
width="54.545269"
height="4.0908952"
x="94.820923"
y="73.841042" />
<rect
y="80.590668"
x="67.822395"
height="4.0908952"
width="54.545269"
id="rect5415"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5417"
width="54.545269"
height="4.0908952"
x="34.07423"
y="87.340294" />
<rect
y="33.343246"
x="-149.3662"
height="4.0908952"
width="54.545269"
id="rect5419"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
transform="scale(-1,1)" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5421"
width="54.545269"
height="4.0908952"
x="-142.61655"
y="87.340363"
transform="scale(-1,1)" />
<rect
y="26.593597"
x="-129.11729"
height="4.0908952"
width="54.545269"
id="rect5423"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
transform="scale(-1,1)" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5425"
width="54.545269"
height="4.0908952"
x="-122.36766"
y="5.6697354"
transform="scale(-1,1)" />
<rect
y="13.094329"
x="-115.61803"
height="4.0908952"
width="54.545269"
id="rect5427"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
transform="scale(-1,1)" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5429"
width="54.545269"
height="4.0908952"
x="-95.369125"
y="19.843964"
transform="scale(-1,1)" />
<rect
y="40.09288"
x="-156.11583"
height="4.0908952"
width="54.545269"
id="rect5431"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
transform="scale(-1,1)" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5433"
width="54.545269"
height="4.0908952"
x="-61.620968"
y="26.593603"
transform="scale(-1,1)" />
<rect
y="60.341797"
x="-68.370598"
height="4.0908952"
width="54.545269"
id="rect5435"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
transform="scale(-1,1)" />
<rect
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect5437"
width="54.545269"
height="4.0908952"
x="-95.369125"
y="33.343246"
transform="scale(-1,1)" />
<rect
y="46.842522"
x="-129.11729"
height="4.0908952"
width="54.545269"
id="rect5439"
style="fill:#ce6a2a;fill-opacity:1;stroke:#ffffff;stroke-width:0.6756382;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
transform="scale(-1,1)" />
</g>
<g
transform="matrix(0.35710458,0,0,0.35710458,-16.552211,86.299641)"
id="g5561">
<g
id="g5395"
transform="matrix(1.2231511,0,0,1.0342076,53.092274,-3.221107)">
<path
style="fill:#ff45bd;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,37.902172 h 3.41634 v -9.115606 h -3.41634 z m 0,0"
id="path13543" />
<path
style="fill:#ff3f54;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,48.786372 h 3.41634 v -9.115617 h -3.41634 z m 0,0"
id="path13547" />
<path
style="fill:#ff5e23;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,59.670563 h 3.41634 v -9.115582 h -3.41634 z m 0,0"
id="path13551" />
<path
style="fill:#f59411;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,70.554798 h 6.06217 v -9.115625 h -6.06217 z"
id="path13555" />
<path
style="fill:#dcd400;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,81.438998 h 3.41634 v -9.115589 h -3.41634 z m 0,0"
id="path13559" />
<path
style="fill:#6eeb23;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,92.323231 h 3.41634 v -9.115619 h -3.41634 z m 0,0"
id="path13563" />
<path
style="fill:#28d982;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,103.20743 h 3.41634 v -9.115623 h -3.41634 z m 0,0"
id="path13567" />
<path
style="fill:#0faede;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.45891759"
d="m 276.99832,114.0916 h 36.40689 v -9.11559 h -36.40689 z m 0,0"
id="path13571" />
<path
style="fill:#217fff;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 276.99832,124.97579 h 3.41634 v -9.11558 h -3.41634 z m 0,0"
id="path13575" />
<path
id="path5312"
d="m 319.33168,37.902172 h 3.41634 v -9.115606 h -3.41634 z m 0,0"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
id="path5314"
d="m 319.33168,48.786372 h 3.41634 v -9.115617 h -3.41634 z m 0,0"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
id="path5316"
d="m 319.33168,59.670563 h 3.41634 v -9.115582 h -3.41634 z m 0,0"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
id="path5318"
d="m 319.33168,70.554798 h 35.16634 v -9.115625 h -35.16634 z"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
id="path5320"
d="m 319.33168,81.438998 h 3.41634 v -9.115589 h -3.41634 z m 0,0"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
id="path5322"
d="m 319.33168,92.323231 h 9.23717 v -9.115619 h -9.23717 z"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
id="path5324"
d="m 319.33168,103.20743 h 3.41634 v -9.115623 h -3.41634 z m 0,0"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
id="path5326"
d="m 319.33168,114.0916 h 3.41503 v -9.11559 h -3.41503 z"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.45891759" />
<path
id="path5328"
d="m 319.33168,124.97579 h 3.41634 v -9.11558 h -3.41634 z m 0,0"
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,115.86019 h 3.41634 v 9.1156 h -3.41634 z m 0,0"
id="path5330" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,104.97599 h 4.24237 v 9.11562 h -4.24237 z"
id="path5332" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,94.091797 h 3.41634 v 9.115583 h -3.41634 z m 0,0"
id="path5334" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,83.207562 h 24.2433 v 9.115625 h -24.2433 z"
id="path5336" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,72.323362 h 3.41634 v 9.115589 h -3.41634 z m 0,0"
id="path5338" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,61.439129 h 3.41634 v 9.115619 h -3.41634 z m 0,0"
id="path5340" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,50.55493 h 3.41634 v 9.115623 h -3.41634 z m 0,0"
id="path5342" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.45891759"
d="m 361.66504,39.67076 h 4.13495 v 9.11559 h -4.13495 z"
id="path5344" />
<path
style="fill:#808080;fill-opacity:0.70196096;fill-rule:nonzero;stroke:none;stroke-width:0.74817562"
d="m 361.66504,28.78657 h 3.41634 v 9.11558 h -3.41634 z m 0,0"
id="path5346" />
</g>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:9.87777805px;line-height:1.25;font-family:'Nimbus Sans';-inkscape-font-specification:'Nimbus Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#666666;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="393.85269"
y="21.642082"
id="text5517"><tspan
id="tspan5515"
x="393.85269"
y="21.642082"
style="font-size:9.87777805px;text-align:center;text-anchor:middle;fill:#666666;stroke-width:0.26458332">Subtypes</tspan></text>
<text
id="text5521"
y="21.642082"
x="445.52206"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:9.87777805px;line-height:1.25;font-family:'Nimbus Sans';-inkscape-font-specification:'Nimbus Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#666666;fill-opacity:1;stroke:none;stroke-width:0.26458332"
xml:space="preserve"><tspan
style="font-size:9.87777805px;text-align:center;text-anchor:middle;fill:#666666;stroke-width:0.26458332"
y="21.642082"
x="445.52206"
id="tspan5519">Drivers</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:9.87777805px;line-height:1.25;font-family:'Nimbus Sans';-inkscape-font-specification:'Nimbus Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#666666;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="497.38028"
y="21.642082"
id="text5525"><tspan
id="tspan5523"
x="497.38028"
y="21.642082"
style="font-size:9.87777805px;text-align:center;text-anchor:middle;fill:#666666;stroke-width:0.26458332">Tissues</tspan></text>
</g>
<path
id="path5563"
d="m 47.093837,108.94591 h 4.736834 v -1.75769 l 5.236444,3.12196 -5.240514,2.97101 v -1.61947 h -4.732764 z"
style="fill:none;stroke:#666666;stroke-width:0.34519589;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:none;stroke:#666666;stroke-width:0.34519589;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 106.09962,108.94591 h 4.73683 v -1.75769 l 5.23645,3.12196 -5.24052,2.97101 v -1.61947 h -4.73276 z"
id="path5567" />
</g>
</svg>
``` {r echo=FALSE, results="hide"}
opt <- options(digits=3)
set.seed(1)
```
# Getting started
You can install Allspice using the standard procedure:
``` {r eval=FALSE}
# Install the package from a remote repository.
install.packages("Allspice")
```
To activate and list the library functions, type
``` {r}
# Activate the library.
library("Allspice")
packageVersion("Allspice")
ls("package:Allspice")
```
Each Allspice function comes with a help page that contains a code example,
such as
``` {r eval=FALSE}
# Access function documentation (not shown in vignette).
? Allspice::classifier
```
You can run all the code examples in one go by typing
``` {r eval=FALSE}
# Run all code examples (not shown in vignette).
fn <- system.file("examples.R", package = "Allspice")
source(fn)
```
# Dataset
To run this tutorial, we will use simulated data that mimics B-cell
acute lymphoblast leukemia samples:
``` {r}
# Generate gene RNA read counts.
simu <- bcellALL(300)
print(simu$counts[1:5,1:6])
print(simu$metadata[1:6,])
```
The output contains the unadjusted read counts as would be produced by
a standard RNA-seq pipeline and patients' sex and age are also simulated.
Please note that these data are artificial and meant only for demonstration
purposes; they do not reflect the complex biology of ALL accurately.
The read counts must be stored in a matrix that has the samples organized
into columns and the genes are listed as rows. For the meta-data, patients
can be listed in rows as that is more convenient in most situations.
# Classify samples {.tabset}
## Predict labels
The first step is to create a new classifier:
``` {r}
# Set up a classifier for genetic B-cell ALL subtypes.
cls <- classifier()
```
By default, the command creates an object that contains three models:
i) ALL subtype prediction, ii) driver gene prediction and iii) tissue
profiling to make sure the RNA data are suitable for analyses.
The next step is to import the covariates (e.g. sex and age) into the
classifier. If there are no covariate data available, this step can be
skipped. The default classifier uses MALE and AGE as column headings,
see the format of the metadata in the first section of the vignette. The
names of covariates are also available as
``` {r}
# List covariates.
info <- information(cls)
print(info$covariates[,c("ASSET","TITLE","COVAR")])
```
To set the covariates, use the command
``` {r}
# Set covariates.
covariates(cls) <- simu$metadata
```
Missing values or incomplete data are allowed, however, a warning will be
produced when the subtypes are predicted. Also, it is important to set the
covariates **before** loading the RNA read counts.
Once the covariates have been set, the RNA-seq read counts are next:
``` {r}
# Load RNA-seq profiles.
profiles(cls) <- simu$counts
```
The above command pre-processes the data and predicts the subtypes based on
the combined information from covariates and read counts. To get the results,
use the command
``` {r}
# Prediction results.
pred <- predictions(cls)
primary <- pred[[1]]
print(primary[1:6,c("LABEL","FREQ","PROX","EXCL")])
```
The output is a list of data frames, where each element contains the results
generated by a classification asset (see the section on how to create your own
classifier for more information on assets). Here, we are interested in the ALL
subtype which is the primary asset in the classifier.
Please use the tabs at the top to navigate to the next page.
## Metrics
Here are selected results from the previous page again:
``` {r}
# Prediction results.
ambig <- which(primary$CATEG == "Ambiguous")
uncla <- which(primary$CATEG == "Unclassified")
rows <- unique(c(1:5, ambig[1], uncla[1]))
print(primary[rows,c("LABEL","MATCH","FREQ","PROX","EXCL")])
```
The data frame includes additional information besides the most plausible
ALL subtype **LABEL**. The ALL subtype that most resembles the patient's
profile is defined as the best-matching subtype **MATCH**. For most cases,
LABEL will refer to the same subtype as MATCH, but failure to pass quality
checks and the rarity of a subtype may sometimes lead to conflicting
results.
The next column named **FREQ** tells the frequency of the predicted subtype
given the observed RNA profile and covariates. For example, if FREQ is 0.9,
then you would expect to see 9 out of 10 patients that share this data profile
to have that predicted ALL subtype. This metric depends on the training set
that was used when the classification asset was created. Thus rare subtypes
are likely to get lower frequency estimates even if the RNA profile would be
a close match.
The frequency metric does not capture mutual exclusivity because it is
evaluated independently for each subtype. For example, Allspice allows
patients to have more than one subtype in parallel when the statistical model
is trained. In this scenario, parallel subtypes may all get high frequencies,
of which the highest would be chosen as the predicted subtype. To identify
samples with mixed transcriptional characteristics, the results also includes
a probabilistic estimate for exclusivity in the column **EXCL** that tells
how likely it is that a sample comes from a single ALL subtype.
**PROX** (proximity) and **EXCL** (exclusivity) are used as quality metrics.
By default, Allspice labels any samples with <50% proximity as
'Unclassified'. Of those that pass the probability threshold, samples
with <50% exclusivity are labelled as 'Ambiguous'. The proximity measure
is conceptually the same as subtype frequency, however, any differences
in subtype prevalence are adjusted away.
You may have noticed that the subtype labels and the matched subtype
names are slightly different. This is because text labels with
non-alphanumeric characters may be automatically changed by R when used as
row or column names in data structures, thus the subtype identities are
made safe compared to the human readable labels. You can access
subtype labels by typing:
``` {r}
# Access subtype labelling information.
info <- information(cls)
print(info$categories[1:5,c("ASSET","TITLE","CATEG","LABEL")])
```
See also the Iris data example in the section on creating new classifiers.
It contains instructions on how to set the labels for a classification asset.
Please use the tabs at the top to navigate to the next page.
## Visual report
Detailed classification results can be visualised on a case-by-case basis.
In the first example, we first identify a patient sample that passed quality
control and did not show mixed characteristics:
``` {r}
# Select successful classification.
rows <- which((primary$CATEG != "Ambiguous") & (primary$FREQ > 0.9))
print(primary[rows[1],c("LABEL","MATCH","FREQ","PROX","EXCL")])
```
``` {r results="hide", fig.width=8, fig.height=6, fig.align="center", fig.cap="Figure: Classification results. The predicted subtype label is written on the top left corner. The expected frequency of the subtype given the data profile is written as a percentage after the predicted label. RNA biomarker scores were also calculated for the presence of alterations in specific genes (center bar chart), note that a patient may have multiple driver genes in parallel. The right-most chart shows RNA biomarker scores for the predicted source tissue of the sample (in this simulated dataset, all samples were generated from B-cell ALL profiles). "}
# Show patient report.
report(cls, name = rows[1], file = NULL)
```
The second example shows a case where the subtype is less obvious due to mixed
transcriptional characteristics. Sometimes this can be caused by random
incidental fluctuations that are always present in biological data, but some
of these cases will be "real" in the sense that the same individual can
harbour multiple cancer driving mutations or some alterations affect wide
regions of the genome (e.g. deletions or duplications of chromosomal
segments) and thus multiple genes would be involved.
``` {r}
# Select ambiguous classification.
rows <- which((primary$CATEG == "Ambiguous") & (primary$PROX > 0.9))
print(primary[rows[1],c("LABEL","MATCH","FREQ","PROX","EXCL")])
```
Mixed profiles typically manifest multiple indicators for driver genes while
still being identified as a B-cell ALL tissue type:
``` {r results="hide", fig.width=8, fig.height=6, fig.align="center", fig.cap="Figure: Classification results for a case with mixed transcriptional characteristics."}
# Show patient report.
report(cls, name = rows[1], file = NULL)
```
Lastly, the simulated dataset includes samples with randomized data:
``` {r}
# Select poor quality samples.
rows <- which(primary$CATEG == "Unclassified")
print(primary[rows[1],c("LABEL","MATCH","FREQ","PROX","EXCL")])
```
``` {r results="hide", fig.width=8, fig.height=6, fig.align="center", fig.cap="Figure: Classification results for a case with atypical data."}
# Show patient report.
report(cls, name = rows[1], file = NULL)
```
# Train new classifier {.tabset}
## Configuration
In Allspice, a classifier is actually a collection of classification models.
These models are enclosed in classification *assets* (objects of the Asset
class). As was observed in the previous sections, the default Allspice
classifier contains three assets (ALL subtypes, driver genes and tissues).
This section describes how to create a new RNA-seq classification asset from
the simulated B-cell ALL dataset. Another example that uses the classisal
Iris flower dataset is also presented as a demonstration on how to use
Allspice for any type of dataset with category labels.
Before creating the assets, it is important to configure the models for
different types of datasets. The default configuration is shown below:
``` {r}
# Create a new empty asset.
bALL <- asset()
print(configuration(bALL))
```
RNA-seq normalization parameters include **norm** (if set to 0,
normalization is not performed), **nonzero.min** (the minimum read
count considered non-neglible expression) and **nonzero.ratio**
(minimum ratio of non-neglible values for a transcript to be included
in the output). Allspice uses the DESeq2 method for the normalization
of read counts (Genome Biol 15, 550, 2014).
Standardization parameters include **standard** (if set to 0,
standardization is not performed) and **logarithm** (if set to 0,
data values are used without taking the logarithm). The exact
logarithmic transformation is log2(x + 1).
Feature selection parameters include **ninput.max** (the maximum
number of features to be used for classification) and
**rrinput.max** (the maximum correlation r-squared to be allowed
between features).
Classification parameters include **proximity.min** (minimum
similarity rating considered for reliable classification) and
**exclusivity.min** (minimum exclusivity for non-ambiguous
classification).
Only empty assets can be re-configured. To change the parameters,
use a numeric vector with appropriately named elements:
``` {r}
# Re-configure asset.
configuration(bALL) <- c(ninput.max=30, nonzero.min=90)
print(configuration(bALL)[c("ninput.max","nonzero.min")])
```
Please use the tabs at the top to navigate to the next page.
## RNA-seq
To populate an empty asset, some data organization is required. The first
thing to decide is the title of the asset, which will be displayed in
the visual report (see figures in the previous section). The process begins
with a list:
``` {r}
# Prepare asset title.
materials <- list(title="Simutypes")
```
Next, non-normalized RNA data are included. The dataset needs to be a
numerical matrix with samples in columns:
``` {r}
# Prepare RNA-seq read counts.
materials$dat <- simu$counts
```
Covariates can be in a data frame or a matrix with samples on rows, just
make sure all the columns are numeric:
``` {r}
# Prepare covariate data.
materials$covariates <- simu$metadata[,c("MALE","AGE")]
```
It is very important that all the rows and columns are named in each
data structure since they will be used later to link the inputs together.
It is good practice to always ensure that the row and column names
are written with alphanumeric characters without white spaces, otherwise
the automatic R filters may change some of the characters and cause
unexpected errors.
The last remaining source of information are the pre-defined subtypes
themselves that will be used to train the classification model. In this
example, the subtypes are mutually exclusive (a patient can only exhibit a
single subtype), therefore the subtypes can be obtained from the single
column in the metadata:
``` {r}
# Prepare subtype information.
categ <- simu$metadata[,"SUBTYPE",drop=FALSE]
rows <- which(categ != "Contaminated")
materials$bits <- categ[rows,,drop=FALSE]
```
Note the drop flag in the code above; this ensures that the row names are
carried forward to the bits element and can therefore be used to link the
subtype information with the rest of the patient data. The dataset contains
simulated cases where the category is undefined or the data are contaminated.
These are excluded from training.
If necessary, Allspice also allows overlapping categories, but then the
bits need to be supplied in a binary matrix where 1s indicate category
membership (the name of a column is the name of the corresponding category).
Samples should be organized into rows similarly to the covariates.
In the final step, the materials are assembled into the final classification
asset:
``` {r}
# Assemble the classification asset.
bALL <- asset()
assemble(bALL) <- materials
```
Since we excluded the category labels of "bad" samples, the training set
includes a subset of all samples. Categories that are too small (too few
samples) are ignored and will produce a warning. It is good practice to
prepare your dataset in such a way that all categories have at least
five members.
``` {r}
# Save asset to disk.
tpath <- tempfile()
export(bALL, folder = tpath)
```
The asset can now be loaded into a classifier:
``` {r}
# Create a classifier.
clstest <- classifier(tpath)
```
``` {r}
# Classify samples.
simutest <- bcellALL(5)
covariates(clstest) <- simutest$metadata
profiles(clstest) <- simutest$counts
primtest <- predictions(clstest)[[1]]
print(primtest[,c("LABEL","MATCH","FREQ","PROX","EXCL")])
```
``` {r}
# Show correct subtypes.
print(simutest$metadata)
```
Please use the tabs at the top to navigate to the next page.
## Iris data
Base R containts the classic Iris dataset that is attributed to Edgar
Anderson who collected it and Ronald Fisher who used it as an example of
linear discriminant analysis:
``` {r}
# Iris flower dataset.
print(head(iris))
```
To create a classification asset, it is good to make sure that the data are
properly identified:
``` {r}
# Set row names.
flowers <- iris
rownames(flowers) <- paste0("flower", 1:nrow(flowers))
print(flowers[c(1,80,150),])
```
The training dataset can now be finalized (note the format of the data
matrix):
``` {r}
# Prepare training set.
materials <- list(title="Iris species")
materials$dat <- t(flowers[,1:4]) # vars on rows, samples on columns
materials$bits <- flowers[,"Species",drop=FALSE]
```
The original species labels are short, however, it is nice to have the
full species names in the results as well. Adding labels can be accomplished
by
``` {r}
# Set human-readable category labels.
model <- asset()
labels <- c("Iris Setosa", "Iris Virginica", "Iris Versicolor")
names(labels) <- c("setosa", "virginica", "versicolor")
visuals(model) <- labels
```
Next, the RNA-seq normalization and logarithm needs to be disabled since this
is not RNA-seq data:
``` {r}
# Configure a new asset.
configuration(model) <- c(norm=FALSE, logarithm=FALSE)
configuration(model) <- c(nonzero.min=0, nonzero.ratio=0)
print(configuration(model))
```
The asset can now be finished
``` {r}
# Assemble the classification asset.
assemble(model) <- materials
tpath <- tempfile()
export(model, folder = tpath)
```
and tested:
``` {r}
# Classify samples.
clsiris <- classifier(tpath)
profiles(clsiris) <- t(flowers[,1:4])
iristest <- predictions(clsiris)[[1]]
print(iristest[c(1,80,150),c("LABEL","MATCH","PROX","EXCL")])
```
We know that the Setosa species is easiest to distinguish of the three
(see e.g. the Wikipedia page on the Iris study) and this is manifested
as an increase in ambiguous results for the two other categories:
``` {r}
# Summary of results.
print(table(iristest$LABEL, flowers$Species))
```
Please use the tabs at the top to navigate to the next page.
## Supercategories
On the previous tab, we changed the labels of the categories. It is also
possible to set duplicated labels, indeed, the default classifier contains
a tissue detection asset where the B-cell ALL covers multiple ALL
subtype centroids. Let's revisit the ALL classifier:
``` {r results="hide"}
# Default ALL classifier.
cls <- classifier()
```
``` {r}
# Predict source tissue.
simu <- bcellALL(5)
covariates(cls) <- simu$metadata
profiles(cls) <- simu$counts
tissues <- predictions(cls)[[3]]
print(tissues[,c("LABEL","CATEG","MATCH","MATCH.2nd")])
```
Notice how the predicted categories are different ALL subtypes, but the label
for every one of them is "B-cell ALL". In the visual report, only the
supercategory is displayed (see the figures in the section on sample
classification). The output also shows the second best matching category,
which in this case is the T-cell ALL RNA centroid. This is expected,
since it is another similar form of leukemia.
Why would you use labels to define these supercategories? The answer is a
technical one. You could put all the ALL samples together and calculate
a single B-cell ALL centroid, however, this model would be at risk of being
too coarse considering the great diversity of RNA profiles associated with
specific subtypes. For example, the rare but distinctive subtype driven by
the N159Y alteration in IKZF1 could be considered an outlier as it is far
from the overall ALL centroid, and thus these samples could be
incorrectly classified if the IKZF1 N159Y was not defined as
an explicit subtype.
## Asset contents
Classification assets are stored as text files on the disk and, although
not recommended, it is possible to view and edit them directly. For instance,
the files for ALL subtypes that were imported into the default classifier
can be found via system files that are part of the R library:
``` {r}
# Show asset contents.
base <- system.file(package = "Allspice")
folder <- file.path(base, "subtypes")
print(dir(folder))
```
**Categories** file contains information on the subtypes and their visual
attributes:
``` {r}
# Category information.
dat <- read.delim(file.path(folder, "categories.txt"))
print(dat)
```
**Centroids** file contains subtype profiles for pre-processed data values:
``` {r}
# Standardized subtype profiles.
dat <- read.delim(file.path(folder, "centroids.txt"))
print(dat[1:5,1:6])
cat(nrow(dat), " genes, ", ncol(dat), " subtypes\n", sep="")
```
**Coefficients** file contains the parameters for the back-end regression
analysis that combines the RNA biomarker from the centroid model with
the covariates. B0 is the intercept and B1 is the coefficient for the RNA
biomarker. Note that the coefficients depend on the scale of the inputs
(covariates are never standardized):
``` {r}
# Regression coefficients.
dat <- read.delim(file.path(folder, "coefficients.txt"))
print(dat[1:5,])
```
**Configuration** file contains the settings to determine how data
should be processed:
``` {r}
# Asset settings.
dat <- read.delim(file.path(folder, "configuration.txt"))
print(dat)
```
**Covariates** file contains the basic statistics of the covariates.
The MEAN is used as replacements for missing values:
``` {r}
# Covariate statistics.
dat <- read.delim(file.path(folder, "covariates.txt"))
print(dat)
```
**Nomenclature** file contains a dictionary for converting gene names
from one system to another. In this example, the asset uses Hugo symbols
but can translate ENSEMBL gene names as well:
``` {r}
# Gene names.
dat <- read.delim(file.path(folder, "nomenclature.txt"))
print(dat[1:5,])
```
**Reference** file contains basic statistics of the RNA-seq training data.
Only genes that are usable under the asset settings are included. The VALUE
column is the median of original values, whereas the mean and standard
deviation are calculated from the logarithms if the asset is so configured:
``` {r}
# RNA reference profile.
dat <- read.delim(file.path(folder, "reference.txt"))
print(dat[1:5,])
cat(nrow(dat), " genes\n", sep="")
```
# Build information
```{r echo=FALSE}
sessionInfo()
Sys.time()
```
``` {r echo=FALSE, results="hide"}
options(opt)
```
| /scratch/gouwar.j/cran-all/cranData/Allspice/vignettes/intro.rmd |
#' @title AlphaPart.R
#'
#' @description A function to partition breeding values by a path
#' variable. The partition method is described in García-Cortés et
#' al., 2008: Partition of the genetic trend to validate multiple
#' selection decisions. Animal : an international journal of animal
#' bioscience. DOI: \doi{10.1017/S175173110800205X}
#'
#' @usage
#' AlphaPart(x, pathNA, recode, unknown, sort, verbose, profile,
#' printProfile, pedType, colId, colFid, colMid, colPath, colBV,
#' colBy, center, scaleEBV)
#'
#' @details Pedigree in \code{x} must be valid in a sense that there
#' are:
#'
#' * no directed loops (the simplest example is that the individual
#' identification is equal to the identification of a father or mother)
#' * no bisexuality, e.g., fathers most not appear as mothers
#' * father and/or mother can be unknown (missing) - defined with
#' any "code" that is different from existing identifications
#'
#' Unknown (missing) values for breeding values are propagated down the
#' pedigree to provide all available values from genetic
#' evaluation. Another option is to cut pedigree links - set parents to
#' unknown and remove them from pedigree prior to using this function -
#' see \code{\link[AlphaPart]{pedSetBase}} function. Warning is issued
#' in the case of unknown (missing) values.
#'
#' In animal breeding/genetics literature the model with the underlying
#' pedigree type \code{"IPP"} is often called animal model, while the
#' model for pedigree type \code{"IPG"} is often called sire - maternal
#' grandsire model. With a combination of \code{colFid} and
#' \code{colMid} mother - paternal grandsire model can be accomodated as
#' well.
#'
#' Argument \code{colBy} can be used to directly perform a summary
#' analysis by group, i.e., \code{summary(AlphaPart(...),
#' by="group")}. See \code{\link[AlphaPart]{summary.AlphaPart}} for
#' more. This can save some CPU time by skipping intermediate
#' steps. However, only means can be obtained, while \code{summary}
#' method gives more flexibility.
#'
#' @seealso \code{\link[AlphaPart]{summary.AlphaPart}} for summary
#' method that works on output of \code{AlphaPart},
#' \code{\link[AlphaPart]{pedSetBase}} for setting base population,
#' \code{\link[AlphaPart]{pedFixBirthYear}} for imputing unknown
#' (missing) birth years, \code{\link[pedigree]{orderPed}} in
#' \pkg{pedigree} package for sorting pedigree
#'
#' @references Garcia-Cortes, L. A. et al. (2008) Partition of the
#' genetic trend to validate multiple selection decisions. Animal,
#' 2(6):821-824. \doi{10.1017/S175173110800205X}
#'
#' @param x data.frame , with (at least) the following columns:
#' individual, father, and mother identif ication, and year of birth;
#' see arguments \code{colId}, \code{colFid}, \code{colMid},
#' \code{colPath}, and \code{colBV}; see also details about the
#' validity of pedigree.
#' @param pathNA Logical, set dummy path (to "XXX") where path
#' information is unknown (missing).
#' @param recode Logical, internally recode individual, father and,
#' mother identification to \code{1:n} codes, while missing parents
#' are defined with \code{0}; this option must be used if identif
#' ications in \code{x} are not already given as \code{1:n} codes, see
#' also argument \code{sort}.
#' @param unknown Value(s) used for representing unknown (missing)
#' parent in \code{x}; this options has an effect only when
#' \code{recode=FALSE} as it is only needed in that situation.
#' @param sort Logical, initially sort \code{x} using \code{orderPed()}
#' so that children follow parents in order to make imputation as
#' optimal as possible (imputation is performed within a loop from the
#' first to the last unknown birth year); at the end original order is
#' restored.
#' @param verbose Numeric, print additional information: \code{0} -
#' print nothing, \code{1} - print some summaries about the data.
#' @param profile Logical, collect timings and size of objects.
#' @param printProfile Character, print profile info on the fly
#' (\code{"fly"}) or at the end (\code{"end"}).
#' @param pedType Character, pedigree type: the most common form is
#' \code{"IPP"} for Individual, Parent 1 (say father), and Parent 2
#' (say mother) data; the second form is \code{"IPG"} for Individual,
#' Parent 1 (say father), and one of Grandparents of Parent 2 (say
#' maternal grandfather).
#' @param colId Numeric or character, position or name of a column
#' holding individual identif ication.
#' @param colFid Numeric or character, position or name of a column
#' holding father identif ication.
#' @param colMid Numeric or character, position or name of a column
#' holding mother identif ication or maternal grandparent identif
#' ication if \code{pedType="IPG"} .
#' @param colPath Numeric or character, position or name of a column
#' holding path information.
#' @param colBV Numeric or character, position(s) or name(s) of
#' column(s) holding breeding Values.
#' @param colBy Numeric or character, position or name of a column
#' holding group information (see details).
#' @param center Logical, if \code{center=TRUE} detect a shift in base
#' population mean and attributes it as parent average effect rather
#' than Mendelian sampling effect, otherwise, if center=FALSE, the base
#' population values are only accounted as Mendelian sampling
#' effect. Default is \code{center = TRUE}.
#' @param scaleEBV a list with two arguments defining whether is
#' appropriate to center and/or scale the \code{colBV} columns in respect to
#' the base population. The list may contain the following components:
#'
#' * `center`: a logical value
#' * `scale`: a logical value. If `center = TRUE` and `scale = TRUE` then the
#' base population is set to has zero mean and unit variance.
#'
#' @example inst/examples/examples_AlphaPart.R
#' @return An object of class \code{AlphaPart}, which can be used in
#' further analyses - there is a handy summary method
#' (\code{\link[AlphaPart]{summary.AlphaPart}} works on objects of
#' \code{AlphaPart} class) and a plot method for its output
#' (\code{\link[AlphaPart]{plot.summaryAlphaPart}} works on objects of
#' \code{summaryAlphaPart} class). Class \code{AlphaPart} is a
#' list. The first \code{length(colBV)} components (one for each trait
#' and named with trait label, say trt) are data frames. Each
#' data.frame contains:
#'
#' * `x` columns from initial data `x`
#' * `trt_pa` parent average
#' * `trt_w`Mendelian sampling term
#' * `trt_path1, trt_path2, ...` breeding value partitions
#'
#' The last component of returned object is also a list named
#' \code{info} with the following components holding meta information
#' about the analysis:
#'
#' * `path` column name holding path information
#' * `nP` number of paths
#' * `lP` path labels
#' * `nT` number of traits
#' * `lT` trait labels
#' * `warn` potential warning messages associated with this object
#'
#' If \code{colBy!=NULL} the resulting object is of a class
#' \code{summaryAlphaPart}, see
#' \code{\link[AlphaPart]{summary.AlphaPart}} for details.
#'
#' If \code{profile=TRUE}, profiling info is printed on screen to spot
#' any computational bottlenecks.
#'
#' @useDynLib AlphaPart, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#'
#' @importFrom utils str
#' @importFrom pedigree orderPed
#' @importFrom stats aggregate
#' @importFrom tibble is_tibble
#'
#' @export
AlphaPart <- function (x, pathNA=FALSE, recode=TRUE, unknown= NA,
sort=TRUE, verbose=1, profile=FALSE,
printProfile="end", pedType="IPP", colId=1,
colFid=2, colMid=3, colPath=4, colBV=5:ncol(x),
colBy=NULL, center = TRUE,
scaleEBV = list()) {
## Test if the data is a data.frame
if(is_tibble(x)){
x <- as.data.frame(x)
}
## --- Setup ---
test <- (length(colId) > 1 | length(colFid) > 1 | length(colMid) > 1 | length(colPath) > 1 | length(colBy) > 1)
if (test) {
stop("arguments 'colId', 'colFid', 'colMid', 'colPath', and 'colBy' must be of length 1")
}
if (is.null(colBy)) {
groupSummary <- FALSE
} else {
groupSummary <- TRUE
}
test <- pedType %in% c("IPP", "IPG")
if (any(!test)) {
stop("'pedType' must be either 'IPP' or 'IPG'")
}
#=====================================================================
if (profile) {
time0 <- Sys.time()
cat("\nStart:", format(time0), "\n")
timeRet <- data.frame(task="Start", timeP=time0, time=0, timeCum=0,
memory=0, memoryCum=0,
stringsAsFactors=FALSE)
.profilePrint <- function(x, task, printProfile, time, mem, update=
FALSE)
{
i <- nrow(x)
x[i + 1, "task"] <- task
x[i + 1, "timeP"] <- time
x[i + 1, "time"] <- timeTMP1 <- round(time - x[i, "timeP"], digits=1L)
x[i + 1, "timeCum"] <- timeTMP2 <- round(time - x[1, "timeP"], digits=1L)
if (!update) {
x[i + 1, "memory"] <- memTMP1 <- round(mem/1024^2, digits=1L)
x[i + 1, "memoryCum"] <- memTMP2 <- round(mem/1024^2, digits=1L) + x[i, "memoryCum"]
} else {
x[i + 1, "memory"] <- memTMP1 <- round(mem/1024^2, digits=1L)
x[i + 1, "memory"] <- abs(x[i + 1, "memory"] - x[i, "memory"])
x[i + 1, "memoryCum"] <- memTMP2 <- x[i + 1, "memory"] + x[i, "memoryCum"]
}
if (printProfile == "fly") {
cat("\n", task, ":\n", sep="")
cat(" - time (this task):", format(timeTMP1), "\n")
cat(" - time (all tasks):", format(timeTMP2), "\n")
cat(" - memory (this object):", paste(memTMP1, "Mb"), "\n")
cat(" - memory (all objects):", paste(memTMP2, "Mb"), "\n")
}
x
}
}
#=======================================================================
# -- Test identification
#=======================================================================
if(!is.numeric(colId)){
colId <- which(colnames(x) %in% colId)
if (length(colId)==0) {
stop("Identification not valid for 'colId' column name", call. = FALSE)
}
}
if(!is.numeric(colMid)){
colMid <- which(colnames(x) %in% colMid)
if (length(colMid)==0) {
stop("Identification not valid for 'colMid' column name", call. = FALSE)
}
}
if(!is.numeric(colFid)){
colFid <- which(colnames(x) %in% colFid)
if (length(colFid)==0) {
stop("Identification not valid for 'colFid' column name", call. = FALSE)
}
}
if(!is.numeric(colPath)){
testN <- length(colPath)
colPath <- which(colnames(x) %in% colPath)
if (length(colPath)!=testN) {
stop("Identification not valid for 'colPath' column name", call. = FALSE)
}
testN <- NULL # not needed anymore
}
if(!is.numeric(colBy)){
testN <- length(colBy)
colByOriginal <- colBy
colBy <- which(colnames(x) %in% colBy)
if (length(colBy)!=testN) {
stop("Identification not valid for 'colBy' column name", call. = FALSE)
}
testN <- NULL # not needed anymore
}
if(!is.numeric(colBV)){
testN <- length(colBV)
colBV <- which(colnames(x) %in% colBV)
if (length(colBV) != testN) {
stop("Identification not valid for 'colBV' column(s) name", call. = FALSE)
}
testN <- NULL # not needed anymore
}
#=====================================================================
## --- Sort and recode pedigree ---
#=====================================================================
## Make sure that identifications are numeric if recode=FALSE
test <- !sapply(x[, c(colId, colFid, colMid)], is.numeric) & !recode
if (any(test)) {
stop("argument 'recode' must be 'TRUE' when identif ications in 'x' are not numeric")
}
#---------------------------------------------------------------------
## Make sure that colBV columns are numeric
test <- !sapply(x[, c(colBV)], is.numeric)
if (any(test)) {
stop("colBV columns must be numeric!")
str(x)
}
#---------------------------------------------------------------------
## Sort so that parents precede children
if (sort) {
recode <- TRUE
x <- x[order(orderPed(ped=x[, c(colId, colFid, colMid)])), ]
}
#=======================================================================
# Centering to make founders has mean zero
#=======================================================================
controlvals <- getScale()
if (!missing(scaleEBV)) {
controlvals[names(scaleEBV)] <- scaleEBV
}
if(controlvals$center == TRUE | controlvals$scale == TRUE){
x[, colBV] <- sEBV(y = x[,c(colId, colFid, colMid, colBV)],
center = controlvals$center,
scale = controlvals$scale,
recode = recode, unknown = unknown)
}
#=======================================================================
#---------------------------------------------------------------------
## Recode all ids to 1:n
if (recode) {
y <- cbind(id=seq_len(nrow(x)),
fid=match(x[, colFid], x[, colId], nomatch=0),
mid=match(x[, colMid], x[, colId], nomatch=0))
colnames(y) <- c(colId,colFid,colMid)
} else {
y <- as.matrix(x[, c(colId, colFid, colMid)])
## Make sure we have 0 when recoded data is provided
if (is.na(unknown)) {
y[, c(colFid, colMid)] <- NAToUnknown(x=y[, c(colFid, colMid)],
unknown=0)
} else {
if (unknown != 0) {
y[, c(colFid, colMid)] <-
NAToUnknown(x=unknownToNA(x=y[, c(colFid, colMid)],
unknown=unknown), unknown=0)
}
}
}
y <- cbind(y, as.matrix(x[, colBV]))
#=====================================================================
## Test if father and mother codes preceede children code -
## computational engine needs this
#=====================================================================
test <- y[, 2] >= y[, 1]
if (any(test)) {
print(x[test, ])
print(sum(test))
stop("sorting/recoding problem: parent (father in this case) code must preceede children code - use arguments 'sort' and/or 'recode'")
}
#---------------------------------------------------------------------
test <- y[, 3] >= y[, 1]
if (any(test)) {
print(x[test, ])
print(sum(test))
stop("sorting/recoding problem: parent (mother in this case) code must preceede children code - use arguments 'sort' and/or 'recode'")
}
#---------------------------------------------------------------------
if (profile) {
timeRet <- .profilePrint(x=timeRet, task="Sort and/or recode pedigree", printProfile=printProfile,
time=Sys.time(), mem=(object.size(x) + object.size(y)))
}
#=====================================================================
## --- Dimensions and Paths ---
#=====================================================================
## Pedigree size
nI <- nrow(x)
#---------------------------------------------------------------------
## Traits
lT <- colnames(x[, colBV, drop=FALSE])
nT <- length(lT) # number of traits
colnames(y)[4:ncol(y)] <- lT
#---------------------------------------------------------------------
## Missing values
nNA <- apply(x[, colBV, drop=FALSE], 2, function(z) sum(is.na(z)))
names(nNA) <- lT
#---------------------------------------------------------------------
## Paths - P matrix
test <- is.na(x[, colPath])
if (any(test)) {
if (pathNA) {
x[, colPath] <- as.character(x[, colPath])
x[test, colPath] <- "XXX"
} else {
stop("unknown (missing) value for path not allowed; use 'pathNA=TRUE'")
}
}
if (!is.factor(x[, colPath])) x[, colPath] <- factor(x[, colPath])
lP <- levels(x[, colPath])
nP <- length(lP) # number of paths
P <- as.integer(x[, colPath]) - 1
#---------------------------------------------------------------------
## Groups
if (groupSummary) {
test <- is.na(x[, colBy])
if (any(test)) {
if (pathNA) {
x[, colBy] <- as.character(x[, colBy])
x[test, colBy] <- "XXX"
} else {
stop("unknown (missing) value for group not allowed; use 'pathNA=TRUE'")
}
}
if (!is.factor(x[, colBy])) x[, colBy] <- factor(x[, colBy])
lG <- levels(x[, colBy])
nG <- length(lG)
g <- as.integer(x[, colBy])
}
if (verbose > 0) {
cat("\nSize:\n")
cat(" - individuals:", nI, "\n")
cat(" - traits: ", nT, " (", paste(lT, collapse=", "), ")", "\n", sep="")
cat(" - paths: ", nP, " (", paste(lP, collapse=", "), ")", "\n", sep="")
if (groupSummary) {
cat(" - groups: ", nG, " (", paste(lG, collapse=", "), ")", "\n", sep="")
}
cat(" - unknown (missing) values:\n")
print(nNA)
}
if (any(nNA > 0)) stop("unknown (missing) values are propagated through the pedigree and therefore not allowed")
nNA <- NULL # not needed anymore
if (profile) {
timeRet <- .profilePrint(x=timeRet, task="Dimensions and Matrices P", printProfile=printProfile,
time=Sys.time(), mem=object.size(P))
}
#=====================================================================
## --- Compute ---
#=====================================================================
## Prepare stuff for C++
c1 <- c2 <- 0.5
if (pedType == "IPG") c2 <- 0.25
#---------------------------------------------------------------------
## Add "zero" row (simplif ies computations with missing parents!)
y <- rbind(y[1, ], y)
y[1, ] <- 0
rownames(x) <- NULL
P <- c(0, P)
if (groupSummary) g <- c(0, g)
#---------------------------------------------------------------------
## Compute
if (!groupSummary) {
tmp <- .Call("AlphaPartDrop",
c1_=c1, c2_=c2,
nI_=nI, nP_=nP, nT_=nT,
y_=y,
P_=P, Px_=cumsum(c(0, rep(nP, nT-1))),
PACKAGE="AlphaPart")
} else {
N <- aggregate(x=y[-1, -c(1:3)], by=list(by=x[, colBy]), FUN=length)
tmp <- vector(mode="list", length=3)
names(tmp) <- c("pa", "w", "xa")
tmp$pa <- tmp$w <- matrix(data=0, nrow=nG+1, ncol=nT)
tmp$xa <- .Call("AlphaPartDropGroup",
c1_=c1, c2_=c2,
nI_=nI, nP_=nP, nT_=nT, nG_=nG,
y_=y, P_=P, Px_=cumsum(c(0, rep(nP, nT-1))), g_=g,
PACKAGE="AlphaPart")
}
#---------------------------------------------------------------------
## Assign nice column names
colnames(tmp$pa) <- paste(lT, "_pa", sep="")
colnames(tmp$w) <- paste(lT, "_w", sep="")
colnames(tmp$xa) <- c(t(outer(lT, lP, paste, sep="_")))
if (profile) {
timeRet <- .profilePrint(x=timeRet, task="Computing",
printProfile=printProfile,
time=Sys.time(), mem=object.size(tmp))
}
#=====================================================================
## --- Massage results ---
#=====================================================================
## Put partitions for one trait in one object (-1 is for removal of
## the "zero" row)
ret <- vector(mode="list", length=nT+1)
t <- 0
colP <- colnames(tmp$pa)
colW <- colnames(tmp$w)
colX <- colnames(tmp$xa)
#=====================================================================
# Original Values
#=====================================================================
if (center){
tmp <- centerPop(y = y[-1,], colBV = colBV, path = tmp)
}
#=====================================================================
for (j in 1:nT) { ## j <- 1
Py <- seq(t+1, t+nP)
ret[[j]] <- cbind(tmp$pa[-1, j], tmp$w[-1, j], tmp$xa[-1, Py])
colnames(ret[[j]]) <- c(colP[j], colW[j], colX[Py])
t <- max(Py)
}
tmp <- NULL # not needed anymore
#---------------------------------------------------------------------
if (profile) {
timeRet <- .profilePrint(x=timeRet, task="Massage results",
printProfile=printProfile,
time=Sys.time(), mem=object.size(ret))
}
#=====================================================================
## Add initial data
#=====================================================================
if (!groupSummary) {
for (i in 1:nT) {
## Hassle in order to get all columns and to be able to work with
## numeric or character column "names"
colX <- colX2 <- colnames(x)
names(colX) <- colX; names(colX2) <- colX2
## ... put current agv in the last column in original data
colX <- c(colX[!(colX %in% colX[colBV[i]])], colX[colBV[i]])
## ... remove other traits
colX <- colX[!(colX %in% colX2[(colX2 %in% colX2[colBV]) & !
(colX2 %in% colX2[colBV[i]])])]
ret[[i]] <- cbind(x[, colX], as.data.frame(ret[[i]]))
rownames(ret[[i]]) <- NULL
}
}
#---------------------------------------------------------------------
## Additional (meta) info. on number of traits and paths for other
## methods
tmp <- colnames(x); names(tmp) <- tmp
ret[[nT+1]] <- list(path=tmp[colPath], nP=nP, lP=lP, nT=nT, lT=lT,
warn=NULL)
## names(ret)[nT+1] <- "info"
names(ret) <- c(lT, "info")
if (profile) {
timeRet <- .profilePrint(x=timeRet, task="Finalizing returned object + adding initial data", printProfile=printProfile,
time=Sys.time(), mem=object.size(ret), update=TRUE)
}
#---------------------------------------------------------------------
# Profile
#---------------------------------------------------------------------
if (profile){
ret$info$profile <- timeRet
if (printProfile == "end") {
print(timeRet)
}
}
#=====================================================================
## --- Return ---
#=====================================================================
class(ret) <- c("AlphaPart", class(ret))
if (groupSummary) {
ret$by <- colByOriginal
ret$N <- N
summary(object=ret, sums=TRUE)
} else {
ret
}
}
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/R/AlphaPart.R |
#' AlphaPartSubset.R
#'
#' A function to choose the partition paths to keep.
#'
#' Displaying results of partitions for many paths is often confusing.
#' This function helps in selecting only paths of interest.
#' Unspecified paths are removed from the input object \code{x}.
#' Meta information is modified accordingly. Default setting does nothing.
#' @seealso
#' \code{\link[AlphaPart]{AlphaPart}} for the main method,
#' \code{\link[AlphaPart]{summary.AlphaPart}} for summary method that works on output of \code{AlphaPart},
#' \code{\link[AlphaPart]{AlphaPartSum}} for sum method.
#'
#' @param x AlphaPart or summaryAlphaPart, object from the \code{AlphaPart(...)} or \code{summary(AlphaPart(...), ...)} call.
#' @param paths Character, names of paths to be kept.
#'
#' @return An object of class \code{AlphaPart} or \code{summaryAlphaPart} with only some paths.
#' Meta information in slot "info" is modified as well.
#'
#' @example inst/examples/examples_AlphaPartSubset.R
#'
#' @useDynLib AlphaPart, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#'
#' @export
AlphaPartSubset <- function(x, paths=NULL) {
## --- Setup ---
test1 <- inherits(x, "AlphaPart")
test2 <- inherits(x, "summaryAlphaPart")
if (!any(c(test1, test2))) stop("object 'x' must be of a 'AlphaPart' or 'summaryAlphaPart' class")
## Do nothing
if (is.null(paths)) return(x)
## Keep only uniquely defined paths
paths <- unique(paths)
## --- Action ---
## Create "identity" map for specified paths and call AlphaPartSum to ease the
## work with a rather complex object structure ;)
nP <- length(paths)
map <- vector(mode="list", length=nP)
for (i in 1:nP) {
map[[i]] <- c(paths[i], paths[i])
}
## Now add non-specified paths in the last mapping so AlphaPartSum will remove them
map[[i]] <- c(map[[i]], x$info$lP[!(x$info$lP %in% paths)])
## Call AlphaPartSum
AlphaPartSum(x=x, map=map, remove=TRUE, call="AlphaPartPathSubset")
}
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/R/AlphaPartSubset.R |
#' AlphaPartSum.R
#'
#' A function to sum partitions of several paths.
#'
#' @details
#' Sometimes partitions of particular paths are very small or we want to sum
#' paths that have some similarity. These actions are easy to achive manually
#' but this functions provides a way to do this consistently with the given
#' object \code{x}.
#'
#' Arguments \code{map} must be a list of vectors of length at least
#' two. Vectors of length one are skipped. The idea is that the first element
#' is the new or existing path into which we add up all the remaining specified
#' paths, say \code{list(c("A", "B"), c("X", "X", "Y"), c("Z", "X"))} would
#' imply A = B, X = X + Y, and Z = X = X + Y. Note that once X is changed its
#' changed value is used in further calculations. Specify different (new) names
#' for new targets if you want to avoid this.
#'
#' Be carefull with \code{remove=TRUE}, which is the default setting, as all
#' partitions defined after the first (target/new) partition in vector in list
#' will be removed, for example with \code{list(c("A", "B"), c("X", "X", "Y"),
#' c("Z", "X"))} partitions B and Y will be removed, while X will not be removed
#' as it is defined as a target/new partition.
#'
#' @seealso
#' \code{\link[AlphaPart]{AlphaPart}} for the main method,
#' \code{\link[AlphaPart]{summary.AlphaPart}} for summary method that works on output of \code{AlphaPart},
#' \code{\link[AlphaPart]{AlphaPartSubset}} for subset/keep method
#'
#' @param x summaryAlphaPart, object from the \code{AlphaPart(...)} or \code{summary(AlphaPart(...), ...)} call.
#' @param map List, a map of summing paths; see details and examples.
#' @param remove Logical, remove original paths or not.
#' @param zeroPath Logical, set called path to zero if it does not exist.
#' @param call character, for internal use with \code{AlphaPartSubset}).
#'
#' @example inst/examples/examples_AlphaPartSum.R
#'
#' @return An object of class \code{AlphaPart} or \code{summaryAlphaPart} with modified partitions.
#' Meta information in slot "info" is modified as well.
#'
#' @useDynLib AlphaPart, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#'
#' @export
AlphaPartSum <- function (x, map=NULL, remove=TRUE, zeroPath=TRUE, call="AlphaPartSum") {
## --- Setup ---
test1 <- inherits(x, "AlphaPart")
test2 <- inherits(x, "summaryAlphaPart")
if (!any(c(test1, test2))) stop("object 'x' must be of a 'AlphaPart' or 'summaryAlphaPart' class")
if (!is.list(map)) stop("object 'map' must be of a 'list' class")
## Initial number of columns
nCOrig <- ifelse(test1, ncol(x[[1]]), ncol(x[[1]]))
nPOrig <- x$info$nP
nCRem <- 0
## Any unknown path?
mapP <- map
mapT <- NULL
for (i in 1:length(mapP)) {
## Targets
mapT <- c(mapT, mapP[[i]][1])
## Components
mapP[[i]] <- mapP[[i]][2:length(mapP[[i]])]
}
mapM <- NULL
mapT <- c("", mapT) ## trick so that code bellow works with i=1
for (i in 1:length(mapP)) {
testE <- mapP[[i]] %in% x$info$lP ## path exists in the data?
if (any(!testE)) {
testT <- mapP[[i]] %in% mapT[1:i] ## path exists as a target defined up to now (at i)?
if (any(!testT)) {
mapM <- c(mapM, mapP[[i]][(!testE & !testT)])
}
}
}
if (length(mapM) > 0) {
if (!zeroPath) {
stop(paste("Unexisting path(s): ", paste(mapM, collapse=", ", sep=""), sep=""))
}
}
## --- Action ---
## Loop over traits
for (t in 1:(length(x) - 1)) { ## t <- 1
## Sum up partitions given the map
if (call == "AlphaPartSum") {
if (zeroPath) {
for (i in mapM) {
x[[t]][, paste(x$info$lT[t], i, sep="_")] <- 0
}
}
for (i in 1:length(map)) { ## i <- 1
if (length(map[[i]]) > 1) {
if (test1) { ## x comes from AlphaPart(...)
if (length(map[[i]][2:length(map[[i]])]) > 1) { ## need this as rowSums() need an array of at least two dimensions
x[[t]][, paste(x$info$lT[t], map[[i]][1], sep="_")] <- rowSums(x[[t]][, paste(x$info$lT[t], map[[i]][2:length(map[[i]])], sep="_")])
} else {
x[[t]][, paste(x$info$lT[t], map[[i]][1], sep="_")] <- x[[t]][, paste(x$info$lT[t], map[[i]][2], sep="_")]
}
} else { ## x comes from summary(AlphaPart(...), ...)
if (length(map[[i]][2:length(map[[i]])]) > 1) {
x[[t]][, map[[i]][1]] <- rowSums(x[[t]][, map[[i]][2:length(map[[i]])]])
} else {
x[[t]][, map[[i]][1]] <- x[[t]][, map[[i]][2]]
}
## for (j in ...)
} ## if (test1)
} ## if (length...)
} ## for (i in 1...)
} ## if (call != "AlphaPartSum")
## Remove original partitions (we do this after we go through the whole map!)
if (remove) {
remY <- remN <- NULL
for (i in 1:length(map)) { ## i <- 1
if (length(map[[i]]) > 1) {
remN <- c(remN, map[[i]][1])
remY <- c(remY, map[[i]][2:length(map[[i]])])
} ## if (length...)
} ## for (i in 1...)
remY <- unique(remY)
remN <- unique(remN)
remY <- remY[!(remY %in% remN)]
if (length(remY) > 0) {
if (test1) { ## x comes from AlphaPart(...)
for (i in remY) x[[t]][, paste(x$info$lT[t], i, sep="_")] <- NULL
} else { ## x comes from summary(AlphaPart(...), ...)
for (i in remY) x[[t]][, i] <- NULL
} ## if (test1)
} ## if (length...)
} ## if (remove)
} ## for (t in ...)
## --- Fix meta info ---
if (remove) nCRem <- length(remY)
nC <- ifelse(test1, ncol(x[[1]]), ncol(x[[1]]))
x$info$nP <- nC - (nCOrig - nPOrig)
if (test1) {
x$info$lP <- gsub(pattern=paste(x$info$lT[t], "_", sep=""), replacement="", x=colnames(x[[t]])[(nCOrig - nPOrig + 1):nC], fixed=TRUE)
} else {
x$info$lP <- colnames(x[[t]])[(nCOrig - nPOrig + 1):nC]
}
x$info$warn <- c(x$info$warn, paste("Consistency of the overall sum of partitions might not be correct due to the previous use of '", call, "'", sep=""))
## --- Return ---
x
}
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/R/AlphaPartSum.R |
#' Sample pedigree for partition.
#'
#' A dataset containing pedigree information and breeding values
#' for six individuals.
#'
#' @format A data frame with 6 rows and 8 variables:
#' \describe{
#' \item{IId}{individual's ID}
#' \item{FId}{Father's ID}
#' \item{MId}{Mother's ID}
#' \item{gen}{Generation}
#' \item{country}{Country}
#' \item{gender}{Individual's sex}
#' \item{bv1}{Breeding value for trait 1}
#' \item{bv2}{Breeding value for trait 1}
#' }
#' @source Simulation.
"AlphaPart.ped" | /scratch/gouwar.j/cran-all/cranData/AlphaPart/R/data.R |
########################################################################
## Script purpose: generic functions
## Date: 2022-07-07
########################################################################
### unknown.R
###------------------------------------------------------------------------
### What: Change given unknown value to NA and vice versa
### $Id: unknown.R 1797 2014-04-05 18:19:49Z warnes $
### Time-stamp: <2007-04-26 13:16:10 ggorjan>
###------------------------------------------------------------------------
### {{{ isUnknown
###------------------------------------------------------------------------
#' @title Change given unknown value to NA and vice versa.
#' @description Unknown or missing values (\code{NA} in \code{R}) can be represented in various ways (as 0, 999, etc.) in different programs. \code{isUnknown}, \code{unknownToNA}, and \code{NAToUnknown} can help to change unknown values to \code{NA} and vice versa.
#' @name UnknownFuns
#' @usage isUnknown(x, unknown=NA, \dots)
#' @usage unknownToNA(x, unknown, warning=FALSE, \dots)
#' @usage NAToUnknown(x, unknown, force=FALSE, call.=FALSE, \dots)
#' @aliases isUnknown
#' @aliases isUnknown.default
#' @aliases isUnknown.POSIXlt
#' @aliases isUnknown.list
#' @aliases isUnknown.data.frame
#' @aliases isUnknown.matrix
#' @aliases unknownToNA
#' @aliases unknownToNA.default
#' @aliases unknownToNA.factor
#' @aliases unknownToNA.list
#' @aliases unknownToNA.data.frame
#' @aliases NAToUnknown
#' @aliases NAToUnknown.default
#' @aliases NAToUnknown.factor
#' @aliases NAToUnknown.list
#' @aliases NAToUnknown.data.frame
#' @param x generic, object with unknown value(s)
#' @param unknown generic, value used instead of \code{NA}
#' @param warning logical, issue warning if \code{x} already has \code{NA}
#' @param force logical, force to apply already existing value in \code{x}
#' @param ... arguments pased to other methods (as.character for POSIXlt in case of isUnknown)
#' @param call. logical, look in \code{\link{warning}}
#' @seealso
#' \code{\link[AlphaPart]{AlphaPart}}
#'
#' @author Gregor Gorjanc
#'
#' @keywords internal
#'
#' @rdname UnknownFuns
#' @export
isUnknown <- function(x, unknown=NA, ...)
UseMethod("isUnknown")
#' @rdname UnknownFuns
#' @method isUnknown default
#' @usage \method{isUnknown}{default}(x, unknown, ...)
#' @export
isUnknown.default <- function(x, unknown=NA, ...)
{
if(is.list(unknown)) unknown <- unlist(unknown)
ret <- x %in% unknown
if(any(is.na(unknown))) ret <- ret | is.na(x)
ret
}
#' @rdname UnknownFuns
#' @method isUnknown POSIXlt
#' @usage \method{isUnknown}{POSIXlt}(x, unknown, ...)
#' @export
isUnknown.POSIXlt <- function(x, unknown=NA, ...)
{
## FIXME: codetools say
## isUnknown.POSIXlt: wrong number of arguments to as.character
if(is.list(unknown) && !inherits(x=unknown, what="POSIXlt")) {
unknown <- lapply(unknown, FUN=as.character, ...)
} else {
unknown <- as.character(x=unknown, ...)
}
if(is.list(x) && !inherits(x=x, what="POSIXlt")) {
x <- lapply(x, FUN=as.character, ...)
} else {
x <- as.character(x=x, ...)
}
isUnknown.default(x=as.character(x), unknown=as.character(unknown))
}
#' @rdname UnknownFuns
#' @method isUnknown list
#' @usage \method{isUnknown}{list}(x, unknown, ...)
#' @export
isUnknown.list <- function(x, unknown=NA, ...) {
unknown <- .unknownList(x=x, unknown=unknown)
x <- mapply(FUN="isUnknown", x=x, unknown=unknown, ..., SIMPLIFY=FALSE)
x
}
#' @rdname UnknownFuns
#' @method isUnknown data.frame
#' @usage \method{isUnknown}{data.frame}(x, unknown, ...)
#' @export
isUnknown.data.frame <- function(x, unknown=NA, ...)
{
x[] <- isUnknown.list(x, unknown=unknown, ...)
x
}
#' @rdname UnknownFuns
#' @method isUnknown matrix
#' @usage \method{isUnknown}{matrix}(x, unknown, ...)
#' @export
isUnknown.matrix <- function(x, unknown=NA, ...)
apply(X=x, MARGIN=ifelse(ncol(x) > nrow(x), 1, 2), FUN=isUnknown,
unknown=unknown)
### }}}
### {{{ unknownToNA
###------------------------------------------------------------------------
#' @rdname UnknownFuns
#' @export
unknownToNA <- function(x, unknown, warning=FALSE, ...)
UseMethod("unknownToNA")
#' @rdname UnknownFuns
#' @method unknownToNA default
#' @usage \method{unknownToNA}{default}(x, unknown, warning, ...)
#' @export
unknownToNA.default <- function(x, unknown, warning=FALSE, ...)
{
if(warning) {
if(any(is.na(x)))
warning("'x' already has NA")
}
is.na(x) <- isUnknown(x=x, unknown=unknown)
x
}
#' @rdname UnknownFuns
#' @method unknownToNA factor
#' @usage \method{unknownToNA}{factor}(x, unknown, warning, ...)
#' @export
unknownToNA.factor <- function(x, unknown, warning=FALSE, ...)
{
## could put this func into default method, but I need unlisted unknown
## for levels handling
if(warning) {
if(any(is.na(x)))
warning("'x' already has NA")
}
if(is.list(unknown)) unknown <- unlist(unknown)
## Levels handling - read help page on this
levs <- levels(x)
levs <- levs[!(levs %in% unknown)]
factor(x, levels=levs)
}
#' @rdname UnknownFuns
#' @method unknownToNA list
#' @usage \method{unknownToNA}{list}(x, unknown, warning, ...)
#' @export
unknownToNA.list <- function(x, unknown, warning=FALSE, ...)
{
unknown <- .unknownList(x=x, unknown=unknown)
x <- mapply(FUN="unknownToNA", x=x, unknown=unknown, warning=warning,
SIMPLIFY=FALSE)
return(x)
}
#' @rdname UnknownFuns
#' @method unknownToNA data.frame
#' @usage \method{unknownToNA}{data.frame}(x, unknown, warning, ...)
#' @export
unknownToNA.data.frame <- function(x, unknown, warning=FALSE, ...)
{
x[] <- unknownToNA.list(x=x, unknown=unknown, warning=warning)
x
}
### }}}
### {{{ NAToUnknown
###------------------------------------------------------------------------
#' @rdname UnknownFuns
#' @export
NAToUnknown <- function(x, unknown, force=FALSE, call.=FALSE, ...)
UseMethod("NAToUnknown")
#' @method NAToUnknown default
#' @usage \method{NAToUnknown}{default}(x, unknown, force, call., ...)
#' @export
#' @rdname UnknownFuns
NAToUnknown.default <- function(x, unknown, force=FALSE, call.=FALSE, ...)
{
if(length(as.character(unknown)) != 1) # as.character allows also POSIXlt
stop("'unknown' must be a single value")
if(any(isUnknown(x, unknown=unknown)) && !force)
stop(sprintf("'x' already has value %s", dQuote(unknown)))
classX <- class(x)[1]
classUnk <- class(unknown)[1]
if(classX != classUnk) {
tmp <- c("integer", "numeric")
if(!(classX %in% tmp && classUnk %in% tmp)) {
warning(sprintf("'unknown' should be %s for %s 'x' - will try to coerce",
dQuote(classX), dQuote(classX)), call.=call.)
}
unknown <- do.call(paste("as.", classX, sep=""), args=list(unknown))
}
x[is.na(x)] <- unknown
x
}
#' @rdname UnknownFuns
#' @method NAToUnknown factor
#' @usage \method{NAToUnknown}{factor}(x, unknown, force, call., ...)
#' @export
NAToUnknown.factor <- function(x, unknown, force=FALSE, call.=FALSE, ...)
{
if(length(unknown) != 1)
stop("'unknown' must be a single value")
if(any(isUnknown(x, unknown=unknown))) {
if(!force) stop(sprintf("'x' already has level %s", dQuote(unknown)))
} else {
mapLevels(x) <- c(mapLevels(x, codes=FALSE),
mapLevels(as.character(unknown), codes=FALSE))
}
x[is.na(x)] <- unknown
if(!force)
warning(sprintf("new level is introduced: %s", unknown), call.=call.)
x
}
#' @rdname UnknownFuns
#' @method NAToUnknown list
#' @usage \method{NAToUnknown}{list}(x, unknown, force, call., ...)
#' @export
NAToUnknown.list <- function(x, unknown, force=FALSE, call.=FALSE, ...)
{
unknown <- .unknownList(x=x, unknown=unknown)
x <- mapply(FUN="NAToUnknown", x=x, unknown=unknown, force=force,
call.=call., SIMPLIFY=FALSE)
x
}
#' @rdname UnknownFuns
#' @method NAToUnknown data.frame
#' @usage \method{NAToUnknown}{data.frame}(x, unknown, force, call., ...)
#' @export
NAToUnknown.data.frame <- function(x, unknown, force=FALSE, call.=FALSE, ...)
{
x[] <- NAToUnknown.list(x=x, unknown=unknown, force=force, call.=call.)
x
}
### }}}
### {{{ .unknownList
###------------------------------------------------------------------------
#' @rdname UnknownFuns
#' @export
.unknownList <- function(x, unknown)
{
## --- Setup ---
n <- length(x)
unkN <- length(unknown)
namesX <- names(x)
namesXNullTest <- is.null(namesX)
unkNames <- names(unknown)
unkNamesNullTest <- is.null(unkNames)
defInNames <- ".default" %in% unkNames
defInd <- unkNames %in% ".default"
def <- unknown[defInd]
if(defInNames) { ## Remove default
unkN <- unkN - 1
unkNames <- unkNames[!defInd]
unknown <- unknown[!defInd]
}
if(!namesXNullTest) { ## Check for nonexistent name
test <- !(unkNames %in% namesX)
if(any(test)) stop(sprintf("name(s) %s not in names of 'x'",
paste(sQuote(unkNames[test]), collapse=" ")))
}
## --- Recycle ---
if(unkN < n) {
if(unkNamesNullTest | defInNames) {
if(defInNames) { # handling .default
names(def) <- NULL
unknownDef <- rep(def, length=(n - unkN))
names(unknownDef) <- namesX[!(namesX %in% unkNames)]
unknown <- c(unknownDef, unknown)
} else {
unknownDef <- unknown
unknown <- rep(unknownDef, length=n)
}
} else {
stop("can not propely recycle named 'unknown'")
}
}
## --- Names ---
if(!namesXNullTest) { ## no need if namesX NULL
if(unkNamesNullTest) { ## missing unkNames
names(unknown) <- namesX
} else { ## unkNames known
unknown <- unknown[match(namesX, names(unknown))]
}
}
unknown
}
### }}}
### {{{ Dear Emacs
### Local variables:
### folded-file: t
### End:
### }}}
###------------------------------------------------------------------------
### unknown.R ends here
###------------------------------------------------------------------------
### What: Print object size in human readable format - code
###------------------------------------------------------------------------
#' @title Report the Space Allocated for Objects
#' @description Provides an estimate of the memory that is being used to store \code{R} objects.
#' @name object.size
#' @usage NULL
#' @aliases object.size
#' @aliases c.object_sizes
#' @aliases as.object_sizes
#' @aliases is.object_sizes
#' @aliases format.object_sizes
#' @aliases print.object_sizes
#' @seealso
#' \code{\link[AlphaPart]{AlphaPart}}
#'
#' @keywords internal
#' @rdname object.size
#' @export
object.size <- function(...)
{
structure(sapply(list(...),
utils::object.size),
class=c("object_sizes", "numeric"))
}
#' @export
#' @rdname object.size
print.object_sizes <- function(x,
quote=FALSE,
humanReadable=getOption("humanReadable"),
standard="IEC",
units,
digits=1,
width=NULL,
sep=" ",
justify = c("right", "left"),
...)
{
print(format(x,
humanReadable=humanReadable,
standard=standard,
units=units,
digits=digits,
width=width,
sep=sep,
justify=justify),
quote=quote,
...)
invisible(x)
}
#' @export
#' @rdname object.size
format.object_sizes <- function(x,
humanReadable=getOption("humanReadable"),
standard="IEC",
units,
digits=1,
width=NULL,
sep=" ",
justify = c("right", "left"),
...)
{
if( !missing(units) )
{
if (units=="bytes")
paste(x, "bytes")
else
humanReadable(x,
standard=standard,
units=units,
digits=digits,
width=width,
sep=sep,
justify=justify
)
}
else if( is.null(humanReadable) || humanReadable==FALSE )
paste(x, "bytes")
else
humanReadable(x,
standard=standard,
units=units,
digits=digits,
width=width,
sep=sep,
justify=justify)
}
#' @export
#' @rdname object.size
is.object_sizes <- function(x) inherits(x, what="object_sizes")
#' @export
#' @rdname object.size
as.object_sizes <- function(x)
{
if(!is.numeric(x) || any(x<0)) stop("'x' must be a positive numeric vector")
class(x) <- c("object_sizes", "numeric")
x
}
#' @export
#' @rdname object.size
c.object_sizes <- function(..., recursive=FALSE)
{
x <- NextMethod()
if(is.numeric(x)) class(x) <- c("object_sizes", "numeric")
x
}
###------------------------------------------------------------------------
### object.size.R ends here
### mapLevels.R
###------------------------------------------------------------------------
### What: Mapping levels
### $Id: mapLevels.R 1991 2015-04-29 03:27:50Z warnes $
### Time-stamp: <2007-04-26 13:16:18 ggorjan>
###------------------------------------------------------------------------
### {{{ mapLevels
###------------------------------------------------------------------------
#' @title Mapping levels
#' @description \code{mapLevels} produces a map with information on levels and/or internal integer codes. As such can be conveniently used to store level mapping when one needs to work with internal codes of a factor and later transfrorm back to factor or when working with several factors that should have the same levels and therefore the same internal coding.
#' @name mapLevels
#' @usage mapLevels(x, codes=TRUE, sort=TRUE, drop=FALSE, combine=FALSE, \dots)
#' @usage mapLevels(x) <- value
#' @aliases mapLevels
#' @aliases mapLevels.default
#' @aliases mapLevels.character
#' @aliases mapLevels.list
#' @aliases mapLevels.data.frame
#' @aliases print.levelsMap
#' @aliases print.listLevelsMap
#' @aliases is.levelsMap
#' @aliases is.listLevelsMap
#' @aliases .checkLevelsMap
#' @aliases .checkListLevelsMap
#' @aliases "[.levelsMap"
#' @aliases "[.listLevelsMap"
#' @aliases c.levelsMap
#' @aliases c.listLevelsMap
#' @aliases unique.levelsMap
#' @aliases sort.levelsMap
#' @aliases mapLevels<-
#' @aliases mapLevels<-.default
#' @aliases mapLevels<-.factor
#' @aliases mapLevels<-.character
#' @aliases mapLevels<-.list
#' @aliases mapLevels<-.data.frame
#' @param x object whose levels will be mapped, look into details `codes` boolean,
#' create integer levelsMap (with internal codes) or character levelsMap (with level names)
#' @param codes boolean, create integer levelsMap (with internal codes) or character levelsMap (with level names)
#' @param sort boolean, sort levels of character \code{x}, look into details
#' @param drop boolean, drop unused levels
#' @param combine boolean, combine levels, look into details
#' @param ... additional arguments for \code{sort}
#' @param value levelsMap or listLevelsMap, output of \code{mapLevels} methods or constructed by user, look into details
#' @seealso
#' \code{\link[AlphaPart]{AlphaPart}}
#'
#' @author Gregor Gorjanc
#'
#' @keywords internal
#'
#' @rdname mapLevels
#' @export
mapLevels <- function(x, codes=TRUE, sort=TRUE, drop=FALSE,
combine=FALSE, ...)
{
UseMethod("mapLevels")
}
#' @rdname mapLevels
#' @method mapLevels default
#' @usage \method{mapLevels}{default}(x, codes, sort, drop, combine, ...)
#' @export
mapLevels.default <- function(x, codes=TRUE, sort=TRUE, drop=FALSE,
combine=FALSE, ...)
{
stop(sprintf("mapLevels can only be used on %s and %s atomic 'x'",
dQuote("factor"), dQuote("character")))
}
#' @rdname mapLevels
#' @method mapLevels character
#' @usage \method{mapLevels}{character}(x, codes, sort, drop, combine, ...)
#' @export
mapLevels.character <- function(x, codes=TRUE, sort=TRUE, drop=FALSE,
combine=FALSE, ...)
{
mapLevels.factor(x=x, codes=codes, sort=sort, drop=drop, ...)
}
## Could coerce character to factor and then use factor method, but that
## is more expensive than simple unique and length used bellow in factor
## method
#' @rdname mapLevels
#' @method mapLevels factor
#' @usage \method{mapLevels}{factor}(x, codes, sort, drop, combine, ...)
#' @export
mapLevels.factor <- function(x, codes=TRUE, sort=TRUE, drop=FALSE,
combine=FALSE, ...)
{
## --- Argument actions ----
if(is.factor(x)) { # factor
if(drop) x <- factor(x)
nlevs <- nlevels(x)
levs <- levels(x)
} else { # character
levs <- unique(x)
nlevs <- length(levs)
if(sort) levs <- sort(levs, ...)
}
## --- Create a map ---
map <- vector(mode="list", length=nlevs)
names(map) <- levs
if(codes) {
map[seq_len(nlevs)] <- seq_len(nlevs)
} else {
map[seq_len(nlevs)] <- levs
}
class(map) <- "levelsMap"
map
}
#' @rdname mapLevels
#' @method mapLevels list
#' @usage \method{mapLevels}{list}(x, codes, sort, drop, combine, ...)
#' @export
mapLevels.list <- function(x, codes=TRUE, sort=TRUE, drop=FALSE,
combine=FALSE, ...)
{
map <- lapply(x, mapLevels, codes=codes, sort=sort, drop=drop, ...)
class(map) <- "listLevelsMap"
if(combine) {
if(!codes) {
return(c(map, sort=sort, recursive=TRUE))
} else {
stop(sprintf("can not combine integer %s", dQuote("levelsMaps")))
}
}
map
}
#' @rdname mapLevels
#' @method mapLevels data.frame
#' @usage \method{mapLevels}{data.frame}(x, codes, sort, drop, combine, ...)
#' @export
mapLevels.data.frame <- function(x, codes=TRUE, sort=TRUE, drop=FALSE,
combine=FALSE, ...)
{
mapLevels.list(x, codes=codes, sort=sort, drop=drop, combine=combine, ...)
}
### }}}
### {{{ print.*
###------------------------------------------------------------------------
#' @rdname mapLevels
#' @export
.unlistLevelsMap <- function(x, ind=FALSE)
{
y <- unlist(x, use.names=FALSE)
len <- sapply(x, FUN=length)
names(y) <- rep(names(x), times=len)
if(ind) {
return(list(y, rep(seq_len(length(x)), times=len), len))
} else {
return(y)
}
}
#' @rdname mapLevels
#' @export
print.levelsMap <- function(x, ...)
{
x <- .unlistLevelsMap(x)
print(x, ...)
}
#' @rdname mapLevels
#' @export
print.listLevelsMap <- function(x, ...)
{
class(x) <- "list"
print(x, ...)
}
### }}}
### {{{ [.*
###------------------------------------------------------------------------
## We need these two since [.list method drops class
#' @rdname mapLevels
#' @export
"[.levelsMap" <- function(x, i)
{
classX <- class(x)
class(x) <- "list"
x <- x[i]
class(x) <- classX
x
}
#' @rdname mapLevels
#' @export
"[.listLevelsMap" <- function(x, i)
{
classX <- class(x)
class(x) <- "list"
x <- x[i]
class(x) <- classX
x
}
### }}}
### {{{ is.*
###------------------------------------------------------------------------
#' @rdname mapLevels
#' @export
is.levelsMap <- function(x)
inherits(x=x, what="levelsMap")
#' @rdname mapLevels
#' @export
is.listLevelsMap <- function(x)
inherits(x=x, what="listLevelsMap")
#' @rdname mapLevels
#' @importFrom methods is
#' @export
.isCharacterMap <- function(x)
{
if(is(x) == "levelsMap") {
return(inherits(x=unlist(x), what="character"))
} else {
stop(sprintf("can be used only on %s", dQuote("levelsMap")))
}
}
### }}}
### {{{ as.*
###------------------------------------------------------------------------
#' @rdname mapLevels
#' @export
as.levelsMap <- function(x, check=TRUE, ...)
{
if(check)
.checkLevelsMap(x, method="raw")
class(x) <- "levelsMap"
unique(x, ...)
}
#' @rdname mapLevels
#' @export
as.listLevelsMap <- function(x, check=TRUE)
{
if(check)
.checkListLevelsMap(x, method="raw")
class(x) <- "listLevelsMap"
x
}
### }}}
### {{{ .check*
###------------------------------------------------------------------------
#' @rdname mapLevels
#' @export
.checkLevelsMap <- function(x, method) {
xLab <- deparse(substitute(x))
also <- "\b"
if(method == "class") {
also <- "also"
if(!is.levelsMap(x))
stop(sprintf("'%s' must be a %s", xLab, dQuote("levelsMap")))
}
if(!is.list(x) || is.null(names(x)))
stop(sprintf("'%s' must be %s a named list", xLab, also))
## Components can be of different length
## if(!all(sapply(x, FUN=length) == 1))
## stop(sprintf("all components of '%s' must have length 1", xLab))
}
#' @rdname mapLevels
#' @export
.checkListLevelsMap <- function(x, method) {
xLab <- deparse(substitute(x))
also <- "\b"
if(method == "class") {
also <- "also"
if(!is.listLevelsMap(x))
stop(sprintf("'%s' must be a %s", xLab, dQuote("listLevelsMap")))
}
if(!is.list(x) || any(!sapply(x, FUN=is.levelsMap)))
stop(sprintf("'%s' must be %s a list of %s", xLab, also,
dQuote("levelsMap")))
lapply(x, FUN=.checkLevelsMap, method=method)
}
### }}}
### {{{ c.*
###------------------------------------------------------------------------
#' @rdname mapLevels
#' @export
c.levelsMap <- function(..., sort=TRUE, recursive=FALSE)
{
x <- list(...)
class(x) <- "listLevelsMap"
## we use recursive=TRUE here because ... is a lists of lists
c(x, sort=sort, recursive=TRUE)
}
#' @rdname mapLevels
#' @export
c.listLevelsMap <- function(..., sort=TRUE, recursive=FALSE)
{
x <- list(...)
lapply(x, FUN=.checkListLevelsMap, method="class")
x <- unlist(x, recursive=FALSE)
if(!recursive) {
class(x) <- "listLevelsMap"
} else {
if(any(!sapply(x, FUN=.isCharacterMap)))
stop(sprintf("can not combine integer %s", dQuote("levelsMaps")))
if(!is.null(names(x))) names(x) <- NULL
x <- unlist(x, recursive=FALSE)
## how to merge components with the same name?
class(x) <- "levelsMap"
if(sort) x <- sort(x)
x <- unique(x)
}
x
}
### }}}
### {{{ sort
###------------------------------------------------------------------------
#' @rdname mapLevels
#' @export
sort.levelsMap <- function(x, decreasing=FALSE, na.last=TRUE, ...)
x[order(names(x), na.last=na.last, decreasing=decreasing)]
### }}}
### {{{ unique
###------------------------------------------------------------------------
#' @rdname mapLevels
#' @export
unique.levelsMap <- function(x, incomparables=FALSE, ...)
{
## Find duplicates
y <- .unlistLevelsMap(x, ind=TRUE)
## Duplicates for values and names combinations
test <- duplicated(cbind(y[[1]], names(y[[1]])),
incomparables=incomparables, ...)
if(any(test)) {
if(any(y[[3]] > 1)) { # work with the same structure as in x
j <- 1
k <- y[[3]][1]
empty <- NULL
for(i in seq(along=x)) { # how slow is this loop?
tmp <- !test[j:k]
if(all(!tmp)) { # these components will be empty
empty <- c(empty, i)
} else {
x[[i]] <- x[[i]][tmp]
}
j <- j + y[[3]][i]
k <- k + y[[3]][i + 1]
}
if(!is.null(empty))
x[empty] <- NULL
} else { # simple one-length components
x <- x[!test]
}
}
x
}
### }}}
### {{{ mapLevels<-
###------------------------------------------------------------------------
#' @rdname mapLevels
#' @export
"mapLevels<-" <- function(x, value)
UseMethod("mapLevels<-")
#' @rdname mapLevels
#' @method mapLevels<- default
#' @export
"mapLevels<-.default" <- function(x, value)
{
## --- Checks ---
classX <- c("integer", "character", "factor")
if(any(!(class(x) %in% classX)))
stop(sprintf("'x' must be either: %s", paste(dQuote(classX), collapse=", ")))
.checkLevelsMap(x=value, method="class")
## --- Mapping levels in x ---
char <- all(sapply(value, is.character))
int <- all(sapply(value, is.integer))
if(int) { # codes=TRUE
if(is.integer(x)) x <- factor(x)
if(is.factor(x)) levels(x) <- value
if(is.character(x))
stop(sprintf("can not apply integer %s to %s",
dQuote("levelsMap"), dQuote("character")))
} else { # codes=FALSE
if(!char)
stop("all components of 'value' must be of the same class")
if(is.character(x)) x <- factor(x)
if(is.factor(x)) levels(x) <- value
if(is.integer(x))
stop(sprintf("can not apply character %s to %s",
dQuote("levelsMap"), dQuote("integer")))
}
x
}
#' @rdname mapLevels
#' @method mapLevels<- list
#' @export
"mapLevels<-.list" <- function(x, value)
{
if(!is.listLevelsMap(value)) {
if(is.levelsMap(value)) {
value <- as.listLevelsMap(list(value), check=FALSE)
## no need for check as default method does checking anyway
} else {
stop(sprintf("'x' must be either %s or %s",
dQuote("listLevelsMap"), dQuote("levelsMap")))
}
}
x <- mapply(FUN="mapLevels<-", x=x, value=value, SIMPLIFY=FALSE)
x
}
#' @rdname mapLevels
#' @method mapLevels<- data.frame
#' @export
"mapLevels<-.data.frame" <- function(x, value)
{
x[] <- "mapLevels<-.list"(x, value)
x
}
### }}}
### {{{ Dear Emacs
## Local variables:
## folded-file: t
## End:
### }}}
###------------------------------------------------------------------------
### mapLevels.R ends here
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/R/dataMethods.R |
#=======================================================================
# Print
#=======================================================================
#-----------------------------------------------------------------------
# Print plotSummaryAlphaPart
#-----------------------------------------------------------------------
#' @rdname print.plotSummaryAlphaPart
#' @method print plotSummaryAlphaPart
#' @title Print a plot generate by the function
#' \code{plotSummaryAlphaPart}
#' @usage \method{print}{plotSummaryAlphaPart}(x, ask, ...)
#' @aliases print.plotSummaryAlphaPart
#' @description Plot output object from
#' \code{\link[AlphaPart]{plot.summaryAlphaPart}}.
#' @seealso \code{\link[AlphaPart]{plot.summaryAlphaPart}}
#'
#' @param x plotSummaryAlphaPart, output object from
#' \code{\link[AlphaPart]{plot.summaryAlphaPart}} function
#' @param ask Logical, ask before printing another plot?
#' @param ... Arguments passed to other functions (not used at the
#' moment).
#'
#' @example inst/examples/examples_print.plotSummaryAlphaPart.R
#'
#' @useDynLib AlphaPart, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#'
#' @export
print.plotSummaryAlphaPart <- function (x, ask=interactive(), ...) {
k <- 1
nT <- length(x)
for (i in 1:nT) {
print(x[[i]])
if (ask) {
if (k < nT) {
msg <- paste("Press any key to print out the next plot (",
k, "/", nT, ") ...\n", sep="")
mp <- readline(prompt=msg)
}
}
k <- k + 1
}
}
#-----------------------------------------------------------------------
# Print summaryAlphaPart
#-----------------------------------------------------------------------
#' @title Print method for objects of the class summaryAlphaPart.
#' @rdname print.summaryAlphaPart
#' @method print summaryAlphaPart
#' @usage \method{print}{summaryAlphaPart}(x, ...)
#' @aliases print.summaryAlphaPart
#' @description Print method for objects of the class
#' \code{summaryAlphaPart} (result of \code{summary(AlphaPart(...))}).
#'
#' @seealso
#' \code{\link[AlphaPart]{summary.AlphaPart}}
#'
#' @param x summaryAlphaPart, output object from
#' \code{\link[AlphaPart]{summary.AlphaPart}} function.
#' @param ... Arguments passed to other functions (not used at the
#' moment).
#'
#' @example inst/examples/examples_summary.AlphaPart.R
#'
#' @useDynLib AlphaPart, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#'
#' @export
print.summaryAlphaPart <- function(x, ...) {
nI <- nrow(x[[1]])
cat("\n\n Summary of partitions of breeding values \n")
cat(" - paths: ", x$info$nP, " (", paste(x$info$lP, collapse=", "), ")\n", sep="")
cat(" - traits: ", x$info$nT, " (", paste(x$info$lT, collapse=", "), ")\n", sep="")
if (length(x$info$warn) > 0) cat(" - warning: ", paste(x$info$warn, collapse="\n"), "\n", sep="")
for (trt in x$info$lT) {
cat("\n Trait:", trt, "\n\n")
print(x[[trt]])
}
cat("\n")
}
#-----------------------------------------------------------------------
# Print AlphaPart
#-----------------------------------------------------------------------
#' @title Print method for the output of AlphaPart function.
#' @rdname print.AlphaPart
#' @method print AlphaPart
#' @usage \method{print}{AlphaPart}(x, n, ...)
#' @aliases print.AlphaPart
#' @description Partitioning of breeding values if often performed on
#' quite large datasets, which quickly fills in the whole
#' screen. Print method therefore prints out paths, number of
#' individuals and the first and the last few lines for each trait to
#' quickly see what kind of data is in \code{x}.
#' @seealso \code{\link[AlphaPart]{AlphaPart}}, \code{\link{head}},
#' \code{\link{tail}}.
#'
#' @param x AlphaPart, output object from
#' \code{\link[AlphaPart]{AlphaPart}} function.
#' @param n Integer, number of the first and last rows in \code{x} to
#' print out using \code{\link{head}} and \code{\link{tail}}.
#' @param ... Arguments passed to \code{print} function.
#'
#' @example inst/examples/examples_AlphaPart.R
#'
#' @useDynLib AlphaPart, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#' @importFrom utils head
#' @importFrom utils tail
#'
#' @export
print.AlphaPart <- function (x, n=6, ...) {
nI <- nrow(x[[1]])
cat("\n\n Partitions of breeding values \n")
cat(" - individuals:", nI, "\n")
cat(" - paths: ", x$info$nP, " (", paste(x$info$lP, collapse=", "), ")\n", sep="")
cat(" - traits: ", x$info$nT, " (", paste(x$info$lT, collapse=", "), ")\n", sep="")
if (length(x$info$warn) > 0) cat(" - warning: ", paste(x$info$warn, collapse="\n"), "\n", sep="")
for (trt in x$info$lT) {
cat("\n Trait:", trt, "\n\n")
if (nI > n*2) {
print(head(x[[trt]]), ...)
cat("...\n")
print(tail(x[[trt]]), ...)
} else {
print(x[[trt]], ...)
}
}
cat("\n")
}
#=======================================================================
# Summary
#=======================================================================
#' @title A function to summarize AlphaPart object.
#' @rdname summary.AlphaPart
#' @method summary AlphaPart
#' @usage \method{summary}{AlphaPart}(object, by, FUN, labelSum, subset,
#' sums, cov, ...)
#' @description Breedng values of individuals are often summarized,
#' either by year of birth or some other classification. Function
#' \code{summary.AlphaPart} provides a way to ease the computation of
#' such summaries on partitions of breeding values.
#'
#' @seealso \code{\link[AlphaPart]{AlphaPart}} for partitioning breeding
#' values, \code{\link[AlphaPart]{plot.summaryAlphaPart}} for plotting
#' output of summary method
#'
#' @param object AlphaPart, output object from
#' \code{\link[AlphaPart]{AlphaPart}} function.
#' @param by Character, the name of a column by which summary function
#' FUN should be applied; if \code{NULL} (default) summary is given
#' for the whole table.
#' @param FUN Function, which function should be used in summary;
#' function should return single value per each level of by.
#' @param labelSum Character, label used for the overall breeding value.
#' @param subset Logical, perform summary only on a subset of
#' \code{object} subsetted by this argument.
#' @param sums Logical, link between \code{\link[AlphaPart]{AlphaPart}}
#' and \code{summary.AlphaPart()} (only for internal use!).
#' @param cov Logical, if FALSE returns \code{n} variances plus one
#' additional column containing two times the sum of all covariances;
#' otherwise returns \code{n} variance and \code{n(n-1)/2} covariances
#' in the form of \code{2*Cov(., .)}, where \code{n} is the number of
#' partitions. This argument only works when \code{FUN = var}. Defaut
#' \code{cov = FALSE}.
#' @param ... Arguments passed to other functions (not used at the
#' moment).
#'
#' @example inst/examples//examples_summary.AlphaPart.R
#'
#' @return An object of class \code{summaryAlphaPart}, which is a list
#' of data frames with summary statistics on breeding value
#' partitions. For each trait there a dataframe holds summary for the
#' "whole/original" breeding value and its partitions. In addition
#' another list is added (named \code{info}) with the following
#' components holdinfg meta info:
#'
#' * `path` column name holding path information
#' * `nP` number of paths
#' * `lP` path labels
#' * `nT` number of traits
#' * `lT` trait labels
#' * `by` column name of variable by which summary was performed
#' * `warn` potential warning messages associated with this object
#' * `labelSum` column name of summary for "whole/original" breeding values
#'
#' There is a handy plot method (\code{\link[AlphaPart]{plot.summaryAlphaPart}}) for output.
#'
#' @useDynLib AlphaPart, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#' @importFrom dplyr group_by do
#' @importFrom magrittr %>%
#' @importFrom stats cov var
#'
#' @export
summary.AlphaPart <- function(object, by=NULL, FUN=mean, labelSum="Sum",
subset=NULL, sums=FALSE, cov = FALSE,
...) {
#---------------------------------------------------------------------
## --- Setup ---
#---------------------------------------------------------------------
groupSummary <- sums
#---------------------------------------------------------------------
# Test Alpha Part Class
test <- !inherits(object, "AlphaPart")
if (test) {
stop("'object' must be of a AlphaPart class")
}
#---------------------------------------------------------------------
# Transforming FUN in a function
test <- is.character(FUN)
if(test==TRUE){
test <- is.function(try(get(FUN), silent = TRUE))
if (test == FALSE) {
stop("argument 'FUN' must be a function", call.= FALSE)
}
FUN = get(FUN)
}
#---------------------------------------------------------------------
# Test for covariance output
test <- is.logical(cov)
if (test==FALSE) {
stop("argument 'cov' must be logical (TRUE or FALSE)", call. = FALSE)
}
#---------------------------------------------------------------------
if (groupSummary) by <- object$by
#---------------------------------------------------------------------
if (!groupSummary) {
test <- !is.null(by) && !(by %in% colnames(object[[1]]))
if (test) {
stop("argument 'by' must be NULL or one of column names in object")
}
test <- do.call(what=FUN, args=list(x=1:3, ...))
if (length(test) > 1) {
stop("function FUN must return a single value (scalar)")
}
}
#---------------------------------------------------------------------
nC <- ncol(object[[1]]) ## number of columns
nP <- object$info$nP ## number of paths
nCov <- 0 ## number of covariances
lP <- object$info$lP ## names of paths
nT <- object$info$nT ## number of traits
lT <- object$info$lT ## names of traits
ret <- vector(mode="list", length=nT+1)
names(ret) <- c(lT, "info")
#---------------------------------------------------------------------
## Subset
if (!is.null(subset)) {
object[1:nT] <- lapply(object[1:nT], FUN=function(z) z[subset, ])
}
ret$info <- list(path=object$info$path, nP=nP, nCov=nCov, lP=lP,
nT=nT, lT=lT, by=by, warn=object$info$warn,
labelSum=labelSum)
#---------------------------------------------------------------------
## --- Compute ---
#---------------------------------------------------------------------
z <- ifelse (groupSummary, 1, 2)
for(i in 1:nT) { ## for each trait
## Setup
cols <- c(lT[i], paste(lT[i], lP, sep="_"))
checkCov <- length(cols[-1])>1 ## do not run cov if path has 1 level
paths <- cols
paths[2:length(paths)] <- ret$info$lP
paths[1] <- labelSum
## Summarize Variance Partitioning
if (identical(deparse(FUN),deparse(var))) {
. <- NULL
if (!groupSummary) {
if (is.null(by)) {
#pri length ne sme biti na.rm = TRUE
tmp <- rep(1, times=nrow(object[[i]]))
tmpM <- aggregate(x=object[[i]][, cols], by=list(by=tmp),
FUN=var, na.rm=TRUE)
if (checkCov){
if (cov) {
tmpM2 <- object[[i]] %>%
group_by(object[[i]][, by]) %>%
do(data.frame(
cov=2*t(cov(.[,cols[-1]], .[,cols[-1]])[
lower.tri(cov(.[,cols[-1]], .[,cols[-1]]),
diag = FALSE)])))
if(is.null(ncol(tmpM2))==FALSE){
tmpM2 <- tmpM2[,-1]
}
}else {
tmpM2 <- tmpM[,2]-rowSums(tmpM[,-c(1:2)])
}
tmpM <- cbind(tmpM,tmpM2)
}
tmpN <- aggregate(x=object[[i]][, cols[1]], by=list(by=tmp),
FUN=length)
} else {
tmpM <- aggregate(x=object[[i]][, cols],
by=list(by=object[[i]][, by]),
FUN=var, na.rm=TRUE)
if (checkCov){
if (cov) {
tmpM2 <- object[[i]] %>%
group_by(object[[i]][, by]) %>%
do(data.frame(
cov=2*t(cov(.[,cols[-1]], .[,cols[-1]])[
lower.tri(cov(.[,cols[-1]], .[,cols[-1]]),
diag = FALSE)])))
if(is.null(ncol(tmpM2))==FALSE){
tmpM2 <- tmpM2[,-1]
}
}else {
tmpM2 <- tmpM[,2]-rowSums(tmpM[,-c(1:2)])
}
tmpM <- cbind(tmpM,tmpM2)
}
tmpN <- aggregate(x=object[[i]][, cols[1]],
by=list(by=object[[i]][, by]), FUN=length)
}
} else {
tmpN <- object$N[, c(1, i+1)]
tmpM <- object[[i]][, -(1:2)]
tmpM <- cbind(rowSums(tmpM), tmpM)
tmpM <- tmpM / tmpN[, 2]
}
#-----------------------------------------------------------------
## Add nice column names
colnames(tmpN) <- c(by, "N")
count <- seq(1,length(paths))[-1]
if(cov && checkCov) {
for(ii in count[-length(count)]){
for(jj in (ii+1):max(count)){
kcount <- length(paths)+1
paths[kcount] <- paste0(paths[ii],paths[jj])
}
}
}else{
kcount <- length(paths)+1
if(checkCov){
paths <- c(paths,"Sum.Cov")
}
}
colnames(tmpM)[z:ncol(tmpM)] <- paths
#-----------------------------------------------------------------
## Combine FUN and number of records
tmp <- cbind(tmpN, tmpM[, z:ncol(tmpM)])
#-----------------------------------------------------------------
}else {
## Summarize non-variance partitioning
if (!groupSummary) {
if (is.null(by)) {
#pri length ne sme biti na.rm = TRUE
tmp <- rep(1, times=nrow(object[[i]]))
tmpM <- aggregate(x=object[[i]][, cols], by=list(by=tmp),
FUN=FUN, na.rm=TRUE)
tmpN <- aggregate(x=object[[i]][, cols[1]], by=list(by=tmp),
FUN=length)
} else {
tmpM <- aggregate(x=object[[i]][, cols],
by=list(by=object[[i]][, by]),
FUN=FUN, na.rm=TRUE)
tmpN <- aggregate(x=object[[i]][, cols[1]],
by=list(by=object[[i]][, by]), FUN=length)
}
} else {
tmpN <- object$N[, c(1, i+1)]
tmpM <- object[[i]][, -(1:2)]
tmpM <- cbind(rowSums(tmpM), tmpM)
tmpM <- tmpM / tmpN[, 2]
}
#-----------------------------------------------------------------
## Add nice column names
colnames(tmpN) <- c(by, "N")
colnames(tmpM)[z:ncol(tmpM)] <- paths
#-----------------------------------------------------------------
## Combine FUN and number of records
tmp <- cbind(tmpN, tmpM[, z:ncol(tmpM)])
#-----------------------------------------------------------------
}
## Store
ret[[i]] <- tmp
}
#---------------------------------------------------------------------
## --- Update when var ---
#---------------------------------------------------------------------
if (identical(deparse(FUN),deparse(var))) {
ret$info$nCov <- kcount-ret$info$nP-1 # number of covariances
ret$info$lP <- paths[-1] ## names of paths
}
#---------------------------------------------------------------------
## --- Return ---
#---------------------------------------------------------------------
class(ret) <- c("summaryAlphaPart", class(ret))
ret
}
#=======================================================================
# Plot
# =======================================================================
#' @title A function to plot summary of partitioned breeding values.
#' @rdname plot.summaryAlphaPart
#' @method plot summaryAlphaPart
#' @usage \method{plot}{summaryAlphaPart}(x, by, sortValue,
#' sortValueFUN, sortValueDec, addSum, paths, xlab, ylab, xlim, ylim,
#' color, lineSize, lineType, lineTypeList, useDirectLabels, method,
#' labelPath, ...)
#' @details Information in summaries of partitions of breeding values
#' can be overhelming due to a large volume of numbers. Plot method
#' can be used to visualise this data in eye pleasing way using
#' ggplot2 graphics.
#'
#' @param x summaryAlphaPart, object from the \code{AlphaPart(...)} or
#' \code{summary(AlphaPart(...), ...)} call.
#' @param by Character, the name of a column by which summary function
#' FUN should be applied; if \code{NULL} (default) summary is given
#' for the whole table.
#' @param sortValue Logical, affect legend attributes via sort of paths
#' according to \code{sortValueFUN} function; if not logical, then
#' ordered paths are given as a character vector.
#' @param sortValueFUN Function, that produces single value for one
#' vector, say \code{mean} or \code{sum}.
#' @param sortValueDec Logical, sort decreasing.
#' @param addSum Logical, plot the overall trend.
#' @param paths Character or list or characters, name of paths to plot;
#' if \code{NULL} plot all paths; see examples.
#' @param xlab Character, x-axis label.
#' @param ylab Character, y-axis label; can be a vector of several
#' labels if there are more traits in \code{x} (recycled!).
#' @param xlim Numeric, a vector of two values with x-axis limits; use a
#' list of vectors for more traits.
#' @param ylim Numeric, a vector of two values with y-axis limits; use a
#' list of vectors for more traits.
#' @param color Character, color names; by default a set of 54 colors is
#' predefined from the \pkg{RColorBrewer} package; in addition a black
#' colour is attached at the begining for the overall trend; if there
#' are more paths than colors then recycling occours.
#' @param lineSize Numeric, line width.
#' @param lineType Numeric, line type (recycled); can be used only if
#' lineTypeList=NULL.
#' @param lineTypeList List, named list of numeric values that help to
#' point out a set of paths (distinguished with line type) within
#' upper level of paths (distinguished by, color), e.g.,
#' lineTypeList=list("-1"=1, "-2"=2, def=1) will lead to use of line
#' 2, for paths having "-2" at the end of path name, while line type 1
#' (default) will, be used for other paths; specification of this
#' argument also causes recycling of colors for the upper level of
#' paths; if NULL all lines have a standard line type, otherwise
#' \code{lineType} does not have any effect.
#' @param useDirectLabels Logical, use directlabels package for legend.
#' @param method List, method for direct.label.
#' @param labelPath Character, legend title; used only if
#' \code{useDirectLabels=FALSE}.
#' @param ... Arguments passed to other functions (not used at the
#' moment).
#'
#' @example inst/examples/examples_plotSummaryAlphaPart.R
#'
#' @return A list of ggplot objects that can be further modified or
#' displayed. For each trait in \code{x} there is one plot
#' visualising summarized values.
#'
#' @useDynLib AlphaPart, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#'
#' @export
#' @importFrom directlabels last.qp
#' @importFrom directlabels direct.label
#' @importFrom reshape melt
#' @import ggplot2
plot.summaryAlphaPart <-
function (
x,
by = NULL,
sortValue=TRUE,
sortValueFUN=sum,
sortValueDec=TRUE,
addSum=TRUE,
paths=NULL,
xlab=NULL,
ylab=NULL,
xlim=NULL,
ylim=NULL,
color,
lineSize=1,
lineType=1,
lineTypeList=NULL,
useDirectLabels=TRUE,
method=list(last.qp, hjust=0),
labelPath=NULL,
...
)
{
#-------------------------------------------------------------------
## --- Setup ---
#-------------------------------------------------------------------
if (!inherits(x, "summaryAlphaPart")) stop("'x' must be of a summaryAlphaPart class")
by <- x$info$by
## by argument
if(is.null(by)) stop("output is provided only when the 'by' argument is defined on the 'summary' function")
path <- x$info$path
lT <- x$info$lT
nT <- x$info$nT
nP <- x$info$nP + x$info$nCov
ret <- vector(mode="list", length=nT)
names(ret) <- x$info$lT
## Axis labels
if (!is.null(xlab) && length(xlab) > 1) stop("you can provide only one value for 'xlab'")
if (!is.null(ylab) && length(ylab) < nT) ylab <- rep(ylab, length=nT)
## Colors
if (!missing(color)) {
if (length(color) < nP) color <- rep(color, length=nP)
color <- c("black", color)
} else {
if (FALSE) { ## Code to generate a bunch of qualitative colors
requireNamespace("RColorBrewer")
#library(package="RColorBrewer")
pals <- c("Set1", "Dark2", "Accent", "Paired", "Set2", "Set3")
palsN <- brewer.pal.info[pals, "maxcolors"]
color <- vector(length=sum(palsN))
j <- 1
for (i in seq(along=pals)) {
color[j:(j - 1 + palsN[i])] <-
do.call("brewer.pal", args=list(n=palsN[i], name=pals[i]))
j <- j + palsN[i]
}
color <- unique(color)
}
color <- c("black", "#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
"#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999",
"#1B9E77", "#D95F02", "#7570B3", "#E7298A", "#66A61E",
"#E6AB02", "#A6761D", "#666666", "#7FC97F", "#BEAED4",
"#FDC086", "#FFFF99", "#386CB0", "#F0027F", "#BF5B17",
"#A6CEE3", "#1F78B4", "#B2DF8A", "#33A02C", "#FB9A99",
"#E31A1C", "#FDBF6F", "#CAB2D6", "#6A3D9A", "#B15928",
"#66C2A5", "#FC8D62", "#8DA0CB", "#E78AC3", "#A6D854",
"#FFD92F", "#E5C494", "#B3B3B3", "#8DD3C7", "#FFFFB3",
"#BEBADA", "#FB8072", "#80B1D3", "#FDB462", "#B3DE69",
"#FCCDE5", "#D9D9D9", "#BC80BD", "#CCEBC5", "#FFED6F")
color <- color[color != "#FFFF33"] ## remove yellow color(s)
}
#-------------------------------------------------------------------
## Line type
if (is.null(lineTypeList)) {
if (length(lineType) < nP) {
lineType <- c(1, rep(x=lineType, times=nP))
} else {
lineType <- c(1, lineType)
}
}
#-------------------------------------------------------------------
## --- Create plots ---
#-------------------------------------------------------------------
## Ylim
ylimT <- ylim
for (i in 1:nT) { ## loop over traits
colorI <- color
lineTypeI <- lineType
## Prepare data
tmp0 <- x[[i]]
## Make sure that path has a name "N"
tmpCol <- colnames(tmp0)
test <- tmpCol %in% "N"
if (sum(test) > 1) {
tmpCol[test & cumsum(test) == 2] <- "N."
colnames(tmp0) <- tmpCol
warning("changing path name from 'N' to 'N.'")
}
tmp <- melt(tmp0[, !(colnames(tmp0) %in% "N")], id=by)
colnames(tmp) <- c("by", "path", "trait")
if (is.logical(sortValue)) {
if (sortValue) {
nC <- ncol(tmp0)
pathStat <- sapply(X=tmp0[, (nC - nP + 1):nC], FUN=sortValueFUN,
na.rm=TRUE)
levs <- names(sort(pathStat, decreasing=sortValueDec))
tmp$path <- factor(tmp$path, levels=c(x$info$labelSum, levs))
if (!is.null(lineTypeList)) { ## fiddle with upper (color) and lower (line type) level of paths
levs2X <- names(lineTypeList); levs2X <-
levs2X[levs2X != "def"]
levs1 <- levs2 <- levs
for (k in levs2X) {
j <- paste(k, "$", sep="") ## lower label mark needs to be at the end of path name!!!
levs2[grep(pattern=j, x=levs1)] <- k
levs1 <- sub(pattern=j, replacement="", x=levs1)
}
levs2[!levs2 %in% levs2X] <- "def"
levs1X <- unique(levs1)
colorList <- as.list(color[-1][seq_len(length(levs1X))])
names(colorList) <- levs1X
colorI <- c("black", unlist(colorList[levs1]))
names(colorI) <- NULL
lineTypeI <- c(lineTypeList$def, unlist(lineTypeList[levs2]))
names(lineTypeI) <- NULL
}
}
} else {
tmp$path <- factor(tmp$path, levels=c(x$info$labelSum, sortValue))
}
#-----------------------------------------------------------------
## Prepare plot
#trait in "" since it is not defined
#-----------------------------------------------------------------
trait <- tmp$trait
p <- qplot(x=by, y=trait, group=path, data=tmp, color=path,
linetype=path, geom="line")
p <- p + geom_line(size=lineSize)
p <- p + xlab(label=ifelse(is.null(xlab), by, xlab))
p <- p + ylab(label=ifelse(is.null(ylab), lT[i], ylab[i])) #lT[i] is the TRAIT!!!
#-----------------------------------------------------------------
if (!is.null(xlim)) {
if (is.list(xlim)) {
xlimI <- xlim[[i]]
} else {
xlimI <- xlim
}
p <- p + scale_x_continuous(limits=xlimI)
}
#-----------------------------------------------------------------
if (!is.null(ylimT)) {
if (is.list(ylimT)) {
ylimI <- ylimT[[i]]
} else {
ylimI <- ylimT
}
p <- p + scale_y_continuous(limits=ylimI)
}
#-----------------------------------------------------------------
if (useDirectLabels) p <- directlabels::direct.label(p=p,
method=method)
#-----------------------------------------------------------------
## This needs to follow direct.label
#-----------------------------------------------------------------
p <- p + scale_colour_manual(values=colorI,
name=ifelse(is.null(labelPath), path,
labelPath))
p <- p + scale_linetype_manual(values=lineTypeI,
name=ifelse(is.null(labelPath),
path, labelPath))
ret[[i]] <- p
}
#-------------------------------------------------------------------
## --- Return ---
#-------------------------------------------------------------------
class(ret) <- c("plotSummaryAlphaPart", class(ret))
ret
}
#=======================================================================
# save
# ======================================================================
#' @title Save plot method for \code{AlphaPart}
#' @return Beside the side effect of saving plots to disk, filenames are printed on
#' screen during the process and at the end invisibly returned.
#' @param ... Arguments passed to \code{type} specific methods, say
#' \code{width} and \code{height} for \code{type="pdf"} etc.
#' @useDynLib AlphaPart, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#' @importFrom grDevices dev.cur
#' @importFrom grDevices dev.off
#' @export
savePlot <- function (...) {
UseMethod("savePlot")
}
#' @title Save plot objects on the disk for permanent storage. Function
#' \code{\link[grDevices]{savePlot}} from the \pkg{grDevices} package
#' works for current page on graphical device. This is an attempt to
#' make this function generic so that one can define \code{savePlot}
#' methods for particular needs.
#' @rdname savePlot.plotSummaryAlphaPart
#' @method savePlot plotSummaryAlphaPart
#' @usage \method{savePlot}{plotSummaryAlphaPart}(x, filename, type,
#' device, pre.hook, traitsAsDir, ...)
#' @aliases savePlot.plotSummaryAlphaPart
#'
#' @description Save plot objects of class
#' \code{plotSummaryAlphaPart} on the disk for permanent storage.
#'
#' @seealso \code{\link[grDevices]{savePlot}} help page on the default \code{savePlot}
#' method in the \pkg{grDevices} package; \code{\link[AlphaPart]{savePlot.plotSummaryAlphaPart}}
#' help page on the method for the objects of \code{plotSummaryAlphaPart} class; and
#' \code{\link[AlphaPart]{plot.summaryAlphaPart}} for ploting results of summaryAlphaPart object.
#'
#' @param x Object on which to chose savePLot method.
#' @param filename Character, filename to save to.
#' @param type Character, file/device type.
#' @param device Device, the device to save from.
#' @param pre.hook Function, call some code before calling print method for plots (see examples).
#' @param traitsAsDir Logical, should plots be saved within trait folders; the construction is
#' \code{file.path(dirname(file), trait, basename(file))}.
#' folders are created if they do not exist.
#' @param ... Arguments passed to \code{type} specific methods, say
#' \code{width} and \code{height} for \code{type="pdf"} etc.
#'
#' @example /inst/examples/examples_savePlot.plotsummaryAlphaPart.R
#'
#' @return Beside the side effect of saving plots to disk, filenames are printed on
#' screen during the process and at the end invisibly returned.
#'
#' @useDynLib AlphaPart, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#' @importFrom grDevices dev.cur
#' @importFrom grDevices dev.off
#' @export
savePlot.plotSummaryAlphaPart <- function(
x, ##<< plotSummaryAlphaPart, output object from
## \code{\link[AlphaPart]{plot.summaryAlphaPart}} function
filename=paste("Rplot", type, sep="."), ##<< character, filename to save to
type=c("pdf", "png", "jpeg", "tiff", "bmp"), ##<< character, file/device type
device=dev.cur(), ##<< device, the device to save from (not used for this method)
pre.hook=NULL, ##<<
traitsAsDir=FALSE, ##<<
... ##<<
) {
if (length(filename) > 1) stop("'filename' argument must be of length one")
if (!inherits(x, "plotSummaryAlphaPart")) stop("'x' must be of a 'plotSummaryAlphaPart' class")
filenameOrig <- sub(pattern=paste(".", type, "$", sep=""), replacement="", x=filename)
ret <- NULL
lT <- names(x)
for (i in seq_len(length(x))) {
if (traitsAsDir) {
dir.create(path=file.path(dirname(filenameOrig), lT[i]), recursive=TRUE, showWarnings=FALSE)
filename <- file.path(dirname(filenameOrig), lT[i], basename(filenameOrig))
}
fileA <- paste(filename, paste(lT[i], ".", type, sep=""), sep="_")
ret <- c(ret, fileA)
cat(fileA, "\n")
print(list(file=fileA, ...))
do.call(what=type, args=list(file=fileA, ...))
if (!is.null(pre.hook) && is.function(pre.hook)) pre.hook()
print(x[[i]])
dev.off()
}
#---------------------------------------------------------------------
## --- Return ---
#---------------------------------------------------------------------
invisible(ret)
}
#' @rdname savePlot.plotSummaryAlphaPart
#' @method savePlot default
#' @aliases savePlot.default
#' @export
savePlot.default <- function(...) {
##seealso<< \code{\link[grDevices]{savePlot}} help page on the default
## \code{savePlot} method in the \pkg{grDevices} package
grDevices::savePlot(...)
##value<< See \code{\link[grDevices]{savePlot}} for details.
}
#=======================================================================
# center base population
#=======================================================================
#' @title Calculate parent average for base population.
#' @description This is an internally called functions used to calculate
#' parent average for base population.
#'
#' @usage NULL
#'
#' @seealso
#' \code{\link[AlphaPart]{AlphaPart}}
#'
#' @author Thiago de Paula Oliveira
#'
#' @keywords internal
#' @importFrom stats lm confint
#' @export
centerPop <- function(y, colBV, path){
#---------------------------------------------------------------------
# Selecting founders and missing pedigree animals
#---------------------------------------------------------------------
colBV <- (ncol(y)-length(colBV)+1):ncol(y)
if(length(colBV)==1){
tmp <- as.matrix(y[c(y[, 2]==0 & y[,3]==0), colBV])
}else{
tmp <- y[c(y[, 2]==0 & y[,3]==0), colBV]
}
baseMean <- colMeans(tmp, na.rm = TRUE)
#---------------------------------------------------------------------
# Decision criteria
#---------------------------------------------------------------------
basePop <- apply(y[,c(2,3)]==0,1,all)
for (i in seq_len(ncol(tmp))){
if(all(confint(lm(tmp[,i] ~ 1), level=0.95)>0)){
path$w[-1,i] <- path$w[-1, i] - basePop * baseMean[i]
path$pa[-1, i] <- path$pa[-1, i] + basePop * y[, colBV[i]] -
path$w[-1, i] * basePop
}
}
return(path)
}
#=======================================================================
# Scaling EBVs
#=======================================================================
#' @title Scale EBVs for objects of the class summaryAlphaPart.
#' @description This is an internally called functions used to Scale
#' EBVs in respect to base population for objects of the class
#' \code{AlphaPart}.
#'
#' @usage NULL
#'
#' @seealso
#' \code{\link[AlphaPart]{AlphaPart}}
#'
#' @author Thiago de Paula Oliveira
#'
#' @keywords internal
#' @importFrom stats sd
#' @export
sEBV <- function(y, center, scale, recode, unknown){
id. <- 1
fid. <- 2
mid. <- 3
if (recode) {
y[,id.:mid.] <- cbind(id=seq_len(nrow(y)),
fid=match(y[, fid.], y[, id.], nomatch=0),
mid=match(y[, mid.], y[, id.], nomatch=0))
} else {
## Make sure we have 0 when recoded data is provided
if (is.na(unknown)) {
y[, c(fid., mid.)] <- NAToUnknown(x=y[, c(fid., mid.)], unknown=0)
} else {
if (unknown != 0) {
y[, c(fid., mid.)] <-
NAToUnknown(x=unknownToNA(x=y[, c(fid., mid.)],
unknown=unknown), unknown=0)
}
}
}
#---------------------------------------------------------------------
# Selecting founders and missing pedigree animals
#---------------------------------------------------------------------
if(ncol(y)==(mid.+1)){
tmp <- as.matrix(y[c(y[, fid.]==0 & y[, mid.]==0), -c(id.:mid.)])
y <- as.matrix(y[, -c(id.:mid.)])
}else{
tmp <- y[c(y[, fid.]==0 & y[, mid.]==0), -c(id.:mid.)]
y <- y[, -c(id.:mid.)]
}
#---------------------------------------------------------------------
# Centering
#---------------------------------------------------------------------
if(is.logical(center)){
if(center){
center <- colMeans(tmp, na.rm = TRUE)
y <- y -
rep(center, rep.int(nrow(y), ncol(y)))
}
}
#---------------------------------------------------------------------
# Scaling
#---------------------------------------------------------------------
if(is.logical(scale)){
if(scale) {
f <- function(x) {
sd(x, na.rm = TRUE)
}
scale <- apply(tmp, 2L, f)
y <- y /
rep(scale, rep.int(nrow(y), ncol(y)))
}
}
return(y)
}
#' @title Get scale information
#' @description This is an internally called function
#'
#' @usage NULL
#'
#' @seealso
#' \code{\link[AlphaPart]{AlphaPart}}
#'
#' @author Thiago de Paula Oliveira
#'
#' @keywords internal
#' @export
getScale <- function(center = FALSE, scale = FALSE, ...){
list(center = center, scale = scale, ...)
} | /scratch/gouwar.j/cran-all/cranData/AlphaPart/R/methods.R |
#' pedFixBirthYear.R
#'
#' A function to fix (impute) missing birth years in pedigree.
#'
#' @details
#' Warnings are issued when there is no information to use to impute birth years or missing
#' values (\code{NA}) are propagated.
#'
#' Arguments \code{down} and \code{na.rm} allow for repeated use of this function, i.e., with
#' \code{down=FALSE} and with \code{down=TRUE} (both in combination with \code{na.rm=TRUE}) in order to
#' propagate information over the pedigree until "convergence".
#'
#' This function can be very slow on large pedigrees with extensive missingness of birth years.
#'
#' @seealso
#' \code{\link[pedigree]{orderPed}} in \pkg{pedigree} package
#'
#' @param x data.frame , with (at least) the following columns: individual, father, and mother identification,
#' and year of birth; see arguments \code{colId},
#' \code{colFid}, \code{colMid}, and \code{colBY}
#' @param interval Numeric, a value for generation interval in years.
#' @param down Logical, the default is to impute birth years based on the birth year of children
#' starting from the youngest to the oldest individuals, while with \code{down=TRUE}
#' birth year is imputed based on the birth year of parents in the opposite order.
#' @param na.rm Logical, remove \code{NA} values when searching for the minimal (maximal) year of birth
#' in children (parents); setting this to \code{FALSE} can lead to decreased success of
#' imputation
#' @param sort Logical, initially sort \code{x} using \code{orderPed()} so that children follow
#' parents in order to make imputation as optimal as possible (imputation is performed
#' within a loop from the first to the last unknown birth year); at the end original
#' order is restored.
#' @param direct Logical, insert inferred birth years immediately so they can be used for successive
#' individuals within the loop.
#' @param report Logical, report success.
#' @param colId Numeric or character, position or name of a column holding individual identification.
#' @param colFid Numeric or character, position or name of a column holding father identification.
#' @param colMid Numeric or character, position or name of a column holding mother identification.
#' @param colBY Numeric or character, position or name of a column holding birth year.
#'
#' @example inst/examples/examples_pedFixBirthYear.R
#'
#' @return Object \code{x} with imputed birth years based on the birth year of children or parents.
#' If \code{report=TRUE} success is printed on the screen as the number of initially, fixed,
#' and left unknown birth years is printed.
#'
#' @useDynLib AlphaPart, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#'
#' @export
#' @importFrom pedigree orderPed
pedFixBirthYear <- function (x, interval, down=FALSE, na.rm=TRUE, sort=TRUE, direct=TRUE,
report=TRUE, colId=1, colFid=2, colMid=3, colBY=4) {
## TODO: Profile function with Rprof() - done one round of optimization - can it be done better?
##
## TODO: Can we add another loop (say via argument automatic=TRUE) to repeatedly call this function?
## The idea is to start say with down=FALSE then in next run with down=TRUE and so on.
## Would have to check if there is no progress between iterations to avoid infinite loop.
##
## TODO: subset data from the start to avoid excessive search and update the table at the end?
##
## TODO: data.table for "binary (indexed) search"?
## - http://datatable.r-forge.r-project.org/
## - https://docs.google.com/viewer?url=http%3A%2F%2Fdatatable.r-forge.r-project.org%2Fdatatable-faq.pdf
##
## TODO: sqldf (index?)
## --- Setup ---
test <- (length(colId) > 1 | length(colFid) > 1 | length(colMid) > 1 | length(colBY) > 1 | length(interval) > 1)
if (test) stop("arguments 'interval', 'colId', 'colFid', 'colMid', and 'colBY' must be of length 1")
## Sort so that children follow parents
if (sort) {
ordOrig <- rownames(x)
x <- x[order(orderPed(ped=x[, c(colId, colFid, colMid)])), ]
}
## --- Core ---
## Individuals with missing birth year
miss <- x[is.na(x[, colBY]), colId]
## miss <- miss[1:100] ## handy for Rprof()
nM <- length(miss)
## Setup list and functions regarding the source of information
if (!down) { ## from children - start from the youngest individual
miss <- rev(miss)
funF <- min
interval <- -interval
} else { ## from parents - start from the oldest individual
funF <- max
}
## Rprof()
## Loop
if (direct) {
k <- 0
for (i in miss) {
if (!down) { ## birth years of children
tmp <- x[x[, colMid] %in% i | x[, colFid] %in% i, colBY]
} else { ## collect birth years of parents
tmp <- x[x[, colId] %in% Reduce(f=c, x=x[x[, colId] %in% i, c(colFid, colMid)]), colBY]
}
if (length(tmp) > 0) {
tmp2 <- suppressWarnings(funF(tmp, na.rm=na.rm) + interval)
## suppressWarnings to avoid warnings about Inf when tmp <- c(NA) is passed to funF with na.rm=TRUE
if (is.na(tmp2) | is.infinite(tmp2)) {
warning(paste("missing value for id=", i, sep=""))
} else {
x[x[, colId] %in% i, colBY] <- tmp2
k <- k + 1
}
} else {
warning(paste("no information found for id=", i, sep=""))
}
}
} else {
ret <- vector(length=nM)
for (i in 1:nM) {
if (!down) { ## birth years of children
tmp <- x[x[, colMid] %in% miss[i] | x[, colFid] %in% miss[i], colBY]
} else { ## collect birth years of parents
tmp <- x[x[, colId] %in% Reduce(f=c, x=x[x[, colId] %in% miss[i], c(colFid, colMid)]), colBY]
}
if (length(tmp) > 0) {
ret[i] <- suppressWarnings(funF(tmp, na.rm=na.rm) + interval)
## suppressWarnings to avoid warnings about Inf when tmp <- c(NA) is passed to funF with na.rm=TRUE
} else {
warning(paste("no information found for id=", miss[i], sep=""))
}
}
ret[is.infinite(ret)] <- NA
tmp <- is.na(ret)
if (any(tmp)) {
warning(paste("missing value for id:", paste(miss[tmp], collate=", "), sep=""))
}
x <- merge(x=x, y=data.frame(.id=miss, .by=ret), by.x=colnames(x)[colId], by.y=".id", all.x=TRUE)
tmp <- is.na(x[, colBY]) & !is.na(x[, ".by"]) & x[, ".by"] != 0
k <- sum(tmp)
x[tmp, colBY] <- x[tmp, ".by"]
x[, ".by"] <- NULL
}
## Rprof(NULL)
## return(summaryRprof())
## --- Return ---
if (report) {
cat("Summary:\n")
cat(" - initially:", nM, "\n")
cat(" - fixed:", k, "\n")
cat(" - left:", nM - k, "\n")
}
if (sort) x <- x[ordOrig, ]
x
}
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/R/pedFixBirthYear.R |
#' pedSetBase.R
#'
#' A function to set the base population in the pedigree.
#'
#' @details
#' Base population in the pedigree is set by removing rows for some individuals, while their
#' presence as parents is also removed.
#'
#' Arguments \code{down} and \code{na.rm} allow for repeated use of this function, i.e., with
#' \code{down=FALSE} and with \code{down=TRUE} (both in combination with \code{na.rm=TRUE}) in order to
#' propagate information over the pedigree until "convergence".
#'
#' This function can be very slow on large pedigrees with extensive missingness of birth years.
#'
#' @seealso
#' \code{\link[pedigree]{orderPed}} in \pkg{pedigree} package
#'
#' @param x data.frame , with (at least) the following columns: individual, father, and mother identification,
#' and year of birth; see arguments \code{colId},
#' \code{colFid}, \code{colMid}, and \code{colBY}
#' @param keep Logical, indicator that defines which individuals should stay in the
#' the pedigree; see details.
#' @param unknown Value used to represent unknown/missing identification
#' @param report Logical, report success.
#' @param colId Numeric or character, position or name of a column holding individual identification.
#' @param colFid Numeric or character, position or name of a column holding father identification.
#' @param colMid Numeric or character, position or name of a column holding mother identification.
#'
#' @example inst/examples/examples_pedSetBase.R
#'
#' @return Object \code{x} with removed rows for some individuals and their presence as parents.
#' If \code{report=TRUE} progress is printed on the screen.
#'
#' @useDynLib AlphaPart, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#'
#' @export
pedSetBase <- function (x, keep=NULL, unknown=NA, report=TRUE, colId=1, colFid=2, colMid=3) {
## --- Setup ---
if (is.null(keep)) stop
test <- (length(colId) > 1 | length(colFid) > 1 | length(colMid) > 1)
if (test) stop("arguments 'colId', 'colFid', and 'colMid' must be of length 1")
n <- nrow(x)
test <- (length(keep) != n)
if (test) stop("the length of argument 'keep' must be the same as the number of entries (rows) in x")
## --- Action ---
if (report) {
cat("All individuals:", n, "\n")
cat("Removing: ", sum(!keep, na.rm=TRUE), ", ",
round(sum(!keep, na.rm=TRUE) / length(keep) * 100), " %\n", sep="")
}
rem <- x[!keep, colId]
ret <- x[keep, ]
ret[ret[, colFid] %in% rem & !isUnknown(x=ret[, colFid], unknown=unknown), colFid] <- unknown
ret[ret[, colMid] %in% rem & !isUnknown(x=ret[, colMid], unknown=unknown), colMid] <- unknown
if (report) cat("Kept:", nrow(ret), "\n")
## --- Return ---
ret
}
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/R/pedSetBase.R |
#' write.csv.R
#'
#' Save summaries of partitioned breeding values to CSV files on disk for further
#' analyses of processing with other software or just for saving (backing up)
#' results.
#'
#' Function \code{\link[utils]{write.csv}} from the \pkg{utils} package works
#' when exported object is a \code{\link[base]{data.frame}} or a
#' \code{\link[base]{matrix}}. This is an attempt to make this function generic
#' so that one can define \code{write.csv} methods for other objects.
#'
#' @seealso \code{\link[utils]{write.csv}} help page on the default \code{write.csv} and \code{write.csv2}
#' methods in the \pkg{utils} package;
#' \code{\link[AlphaPart]{summary.AlphaPart}} and \code{\link[AlphaPart]{AlphaPart}}
#' help pages on the objects of \code{summaryAlphaPart} and \code{AlphaPart} classes.
#'
#' @param x AlphaPart, object returned from \code{\link[AlphaPart]{AlphaPart}} function or
#' summaryAlphaPart, object returned from \code{\link[AlphaPart]{summary.AlphaPart}} function.
#' @param file Character, file name with or without .csv extension, e.g., both "file" and "file.csv" are valid.
#' @param traitsAsDir Logical, should results be saved within trait folders;
#' the construction is \code{file.path(dirname(file), trait, basename(file))};
#' folders are created if they do not exist.
#' @param csv2 Logical, export using \code{\link[utils]{write.csv2}} or \code{\link[utils]{write.csv}}.
#' @param row.names Logical, export row names as well?
#' @param ... Other options passed to \code{\link[utils]{write.csv2}} or \code{\link[utils]{write.csv}}.
#'
#' @example inst/examples/examples_write.csv.R
#'
#' @return It contains:
#'
#' * `write.csv` - see \code{\link[utils]{write.csv}} for details.
#' * `write.csv.AlphaPart` - for each trait (list component in \code{x}) a file
#' is saved on disk with name "AlphaPart_trait.csv", where the file will hold
#' original data and breeding value partitions. With \code{traitsAsDir=TRUE}
#' files are saved as "trait/file_trait.csv". File names are printed on screen
#' during the process of export and at the end invisibly returned.
#' * `write.csv.summaryAlphaPart` - for each trait (list component in \code{x})
#' a file partitions named "file_trait.csv" is saved on disk. With
#' \code{traitsAsDir=TRUE} files are saved as "trait/file_trait_*.csv". File
#' names are printed on screen during the process of export and at the end
#' invisibly returned.
#'
#' @useDynLib AlphaPart, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#' @importFrom utils write.csv2
#' @export
write.csv <- function (...) {
UseMethod("write.csv")
}
#' @describeIn write.csv Default \code{write.csv} method.
write.csv.default <- function (...) {
utils::write.csv(...)
}
#' @describeIn write.csv Save partitioned breeding values to CSV files on disk on disk for further
#' analyses or processing with other software or just for saving (backing up)
#' results.
#'
#' @export
write.csv.AlphaPart <- function (x, file, traitsAsDir=FALSE, csv2=TRUE, row.names=FALSE, ...) {
## --- Setup ---
if (length(file) > 1) stop("'file' argument must be of length one")
if (!inherits(x, "AlphaPart")) stop("'x' must be of a 'AlphaPart' class")
fileOrig <- sub(pattern=".csv$", replacement="", x=file)
ret <- NULL
## --- Code ---
for(i in 1:(length(x)-1)) { ## loop over traits
if(traitsAsDir) {
dir.create(path=file.path(dirname(fileOrig), x$info$lT[i]), recursive=TRUE, showWarnings=FALSE)
file <- file.path(dirname(fileOrig), x$info$lT[i], basename(fileOrig))
}
fileA <- paste(file, "_", x$info$lT[i], ".csv", sep="")
ret <- c(ret, fileA)
cat(fileA, "\n")
if(csv2) {
write.csv2(x=x[[i]], file=fileA, row.names=row.names, ...)
} else {
write.csv(x=x[[i]], file=fileA, row.names=row.names, ...)
}
}
## --- Return ---
invisible(ret)
}
#' @describeIn write.csv Save summaries of partitioned breeding values to CSV files on disk for further
#' analyses of processing with other software or just for saving (backing up)
#' results.
#'
#' @export
write.csv.summaryAlphaPart <- function (x, file, traitsAsDir=FALSE, csv2=TRUE, row.names=FALSE, ...) {
## --- Setup ---
if (length(file) > 1) stop("'file' argument must be of length one")
if (!inherits(x,"summaryAlphaPart")) stop("'x' must be of a 'summaryAlphaPart' class")
fileOrig <- sub(pattern=".csv$", replacement="", x=file)
ret <- NULL
## --- Code ---
for(i in 1:(length(x)-1)) { ## loop over traits
if(traitsAsDir) {
dir.create(path=file.path(dirname(fileOrig), x$info$lT[i]), recursive=TRUE, showWarnings=FALSE)
file <- file.path(dirname(fileOrig), x$info$lT[i], basename(fileOrig))
}
fileA <- paste(file, x$info$lT[i], ".csv", sep="_")
ret <- c(ret, fileA)
cat(fileA, "\n")
if(csv2) {
write.csv2(x=x[[i]], file=fileA, row.names=row.names, ...)
} else {
write.csv(x=x[[i]], file=fileA, row.names=row.names, ...)
}
}
## --- Return ---
invisible(ret)
}
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/R/write.csv.R |
### partAGV_deterministic.R
###-----------------------------------------------------------------------------
### $Id$
###-----------------------------------------------------------------------------
### DESCRIPTION OF A DEMONSTRATION
###-----------------------------------------------------------------------------
## A demonstration with a simple example to see in action the partitioning of
## additive genetic values by paths (Garcia-Cortes et al., 2008; Animal)
##
## DETERMINISTIC SIMULATION (sort of)
##
## We have two locations (1 and 2). The first location has individualss with higher
## additive genetic value. Males from the first location are imported males to the
## second location from generation 2/3. This clearly leads to genetic gain in the
## second location. However, the second location can also perform their own selection
## so the question is how much genetic gain is due to the import of genes from the
## first location and due to their own selection.
##
## Above scenario will be tested with a simple example of a pedigree bellow. Two
## scenarios will be evaluated: without or with own selection in the second location.
## Selection will always be present in the first location.
##
## Additive genetic values are provided, i.e., no inference is being done!
##
## The idea of this example is not to do extensive simulations, but just to have
## a simple example to see how the partitioning of additive genetic values works.
### SETUP
###-----------------------------------------------------------------------------
options(width=200)
### EXAMPLE PEDIGREE & SETUP OF MENDELIAN SAMPLING - "DETERMINISTIC"
###-----------------------------------------------------------------------------
## Generation 0
id0 <- c("01", "02", "03", "04")
fid0 <- mid0 <- rep(NA, times=length(id0))
h0 <- rep(c(1, 2), each=2)
g0 <- rep(0, times=length(id0))
w10 <- c( 2, 2, 0, 0)
w20 <- c( 2, 2, 0, 0)
## Generation 1
id1 <- c("11", "12", "13", "14")
fid1 <- c("01", "01", "03", "03")
mid1 <- c("02", "02", "04", "04")
h1 <- h0
g1 <- rep(1, times=length(id1))
w11 <- c( 0.6, 0.2, -0.6, 0.2)
w21 <- c( 0.6, 0.2, 0.6, 0.2)
## Generation 2
id2 <- c("21", "22", "23", "24")
fid2 <- c("12", "12", "12", "12")
mid2 <- c("11", "11", "13", "14")
h2 <- h0
g2 <- rep(2, times=length(id2))
w12 <- c( 0.6, 0.3, -0.2, 0.2)
w22 <- c( 0.6, 0.3, 0.2, 0.2)
## Generation 3
id3 <- c("31", "32", "33", "34")
fid3 <- c("22", "22", "22", "22")
mid3 <- c("21", "21", "23", "24")
h3 <- h0
g3 <- rep(3, times=length(id3))
w13 <- c( 0.7, 0.1, -0.3, 0.3)
w23 <- c( 0.7, 0.1, 0.3, 0.3)
## Generation 4
id4 <- c("41", "42", "43", "44")
fid4 <- c("32", "32", "32", "32")
mid4 <- c("31", "31", "33", "34")
h4 <- h0
g4 <- rep(4, times=length(id4))
w14 <- c( 0.8, 0.8, -0.1, 0.3)
w24 <- c( 0.8, 0.8, 0.1, 0.3)
## Generation 5
id5 <- c("51", "52", "53", "54")
fid5 <- c("42", "42", "42", "42")
mid5 <- c("41", "41", "43", "44")
h5 <- h0
g5 <- rep(5, times=length(id4))
w15 <- c( 0.8, 1.0, -0.2, 0.3)
w25 <- c( 0.8, 1.0, 0.2, 0.3)
ped <- data.frame( id=c( id0, id1, id2, id3, id4, id5),
fid=c(fid0, fid1, fid2, fid3, fid4, fid5),
mid=c(mid0, mid1, mid2, mid3, mid4, mid5),
loc=c( h0, h1, h2, h3, h4, h5),
gen=c( g0, g1, g2, g3, g4, g5),
w1=c( w10, w11, w12, w13, w14, w15),
w2=c( w20, w21, w22, w23, w24, w25))
ped$sex <- 2
ped[ped$id %in% ped$fid, "sex"] <- 1
ped$loc.gen <- with(ped, paste(loc, gen, sep="-"))
### SIMULATE ADDITIVE GENETIC VALUES - SUM PARENT AVERAGE AND MENDELIAN SAMPLING
###-----------------------------------------------------------------------------
## Additive genetic mean in founders by location
mu1 <- 2
mu2 <- 0
## Additive genetic variance in population
sigma2 <- 1
sigma <- sqrt(sigma2)
## Threshold value for Mendelian sampling for selection - only values above this
## will be accepted in simulation
t <- 0
ped$agv1 <- ped$pa1 <- NA ## Scenario (trait) 1: No selection in the second location
ped$agv2 <- ped$pa2 <- NA ## Scenario (trait) 2: Selection in the second location
## Generation 0 - founders (no parent average here - so setting it to zero)
ped[ped$gen == 0, c("pa1", "pa2")] <- 0
ped[ped$gen == 0, c("agv1", "agv2")] <- ped[ped$gen == 0, c("w1", "w2")]
## Generation 1+ - non-founders (parent average + Mendelian sampling)
for(i in (length(g0)+1):nrow(ped)) {
ped[i, "pa1"] <- 0.5 * (ped[ped$id %in% ped[i, "fid"], "agv1"] +
ped[ped$id %in% ped[i, "mid"], "agv1"])
ped[i, "pa2"] <- 0.5 * (ped[ped$id %in% ped[i, "fid"], "agv2"] +
ped[ped$id %in% ped[i, "mid"], "agv2"])
ped[i, c("agv1", "agv2")] <- ped[i, c("pa1", "pa2")] + ped[i, c("w1", "w2")]
}
### PLOT INDIVIDUAL ADDITIVE GENETIC VALUES
###-----------------------------------------------------------------------------
par(mfrow=c(2, 1), bty="l", pty="m", mar=c(2, 2, 1, 1) + .1, mgp=c(0.7, 0.2, 0))
tmp <- ped$gen + c(-1.5, -0.5, 0.5, 1.5) * 0.1
with(ped, plot(agv1 ~ tmp, pch=c(19, 21)[ped$loc], ylab="Additive genetic value",
xlab="Generation", main="Selection in location 1", axes=FALSE,
ylim=range(c(agv1, agv2))))
axis(1, labels=FALSE, tick=FALSE); axis(2, labels=FALSE, tick=FALSE); box()
legend(x="topleft", legend=c(1, 2), title="Location", pch=c(19, 21), bty="n")
with(ped, plot(agv2 ~ tmp, pch=c(19, 21)[ped$loc], ylab="Additive genetic value",
xlab="Generation", main="Selection in locations 1 and 2", axes=FALSE,
ylim=range(c(agv1, agv2))))
axis(1, labels=FALSE, tick=FALSE); axis(2, labels=FALSE, tick=FALSE); box()
legend(x="topleft", legend=c(1, 2), title="Location", pch=c(19, 21), bty="n")
### PARTITION ADDITIVE GENETIC VALUES BY ...
###-----------------------------------------------------------------------------
## Compute partitions by location
(res <- AlphaPart(x=ped, colPath="loc", colBV=c("agv1", "agv2")))
## Summarize whole population
(ret <- summary(res))
## Summarize and plot by generation (=trend)
(ret <- summary(res, by="gen"))
plot(ret)
## Summarize and plot location specific trends
(ret <- summary(res, by="loc.gen"))
plot(ret)
## Summarize and plot location specific trends but only for location 1
(ret <- summary(res, by="loc.gen", subset=res[[1]]$loc == 1))
plot(ret)
## Summarize and plot location specific trends but only for location 2
(ret <- summary(res, by="loc.gen", subset=res[[1]]$loc == 2))
plot(ret)
## Compute partitions by location and sex
ped$loc.sex <- with(ped, paste(loc, sex, sep="-"))
(res <- AlphaPart(x=ped, colPath="loc.sex", colBV=c("agv1", "agv2")))
## Summarize and plot by generation (=trend)
(ret <- summary(res, by="gen"))
plot(ret)
plot(ret, lineTypeList=list("-1"=1, "-2"=2, def=3))
## Summarize and plot location specific trends
(ret <- summary(res, by="loc.gen"))
plot(ret, lineTypeList=list("-1"=1, "-2"=2, def=3))
## Summarize and plot location specific trends but only for location 1
(ret <- summary(res, by="loc.gen", subset=res[[1]]$loc == 1))
plot(ret)
## Summarize and plot location specific trends but only for location 2
(ret <- summary(res, by="loc.gen", subset=res[[1]]$loc == 2))
plot(ret)
###-----------------------------------------------------------------------------
### AlphaPart_deterministic.R ends here
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/demo/AlphaPart_deterministic.R |
### AlphaPart_deterministic_MCMC.R
###-----------------------------------------------------------------------------
### $Id$
###-----------------------------------------------------------------------------
### DESCRIPTION OF A DEMONSTRATION
###-----------------------------------------------------------------------------
## A demonstration with a simple example to see in action the partitioning of
## additive genetic values by paths (Garcia-Cortes et al., 2008; Animal)
##
## DETERMINISTIC SIMULATION (sort of)
##
## We have two locations (1 and 2). The first location has individualss with higher
## additive genetic value. Males from the first location are imported males to the
## second location from generation 2/3. This clearly leads to genetic gain in the
## second location. However, the second location can also perform their own selection
## so the question is how much genetic gain is due to the import of genes from the
## first location and due to their own selection.
##
## Above scenario will be tested with a simple example of a pedigree bellow. Two
## scenarios will be evaluated: without or with own selection in the second location.
## Selection will always be present in the first location.
##
## Additive genetic values are provided, but also infered from the data using MCMC
## method to show how to use AlphaPart with MCMC results!
##
## The idea of this example is not to do extensive simulations, but just to have
## a simple example to see how the partitioning of additive genetic values works.
### SETUP
###-----------------------------------------------------------------------------
options(width=200)
### EXAMPLE PEDIGREE & SETUP OF MENDELIAN SAMPLING - "DETERMINISTIC"
###-----------------------------------------------------------------------------
## Generation 0
id0 <- c("01", "02", "03", "04")
fid0 <- mid0 <- rep(NA, times=length(id0))
h0 <- rep(c(1, 2), each=2)
g0 <- rep(0, times=length(id0))
w10 <- c( 2, 2, 0, 0)
w20 <- c( 2, 2, 0, 0)
## Generation 1
id1 <- c("11", "12", "13", "14")
fid1 <- c("01", "01", "03", "03")
mid1 <- c("02", "02", "04", "04")
h1 <- h0
g1 <- rep(1, times=length(id1))
w11 <- c( 0.6, 0.2, -0.6, 0.2)
w21 <- c( 0.6, 0.2, 0.6, 0.2)
## Generation 2
id2 <- c("21", "22", "23", "24")
fid2 <- c("12", "12", "12", "12")
mid2 <- c("11", "11", "13", "14")
h2 <- h0
g2 <- rep(2, times=length(id2))
w12 <- c( 0.6, 0.3, -0.2, 0.2)
w22 <- c( 0.6, 0.3, 0.2, 0.2)
## Generation 3
id3 <- c("31", "32", "33", "34")
fid3 <- c("22", "22", "22", "22")
mid3 <- c("21", "21", "23", "24")
h3 <- h0
g3 <- rep(3, times=length(id3))
w13 <- c( 0.7, 0.1, -0.3, 0.3)
w23 <- c( 0.7, 0.1, 0.3, 0.3)
## Generation 4
id4 <- c("41", "42", "43", "44")
fid4 <- c("32", "32", "32", "32")
mid4 <- c("31", "31", "33", "34")
h4 <- h0
g4 <- rep(4, times=length(id4))
w14 <- c( 0.8, 0.8, -0.1, 0.3)
w24 <- c( 0.8, 0.8, 0.1, 0.3)
## Generation 5
id5 <- c("51", "52", "53", "54")
fid5 <- c("42", "42", "42", "42")
mid5 <- c("41", "41", "43", "44")
h5 <- h0
g5 <- rep(5, times=length(id4))
w15 <- c( 0.8, 1.0, -0.2, 0.3)
w25 <- c( 0.8, 1.0, 0.2, 0.3)
ped <- data.frame( id=c( id0, id1, id2, id3, id4, id5),
fid=c(fid0, fid1, fid2, fid3, fid4, fid5),
mid=c(mid0, mid1, mid2, mid3, mid4, mid5),
loc=c( h0, h1, h2, h3, h4, h5),
gen=c( g0, g1, g2, g3, g4, g5),
w1=c( w10, w11, w12, w13, w14, w15),
w2=c( w20, w21, w22, w23, w24, w25))
ped$sex <- 2
ped[ped$id %in% ped$fid, "sex"] <- 1
ped$loc.gen <- with(ped, paste(loc, gen, sep="-"))
### SIMULATE ADDITIVE GENETIC VALUES - SUM PARENT AVERAGE AND MENDELIAN SAMPLING
###-----------------------------------------------------------------------------
## Additive genetic mean in founders by location
mu1 <- 2
mu2 <- 0
## Additive genetic variance in population
sigma2 <- 1
sigma <- sqrt(sigma2)
## Threshold value for Mendelian sampling for selection - only values above this
## will be accepted in simulation
t <- 0
ped$agv1 <- ped$pa1 <- NA ## Scenario (trait) 1: No selection in the second location
ped$agv2 <- ped$pa2 <- NA ## Scenario (trait) 2: Selection in the second location
## Generation 0 - founders (no parent average here - so setting it to zero)
ped[ped$gen == 0, c("pa1", "pa2")] <- 0
ped[ped$gen == 0, c("agv1", "agv2")] <- ped[ped$gen == 0, c("w1", "w2")]
## Generation 1+ - non-founders (parent average + Mendelian sampling)
for(i in (length(g0)+1):nrow(ped)) {
ped[i, "pa1"] <- 0.5 * (ped[ped$id %in% ped[i, "fid"], "agv1"] +
ped[ped$id %in% ped[i, "mid"], "agv1"])
ped[i, "pa2"] <- 0.5 * (ped[ped$id %in% ped[i, "fid"], "agv2"] +
ped[ped$id %in% ped[i, "mid"], "agv2"])
ped[i, c("agv1", "agv2")] <- ped[i, c("pa1", "pa2")] + ped[i, c("w1", "w2")]
}
## Recode identifications to 1:n
ped$ID <- seq_len(nrow(ped))
ped$FID <- match(ped$fid, ped$id)
ped$MID <- match(ped$mid, ped$id)
## pedigree object
ped2 <- with(ped, pedigree(sire=FID, dam=MID, label=ID))
### SIMULATE PHENOTYPES
###-----------------------------------------------------------------------------
mu <- 100
h2 <- 0.9 ## set high heritability as this is a small example with little info
sigma2 <- (sigma2 / h2) - sigma2
sigma <- sqrt(sigma2)
## Make repeated records to make pedigreemm() happy
dat <- rbind(ped, ped)
dat <- dat[order(dat$ID), ]
dat$y1 <- with(dat, round(rnorm(n=nrow(dat), mean=mu + agv1, sd=sigma), 1))
dat$y2 <- with(dat, round(rnorm(n=nrow(dat), mean=mu + agv2, sd=sigma), 1))
### PLOT INDIVIDUAL ADDITIVE GENETIC and PHENOTYPIC VALUES
###-----------------------------------------------------------------------------
par(mfrow=c(2, 2), bty="l", pty="m", mar=c(2, 2, 1, 1) + .1, mgp=c(0.7, 0.2, 0))
tmp <- ped$gen + seq(-1.5, 1.5, length=4) * 0.1
with(ped, plot(agv1 ~ tmp, pch=c(19, 21)[loc], ylab="Additive genetic value",
xlab="Generation", main="Selection in location 1", axes=FALSE,
ylim=range(c(agv1, agv2))))
axis(1, labels=FALSE, tick=FALSE); axis(2, labels=FALSE, tick=FALSE); box()
legend(x="topleft", legend=c(1, 2), title="Location", pch=c(19, 21), bty="n")
with(ped, plot(agv2 ~ tmp, pch=c(19, 21)[loc], ylab="Additive genetic value",
xlab="Generation", main="Selection in locations 1 and 2", axes=FALSE,
ylim=range(c(agv1, agv2))))
axis(1, labels=FALSE, tick=FALSE); axis(2, labels=FALSE, tick=FALSE); box()
legend(x="topleft", legend=c(1, 2), title="Location", pch=c(19, 21), bty="n")
tmp <- dat$gen + seq(-1.5, 1.5, length=8) * 0.1
with(dat, plot(y1 ~ tmp, pch=c(19, 21)[loc], ylab="Phenotypic value",
xlab="Generation", main="Selection in location 1", axes=FALSE,
ylim=range(c(y1, y2))))
axis(1, labels=FALSE, tick=FALSE); axis(2, labels=FALSE, tick=FALSE); box()
legend(x="topleft", legend=c(1, 2), title="Location", pch=c(19, 21), bty="n")
with(dat, plot(y2 ~ tmp, pch=c(19, 21)[loc], ylab="Phenotypic value",
xlab="Generation", main="Selection in locations 1 and 2", axes=FALSE,
ylim=range(c(y1, y2))))
axis(1, labels=FALSE, tick=FALSE); axis(2, labels=FALSE, tick=FALSE); box()
legend(x="topleft", legend=c(1, 2), title="Location", pch=c(19, 21), bty="n")
### INFER AGV VIA MCMC
###-----------------------------------------------------------------------------
## TODO: use MCMCglmm with fixed variances (make h2 high!)
fit1 <- pedigreemm(formula=y1 ~ (1 | ID), data=dat, pedigree=list(ID=ped2))
fit2 <- pedigreemm(formula=y2 ~ (1 | ID), data=dat, pedigree=list(ID=ped2))
par(mfrow=c(1, 2))
plot(ranef(fit1)$ID[, 1] ~ ped$agv1)
plot(ranef(fit2)$ID[, 1] ~ ped$agv2)
## TODO: is so bad correlation OK?
ranef(fit1, postVar=TRUE)
## Error in .local(object, ...) :
## code for applying pedigree and posterior variances not yet written
## TODO: check how postVar are obtained
## TODO: tell to Bates and Vasquez that this should not be needed as we need only diagonals
fit1MCMC <- mcmcsamp(fit1, n=1000, saveb=TRUE)
fit2MCMC <- mcmcsamp(fit2, n=1000, saveb=TRUE)
### PARTITION ADDITIVE GENETIC VALUES BY ...
###-----------------------------------------------------------------------------
## Compute partitions by location
(res <- AlphaPart(x=ped, colPath="loc", colBV=c("agv1", "agv2")))
## Summarize whole population
(ret <- summary(res))
## Summarize and plot by generation (=trend)
(ret <- summary(res, by="gen"))
plot(ret)
## Summarize and plot location specific trends
(ret <- summary(res, by="loc.gen"))
plot(ret)
## Summarize and plot location specific trends but only for location 1
(ret <- summary(res, by="loc.gen", subset=res[[1]]$loc == 1))
plot(ret)
## Summarize and plot location specific trends but only for location 2
(ret <- summary(res, by="loc.gen", subset=res[[1]]$loc == 2))
plot(ret)
## Compute partitions by location and sex
ped$loc.sex <- with(ped, paste(loc, sex, sep="-"))
(res <- AlphaPart(x=ped, colPath="loc.sex", colBV=c("agv1", "agv2")))
## Summarize and plot by generation (=trend)
(ret <- summary(res, by="gen"))
plot(ret)
plot(ret, lineTypeList=list("-1"=1, "-2"=2, def=3))
## Summarize and plot location specific trends
(ret <- summary(res, by="loc.gen"))
plot(ret, lineTypeList=list("-1"=1, "-2"=2, def=3))
## Summarize and plot location specific trends but only for location 1
(ret <- summary(res, by="loc.gen", subset=res[[1]]$loc == 1))
plot(ret)
## Summarize and plot location specific trends but only for location 2
(ret <- summary(res, by="loc.gen", subset=res[[1]]$loc == 2))
plot(ret)
###-----------------------------------------------------------------------------
### AlphaPart_deterministic_MCMC.R ends here
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/demo/AlphaPart_deterministic_MCMC.R |
### demo_stohastic.R
###-----------------------------------------------------------------------------
### $Id$
###-----------------------------------------------------------------------------
### DESCRIPTION OF A DEMONSTRATION
###-----------------------------------------------------------------------------
## A demonstration with a simple example to see in action the partitioning of
## additive genetic values by paths (Garcia-Cortes et al., 2008; Animal)
##
## STOHASTIC SIMULATION (sort of)
##
## We have two locations (1 and 2). The first location has individualss with higher
## additive genetic value. Males from the first location are imported males to the
## second location from generation 2/3. This clearly leads to genetic gain in the
## second location. However, the second location can also perform their own selection
## so the question is how much genetic gain is due to the import of genes from the
## first location and due to their own selection.
##
## Above scenario will be tested with a simple example of a pedigree bellow. Two
## scenarios will be evaluated: without or with own selection in the second location.
## Selection will always be present in the first location.
##
## Additive genetic values are provided, i.e., no inference is being done!
##
## The idea of this example is not to do extensive simulations, but just to have
## a simple example to see how the partitioning of additive genetic values works.
### SETUP
###-----------------------------------------------------------------------------
options(width=200)
## install.packages(pkg=c("truncnorm"), dep=TRUE)
library(package="truncnorm")
### EXAMPLE PEDIGREE
###-----------------------------------------------------------------------------
## Generation 0
id0 <- c("01", "02", "03", "04", "05", "06", "07", "08")
fid0 <- mid0 <- rep(NA, times=length(id0))
h0 <- rep(c(1, 2), each=4)
g0 <- rep(0, times=length(id0))
## Generation 1
id1 <- c("11", "12", "13", "14", "15", "16", "17", "18")
fid1 <- c("02", "02", "02", "02", "06", "06", "06", "06")
mid1 <- c("01", "01", "03", "04", "05", "05", "07", "08")
h1 <- h0
g1 <- rep(1, times=length(id1))
## Generation 2
id2 <- c("21", "22", "23", "24", "25", "26", "27", "28")
fid2 <- c("13", "13", "13", "13", "13", "13", "13", "13")
mid2 <- c("11", "12", "14", "14", "15", "16", "17", "18")
h2 <- h0
g2 <- rep(2, times=length(id2))
## Generation 3
id3 <- c("31", "32", "33", "34", "35", "36", "37", "38")
fid3 <- c("24", "24", "24", "24", "24", "24", "24", "24")
mid3 <- c("21", "21", "22", "23", "25", "26", "27", "28")
h3 <- h0
g3 <- rep(3, times=length(id3))
## Generation 4
id4 <- c("41", "42", "43", "44", "45", "46", "47", "48")
fid4 <- c("34", "34", "34", "34", "34", "34", "34", "34")
mid4 <- c("31", "32", "32", "33", "35", "36", "37", "38")
h4 <- h0
g4 <- rep(4, times=length(id4))
## Generation 5
id5 <- c("51", "52", "53", "54", "55", "56", "57", "58")
fid5 <- c("44", "44", "44", "44", "44", "44", "44", "44")
mid5 <- c("41", "42", "43", "43", "45", "46", "47", "48")
h5 <- h0
g5 <- rep(5, times=length(id4))
ped <- data.frame( id=c( id0, id1, id2, id3, id4, id5),
fid=c(fid0, fid1, fid2, fid3, fid4, fid5),
mid=c(mid0, mid1, mid2, mid3, mid4, mid5),
loc=c( h0, h1, h2, h3, h4, h5),
gen=c( g0, g1, g2, g3, g4, g5))
ped$sex <- 2
ped[ped$id %in% ped$fid, "sex"] <- 1
ped$loc.gen <- with(ped, paste(loc, gen, sep="-"))
### SIMULATE ADDITIVE GENETIC VALUES - STOHASTIC
###-----------------------------------------------------------------------------
## --- Parameters of simulation ---
## Additive genetic mean in founders by location
mu1 <- 2
mu2 <- 0
## Additive genetic variance in population
sigma2 <- 1
sigma <- sqrt(sigma2)
## Threshold value for Mendelian sampling for selection - only values above this
## will be accepted in simulation
t <- 0
## Set seed for simulation
set.seed(seed=19791123)
## --- Start of simulation ---
ped$agv1 <- NA ## Scenario (trait) 1: No selection in the second location
ped$agv2 <- NA ## Scenario (trait) 2: Selection in the second location
## Generation 0 - founders (for simplicity set their values to the mean of location)
ped[ped$gen == 0 & ped$loc == 1, c("agv1", "agv2")] <- mu1
ped[ped$gen == 0 & ped$loc == 2, c("agv1", "agv2")] <- mu2
## Generation 1+ - non-founders
for(i in (length(g0)+1):nrow(ped)) {
## Scenario (trait) 1: selection only in the first location
if(ped[i, "loc"] == 1) {
w <- rtruncnorm(n=1, mean=0, sd=sqrt(sigma2/2), a=t)
} else {
w <- rnorm(n=1, mean=0, sd=sqrt(sigma2/2))
}
ped[i, "agv1"] <- round(0.5 * ped[ped$id %in% ped[i, "fid"], "agv1"] +
0.5 * ped[ped$id %in% ped[i, "mid"], "agv1"] +
w, digits=1)
## Scenario (trait) 2: selection in both locations
if(ped[i, "loc"] == 2) {
w <- rtruncnorm(n=1, mean=0, sd=sqrt(sigma2/2), a=t)
} ## for location 1 take the same values as above
ped[i, "agv2"] <- round(0.5 * ped[ped$id %in% ped[i, "fid"], "agv2"] +
0.5 * ped[ped$id %in% ped[i, "mid"], "agv2"] +
w, digits=1)
}
### PLOT INDIVIDUAL ADDITIVE GENETIC VALUES
###-----------------------------------------------------------------------------
par(mfrow=c(2, 1), bty="l", pty="m", mar=c(2, 2, 1, 1) + .1, mgp=c(0.7, 0.2, 0))
tmp <- ped$gen + c(-1.5, -0.5, 0.5, 1.5) * 0.1
with(ped, plot(agv1 ~ tmp, pch=c(19, 21)[ped$loc], ylab="Additive genetic value",
xlab="Generation", main="Selection in location 1", axes=FALSE,
ylim=range(c(agv1, agv2))))
axis(1, labels=FALSE, tick=FALSE); axis(2, labels=FALSE, tick=FALSE); box()
legend(x="topleft", legend=c(1, 2), title="Location", pch=c(19, 21), bty="n")
with(ped, plot(agv2 ~ tmp, pch=c(19, 21)[ped$loc], ylab="Additive genetic value",
xlab="Generation", main="Selection in locations 1 and 2", axes=FALSE,
ylim=range(c(agv1, agv2))))
axis(1, labels=FALSE, tick=FALSE); axis(2, labels=FALSE, tick=FALSE); box()
legend(x="topleft", legend=c(1, 2), title="Location", pch=c(19, 21), bty="n")
### PARTITION ADDITIVE GENETIC VALUES BY ...
###-----------------------------------------------------------------------------
## Compute partitions by location
(res <- AlphaPart(x=ped, colPath="loc", colBV=c("agv1", "agv2")))
## Summarize whole population
(ret <- summary(res))
## Summarize and plot by generation (=trend)
(ret <- summary(res, by="gen"))
plot(ret)
## Summarize and plot location specific trends
(ret <- summary(res, by="loc.gen"))
plot(ret)
## Summarize and plot location specific trends but only for location 1
(ret <- summary(res, by="loc.gen", subset=res[[1]]$loc == 1))
plot(ret)
## Summarize and plot location specific trends but only for location 2
(ret <- summary(res, by="loc.gen", subset=res[[1]]$loc == 2))
plot(ret)
## Compute partitions by location and sex
ped$loc.sex <- with(ped, paste(loc, sex, sep="-"))
(res <- AlphaPart(x=ped, colPath="loc.sex", colBV=c("agv1", "agv2")))
## Summarize and plot by generation (=trend)
(ret <- summary(res, by="gen"))
plot(ret)
plot(ret, lineTypeList=list("-1"=1, "-2"=2, def=3))
## Summarize and plot location specific trends
(ret <- summary(res, by="loc.gen"))
plot(ret, lineTypeList=list("-1"=1, "-2"=2, def=3))
## Summarize and plot location specific trends but only for location 1
(ret <- summary(res, by="loc.gen", subset=res[[1]]$loc == 1))
plot(ret)
## Summarize and plot location specific trends but only for location 2
(ret <- summary(res, by="loc.gen", subset=res[[1]]$loc == 2))
plot(ret)
###-----------------------------------------------------------------------------
### demo_stohastic.R ends here
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/demo/AlphaPart_stochastic.R |
## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(echo = TRUE, fig.height = 6, fig.width = 6)
## ---- message=FALSE-----------------------------------------------------------
#=======================================================================
# Packges
#=======================================================================
#devtools::install_github("AlphaGenes/AlphaPart")
library(AlphaPart)
library(dplyr)
library(ggplot2)
library(ggridges)
## -----------------------------------------------------------------------------
#=======================================================================
# Reading and organizing Scenario 1
#=======================================================================
data <- readRDS("./../inst/extdata/AlphaPartCattleSim.rds") %>%
dplyr::mutate(across(generation:mother, as.numeric)) %>%
dplyr::rename(status = type) %>%
dplyr::mutate(across(c("sex", "status"), as.factor)) %>%
dplyr::mutate(path = interaction(sex,status, sep = ":")) %>%
arrange(generation, ind) %>%
select(ind, father, mother, sex, status, path, generation, tbv, pheno) %>%
dplyr::mutate(generation = generation - 20) %>%
droplevels()
# Data head
head(data) %>%
knitr::kable(digits = 2)
# Data size
dim(data)
## -----------------------------------------------------------------------------
part <- AlphaPart(data, colId = "ind", colFid = "father",
colMid = "mother", colBV = "tbv", colPath = "path")
head(part$tbv) %>%
knitr::kable(digits = 2)
## -----------------------------------------------------------------------------
# Trends in the additve genetic mean
partMean <- summary(part, by = "generation", FUN = mean)
head(partMean$tbv) %>%
knitr::kable(digits = 2)
## -----------------------------------------------------------------------------
# Trends in the additive genetic variance
partVar <- summary(part, by = "generation", FUN = var, cov = TRUE)
head(partVar$tbv) %>%
knitr::kable(digits = 2)
## ---- fig.height = 10, fig.width=9--------------------------------------------
part$tbv %>%
ggplot(aes(y = as.factor(generation), `tbv_F:Non-Selected`)) +
geom_density_ridges(
aes(fill = "F - Non-Selected", linetype = "F - Non-Selected"),
alpha = .4, point_alpha = 1, rel_min_height = 0.01
) +
geom_density_ridges(
aes(y = as.factor(generation), x= `tbv_M:Non-Selected`, fill = "M - Non-Selected",
linetype = "M - Non-Selected"),
alpha = .4, point_alpha = 1, rel_min_height = 0.01
) +
geom_density_ridges(
aes(y = as.factor(generation), x= `tbv_M:Selected`, fill = "M - Selected",
linetype = "M - Selected"),
alpha = .4, point_alpha = 1, rel_min_height = 0.01
) +
geom_density_ridges(
aes(y = as.factor(generation), x= `tbv`,
fill = "Sum", linetype = "Sum"),
alpha = .4, point_alpha = 1, rel_min_height = 0.01
) +
ylab("Generation") +
xlab("Density plot of breeding value partitions") +
labs(fill = "Path:", linetype = "Path:") +
theme_bw(base_size = 20) +
theme(
legend.position = "top"
)
## -----------------------------------------------------------------------------
partMean$tbv %>%
ggplot(aes(y = Sum, x = generation, colour = "Sum"),
size = 0.1) +
scale_linetype_manual(
values = c("solid", "longdash", "dashed", "dotted"))+
geom_line() +
geom_line(aes(y = `F:Non-Selected`, x = generation,
colour = "F"), alpha = 0.8) +
geom_line(aes(y = `M:Selected`, x = generation,
colour = "M(S)"), alpha = 0.8) +
geom_line(aes(y = `M:Non-Selected`, x = generation,
colour = "M(N)"), alpha = 0.8) +
geom_vline(xintercept = 0, linetype = 2, alpha = 0.3) +
ylab("Genetic Mean") +
xlab("Generation") +
labs(colour = "Path:") +
theme_bw(base_size = 18) +
theme(legend.position = "top")
## -----------------------------------------------------------------------------
partVar$tbv %>%
ggplot(aes(y = Sum, x = generation, colour = "Sum")) +
geom_line() +
geom_line(aes(y = `F:Non-Selected`, x = generation,
colour = "F"), alpha = 0.8) +
geom_line(aes(y = `F:Non-SelectedM:Selected`, x = generation,
colour = "F:M(S)"), size =0.5, alpha =0.8) +
geom_line(aes(y = `F:Non-SelectedM:Non-Selected`, x = generation,
colour = "F:M(N)"), size =0.5, alpha =0.6) +
geom_line(aes(y = `M:Non-SelectedM:Selected`, x = generation,
colour = "M(N):M(S)"), size =0.5, alpha =0.6) +
geom_line(aes(y = `M:Selected`, x = generation,
colour = "M(S)"), alpha = 0.8) +
geom_line(aes(y = `M:Non-Selected`, x = generation,
colour = "M(N)"), size =0.5, alpha =0.8) +
geom_vline(xintercept = 0, linetype = 2, alpha = 0.3) +
ylab("Genetic Variance") +
xlab("Generation") +
labs(colour = "Path: ") +
theme_bw(base_size = 18) +
theme(
legend.position = "top"
)
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/inst/doc/alphapart-variance.R |
---
title: "Partitioning genetic trends in mean and variance"
author: "Gregor Gorjanc, Jana Obsteter, Thiago de Paula Oliveira"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{PartitioningVariance}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.height = 6, fig.width = 6)
```
In breeding programmes, the observed genetic change is a sum of the contributions of different groups of individuals. Here we show how to partition the genetic mean and variance of breeding values using AlphaPart.
In addition to the contribution of paths to changes in genetic mean, breeding programmes should also consider analysing changes in genetic variance to understand the drivers of genetic change in a population fully. Managing the change in genetic mean and variance in breeding programmes is essential to ensure long-term genetic gain.
# Loading packages
```{r, message=FALSE}
#=======================================================================
# Packges
#=======================================================================
#devtools::install_github("AlphaGenes/AlphaPart")
library(AlphaPart)
library(dplyr)
library(ggplot2)
library(ggridges)
```
# Loading datafile
```{r}
#=======================================================================
# Reading and organizing Scenario 1
#=======================================================================
data <- readRDS("./../inst/extdata/AlphaPartCattleSim.rds") %>%
dplyr::mutate(across(generation:mother, as.numeric)) %>%
dplyr::rename(status = type) %>%
dplyr::mutate(across(c("sex", "status"), as.factor)) %>%
dplyr::mutate(path = interaction(sex,status, sep = ":")) %>%
arrange(generation, ind) %>%
select(ind, father, mother, sex, status, path, generation, tbv, pheno) %>%
dplyr::mutate(generation = generation - 20) %>%
droplevels()
# Data head
head(data) %>%
knitr::kable(digits = 2)
# Data size
dim(data)
```
* ```ind``` - individual
* ```father``` and ```mother``` - individual's parents
* ```sex``` - individual sex
* ```status``` - if the individual is or not selected
* ```path``` - the path variable used to partition the additive genetic mean
* ```tbv``` - true breeding value
* ```pheno``` - phenotypic value
# Partitioning trends in genetic mean and variance
We use the `AlphaPart` function to partition the true breeding values `(tbv)` in the `data` by the animal sex and status variable combination into females (F) and males (M) non-selected (N) and males selected (S) contributions:
```{r}
part <- AlphaPart(data, colId = "ind", colFid = "father",
colMid = "mother", colBV = "tbv", colPath = "path")
head(part$tbv) %>%
knitr::kable(digits = 2)
```
We use the generic `summary.AlphaPart` function to summarize an `AlphaPart` object by generation, con*sering:
* the function **mean**
```{r}
# Trends in the additve genetic mean
partMean <- summary(part, by = "generation", FUN = mean)
head(partMean$tbv) %>%
knitr::kable(digits = 2)
```
* the function **variance**
```{r}
# Trends in the additive genetic variance
partVar <- summary(part, by = "generation", FUN = var, cov = TRUE)
head(partVar$tbv) %>%
knitr::kable(digits = 2)
```
## Example of plots to analyse the results
Distribution of breeding value partitions by sex and selection status (selected males (M(S)), non-selected males (M(N)), and
females (F)) over generations.
```{r, fig.height = 10, fig.width=9}
part$tbv %>%
ggplot(aes(y = as.factor(generation), `tbv_F:Non-Selected`)) +
geom_density_ridges(
aes(fill = "F - Non-Selected", linetype = "F - Non-Selected"),
alpha = .4, point_alpha = 1, rel_min_height = 0.01
) +
geom_density_ridges(
aes(y = as.factor(generation), x= `tbv_M:Non-Selected`, fill = "M - Non-Selected",
linetype = "M - Non-Selected"),
alpha = .4, point_alpha = 1, rel_min_height = 0.01
) +
geom_density_ridges(
aes(y = as.factor(generation), x= `tbv_M:Selected`, fill = "M - Selected",
linetype = "M - Selected"),
alpha = .4, point_alpha = 1, rel_min_height = 0.01
) +
geom_density_ridges(
aes(y = as.factor(generation), x= `tbv`,
fill = "Sum", linetype = "Sum"),
alpha = .4, point_alpha = 1, rel_min_height = 0.01
) +
ylab("Generation") +
xlab("Density plot of breeding value partitions") +
labs(fill = "Path:", linetype = "Path:") +
theme_bw(base_size = 20) +
theme(
legend.position = "top"
)
```
Partitions of genetic mean and variance by sex and selection status (selected males (M(S)), non-selected males (M(N)), and females (F)) using true breeding values:
```{r}
partMean$tbv %>%
ggplot(aes(y = Sum, x = generation, colour = "Sum"),
size = 0.1) +
scale_linetype_manual(
values = c("solid", "longdash", "dashed", "dotted"))+
geom_line() +
geom_line(aes(y = `F:Non-Selected`, x = generation,
colour = "F"), alpha = 0.8) +
geom_line(aes(y = `M:Selected`, x = generation,
colour = "M(S)"), alpha = 0.8) +
geom_line(aes(y = `M:Non-Selected`, x = generation,
colour = "M(N)"), alpha = 0.8) +
geom_vline(xintercept = 0, linetype = 2, alpha = 0.3) +
ylab("Genetic Mean") +
xlab("Generation") +
labs(colour = "Path:") +
theme_bw(base_size = 18) +
theme(legend.position = "top")
```
```{r}
partVar$tbv %>%
ggplot(aes(y = Sum, x = generation, colour = "Sum")) +
geom_line() +
geom_line(aes(y = `F:Non-Selected`, x = generation,
colour = "F"), alpha = 0.8) +
geom_line(aes(y = `F:Non-SelectedM:Selected`, x = generation,
colour = "F:M(S)"), size =0.5, alpha =0.8) +
geom_line(aes(y = `F:Non-SelectedM:Non-Selected`, x = generation,
colour = "F:M(N)"), size =0.5, alpha =0.6) +
geom_line(aes(y = `M:Non-SelectedM:Selected`, x = generation,
colour = "M(N):M(S)"), size =0.5, alpha =0.6) +
geom_line(aes(y = `M:Selected`, x = generation,
colour = "M(S)"), alpha = 0.8) +
geom_line(aes(y = `M:Non-Selected`, x = generation,
colour = "M(N)"), size =0.5, alpha =0.8) +
geom_vline(xintercept = 0, linetype = 2, alpha = 0.3) +
ylab("Genetic Variance") +
xlab("Generation") +
labs(colour = "Path: ") +
theme_bw(base_size = 18) +
theme(
legend.position = "top"
)
```
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/inst/doc/alphapart-variance.Rmd |
## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/inst/doc/alphapart-vignette.R |
---
title: "AlphaPart - R implementation of the method for partitioning genetic trends"
description: >
Learn how to get started with the basics of AlphaPart.
author: "Gregor Gorjanc, Jana Obsteter, Thiago de Paula Oliveira"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{AlphaPart}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
## AlphaPart
AlphaPart is an R package available from CRAN repository at https://CRAN.R-project.org/package=AlphaPart. It consists of the main function AlphaPart for partitioning breeding values and auxiliary functions for manipulating data and summarizing, visualizing, and saving results. The package includes an example dataset AlphaPart.ped, which includes a four-generation pedigree and information about the generation, country, gender, and breeding values. Below we describe and demonstrate the functions with the dataset.
We install and load the package with:
install.packages(pkg = “AlphaPart”)
library(package = "AlphaPart")
We use the `AlphaPart` function to partition breeding values `(bv1)` in the `AlphaPart.ped` by the country variable into domestic and import contributions:
data(AlphaPart.ped)
part <- AlphaPart(x = AlphaPart.ped,
colPath = “country”,
colBV = “bv1”)
The partitioning function `AlphaPart` requires a data frame holding pedigree with animal/sire/dam or animal/sire/maternal-grandsire, a time-ordering variable such as year of birth, partition variable (path), and breeding values. Following the method described in García-Cortés et al. (2008), we recurse the pedigree from the oldest to the youngest individuals, for each individual calculate parent average and Mendelian sampling terms for any number of traits and assign terms to paths. We partition multiple traits by specifying a vector of variables, say colBV = c(“bv1”, “bv2”). The multiple trait option can also serve to partition samples from a posterior distribution to quantify uncertainty (Sorensen et al., 1994; Škorput et al., 2015). To speed-up calculations we use C++ and trait-vectorised partitioning. The function can also directly partition and summarize path contributions “on-the-fly”, which is a useful computational speed-up for huge pedigrees. The output object of the function is either `AlphaPart` or `summaryAlphaPart` class.
We use the generic `summary.AlphaPart` function to summarize an `AlphaPart` object by a grouping variable, say generation `(gen)`:
sumPartByGen <- summary(part, by = “gen”)
print(sumPartByGen)
The `summary` function summarizes breeding values and their path partitions by levels of grouping variable. By default, we summarize with a mean, but the user can specify any R function via the FUN argument. The summary function can also summarize only a subset of the object via the subset argument.
We use the generic `plot.summaryAlphaPart` function to plot summarized partitions:
plot(sumPartByGen)
We provide a number of utility functions that ease partitioning analysis. With the `pedFixBirthYear` function we impute missing or fix erroneous years of birth. With the `pedSetBase` function we set the base population by specifying founders and removing older pedigree records. With the `AlphaPartSubset` function we keep partitions for specified paths in the `AlphaPart` or `summaryAlphaPart` objects. With the `AlphaPartSum` function we sum the partitions of several paths in a `summaryAlphaPart` object. The `AlphaPartSubset` and `AlphaPartSum` functions simplify the presentation of partitioning analysis.
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/inst/doc/alphapart-vignette.Rmd |
## Small pedigree with additive genetic (=breeding) values
ped <- data.frame( id=c( 1, 2, 3, 4, 5, 6),
fid=c( 0, 0, 2, 0, 4, 0),
mid=c( 0, 0, 1, 0, 3, 3),
loc=c("A", "B", "A", "B", "A", "A"),
gen=c( 1, 1, 2, 2, 3, 3),
trt1=c(100, 120, 115, 130, 125, 125),
trt2=c(100, 110, 105, 100, 85, 110))
## Partition additive genetic values
tmp <- AlphaPart(x=ped, colBV=c("trt1", "trt2"))
print(tmp)
## Summarize by generation (genetic mean)
summary(tmp, by="gen")
## Summarize by generation (genetic variance)
summary(tmp, by="gen", FUN = var)
\donttest{
## There are also two demos
demo(topic="AlphaPart_deterministic", package="AlphaPart",
ask=interactive())
demo(topic="AlphaPart_stochastic", package="AlphaPart",
ask=interactive())
}
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/inst/examples/examples_AlphaPart.R |
## Small pedigree with additive genetic (=breeding) values
ped <- data.frame( id=c( 1, 2, 3, 4, 5, 6),
fid=c( 0, 0, 2, 0, 4, 0),
mid=c( 0, 0, 1, 0, 3, 3),
loc=c("A", "B", "A", "B", "A", "A"),
gen=c( 1, 1, 2, 2, 3, 3),
trt1=c(100, 120, 115, 130, 125, 125),
trt2=c(100, 110, 105, 100, 85, 110))
## Partition additive genetic values
(tmp <- AlphaPart(x=ped, colBV=c("trt1", "trt2")))
## Keep some partitions (working on object of class AlphaPart)
(tmp2 <- AlphaPartSubset(x=tmp, paths="A"))
## Summarize by generation
(tmpS <- summary(tmp, by="gen"))
## Keep some partitions (working on object of class summaryAlphaPart)
(tmpS2 <- AlphaPartSubset(x=tmpS, paths="A"))
## ... must be equal to
(tmpS3 <- summary(tmp2, by="gen"))
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/inst/examples/examples_AlphaPartSubset.R |
## Small pedigree with additive genetic (=breeding) values
ped <- data.frame( id=c( 1, 2, 3, 4, 5, 6),
fid=c( 0, 0, 2, 0, 4, 0),
mid=c( 0, 0, 1, 0, 3, 3),
loc=c("A", "B", "A", "B", "A", "A"),
gen=c( 1, 1, 2, 2, 3, 3),
trt1=c(100, 120, 115, 130, 125, 125),
trt2=c(100, 110, 105, 140, 85, 110))
## Partition additive genetic values
(tmp <- AlphaPart(x=ped, colBV=c("trt1", "trt2")))
## Sum some partitions (working on object of class AlphaPart)
(tmp2 <- AlphaPartSum(x=tmp, map=list(c("X", "A", "B"), c("A", "B"))))
## Summarize by generation
(tmpS <- summary(tmp, by="gen"))
## Sum some partitions (working on object of class summaryAlphaPart)
(tmpS2 <- AlphaPartSum(x=tmpS, map=list(c("X", "A", "B"), c("A", "B"))))
## ... must be equal to
(tmpS3 <- summary(tmp2, by="gen"))
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/inst/examples/examples_AlphaPartSum.R |
## Example pedigree with missing (unknown) birth year for some individuals
ped0 <- data.frame( id=c( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14),
fid=c( 0, 0, 0, 1, 1, 1, 3, 3, 3, 5, 4, 0, 0, 12),
mid=c( 0, 0, 0, 2, 0, 2, 2, 2, 5, 0, 0, 0, 0, 13),
birth_dt=c(NA, 0, 1, NA, 3, 3, 3, 3, 4, 4, 5, NA, 6, 6) + 2000)
## First run - using information from children
ped1 <- pedFixBirthYear(x=ped0, interval=1)
## Second run - using information from parents
ped2 <- pedFixBirthYear(x=ped1, interval=1, down=TRUE)
## Third run - using information from children, but with no success
ped3 <- pedFixBirthYear(x=ped2, interval=1)
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/inst/examples/examples_pedFixBirthYear.R |
## Example pedigree
ped <- data.frame( id=1:10,
fid=c(0, 0, 0, 1, 1, 1, 3, 3, 3, 5),
mid=c(0, 0, 0, 2, 0, 2, 2, 2, 5, 0),
birth_dt=c(0, 0, 1, 2, 3, 3, 3, 4, 4, 5) + 2000)
## Set base population as those individuals that were born after year 2002
pedSetBase(x=ped, keep=ped$birth_dt > 2002, unknown=0)
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/inst/examples/examples_pedSetBase.R |
\donttest{
## Partition additive genetic values by country
(res <- AlphaPart(x=AlphaPart.ped, colPath="country", colBV=c("bv1", "bv2")))
## Summarize population by generation (=trend)
(ret <- summary(res, by="gen"))
## Plot the partitions
p <- plot(ret, ylab=c("bv for trait 1", "bv for trait 2"), xlab="Generation")
print(p[[1]]$abs)
print(p[[2]]$abs)
print(p)
## Partition additive genetic values by country and sex
AlphaPart.ped$country.gender <- with(AlphaPart.ped, paste(country, gender, sep="-"))
(res <- AlphaPart(x=AlphaPart.ped, colPath="country.gender", colBV=c("bv1", "bv2")))
## Summarize population by generation (=trend)
(ret <- summary(res, by="gen"))
## Plot the partitions
p <- plot(ret, ylab=c("BV for trait 1", "BV for trait 2"), xlab="Generation")
print(p)
p <- plot(ret, ylab=c("BV for trait 1", "BV for trait 2"), xlab="Generation",
lineTypeList=list("-1"=1, "-2"=2, def=3))
print(p)
p <- plot(ret, ylab=c("BV for trait 1", "BV for trait 2"), xlab="Generation",
lineTypeList=list("-1"=1, "-2"=2, def=3), useGgplot2=FALSE, useDirectLabels = FALSE)
print(p)
## Plot control (color and type of lines + limits)
p <- plot(ret, ylab=c("BV for trait 1", "BV for trait 2"), xlab="Generation",
useGgplot2=TRUE, color=c("green", "gray"), lineType=c(2, 3),
sortValue=FALSE, lineSize=4,
xlim=c(-1, 7))
print(p)
}
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/inst/examples/examples_plotSummaryAlphaPart.R |
#' Run example in AlphaPart (see \code{\link[AlphaPart]{AlphaPart}}):
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/inst/examples/examples_print.AlphaPart.R |
## Partition additive genetic values
(res <- AlphaPart(x=AlphaPart.ped, colPath="country", colBV=c("bv1", "bv2")))
## Summarize population by generation (=trend)
(ret <- summary(res, by="gen"))
## Plot the partitions
p <- plot(ret, ylab=c("BV for trait 1", "BV for trait 2"), xlab="Generation")
print(p[[1]])
print(p[[2]])
#print(p)
| /scratch/gouwar.j/cran-all/cranData/AlphaPart/inst/examples/examples_print.plotSummaryAlphaPart.R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.