content large_stringlengths 0 6.46M | path large_stringlengths 3 331 | license_type large_stringclasses 2 values | repo_name large_stringlengths 5 125 | language large_stringclasses 1 value | is_vendor bool 2 classes | is_generated bool 2 classes | length_bytes int64 4 6.46M | extension large_stringclasses 75 values | text stringlengths 0 6.46M |
|---|---|---|---|---|---|---|---|---|---|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/CreateCohorts.R
\name{createCohorts}
\alias{createCohorts}
\title{Create the exposure and outcome cohorts}
\usage{
createCohorts(connectionDetails, cdmDatabaseSchema, workDatabaseSchema,
studyCohortTable = "ohdsi_cohorts",
exposureCohortSummaryTable = "ohdsi_cohort_summary", oracleTempSchema,
workFolder)
}
\arguments{
\item{connectionDetails}{An object of type \code{connectionDetails} as created using the
\code{\link[DatabaseConnector]{createConnectionDetails}} function in the
DatabaseConnector package.}
\item{cdmDatabaseSchema}{Schema name where your patient-level data in OMOP CDM format resides.
Note that for SQL Server, this should include both the database and
schema name, for example 'cdm_data.dbo'.}
\item{workDatabaseSchema}{Schema name where intermediate data can be stored. You will need to have
write priviliges in this schema. Note that for SQL Server, this should
include both the database and schema name, for example 'cdm_data.dbo'.}
\item{studyCohortTable}{The name of the table that will be created in the work database schema.
This table will hold the exposure and outcome cohorts used in this
study.}
\item{exposureCohortSummaryTable}{The name of the table that will be created in the work database schema.
This table will hold the summary of the exposure cohorts used in this
study.}
\item{oracleTempSchema}{Should be used in Oracle to specify a schema where the user has write
priviliges for storing temporary tables.}
\item{workFolder}{Name of local folder to place results; make sure to use forward slashes
(/)}
}
\description{
Create the exposure and outcome cohorts
}
\details{
This function will create the exposure and outcome cohorts following the definitions included in
this package.
}
| /LargeScalePopEst/man/createCohorts.Rd | permissive | jingjingz/StudyProtocols | R | false | true | 1,815 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/CreateCohorts.R
\name{createCohorts}
\alias{createCohorts}
\title{Create the exposure and outcome cohorts}
\usage{
createCohorts(connectionDetails, cdmDatabaseSchema, workDatabaseSchema,
studyCohortTable = "ohdsi_cohorts",
exposureCohortSummaryTable = "ohdsi_cohort_summary", oracleTempSchema,
workFolder)
}
\arguments{
\item{connectionDetails}{An object of type \code{connectionDetails} as created using the
\code{\link[DatabaseConnector]{createConnectionDetails}} function in the
DatabaseConnector package.}
\item{cdmDatabaseSchema}{Schema name where your patient-level data in OMOP CDM format resides.
Note that for SQL Server, this should include both the database and
schema name, for example 'cdm_data.dbo'.}
\item{workDatabaseSchema}{Schema name where intermediate data can be stored. You will need to have
write priviliges in this schema. Note that for SQL Server, this should
include both the database and schema name, for example 'cdm_data.dbo'.}
\item{studyCohortTable}{The name of the table that will be created in the work database schema.
This table will hold the exposure and outcome cohorts used in this
study.}
\item{exposureCohortSummaryTable}{The name of the table that will be created in the work database schema.
This table will hold the summary of the exposure cohorts used in this
study.}
\item{oracleTempSchema}{Should be used in Oracle to specify a schema where the user has write
priviliges for storing temporary tables.}
\item{workFolder}{Name of local folder to place results; make sure to use forward slashes
(/)}
}
\description{
Create the exposure and outcome cohorts
}
\details{
This function will create the exposure and outcome cohorts following the definitions included in
this package.
}
|
print.turbulence <-
function(x, ...) {
### summarising turbulence object information
cat("\n\tTurbulence intensity\n\n")
obj <- x[[1]]
if(length(x)>1) for(i in 2:length(x)) obj <- cbind(obj, x[[i]])
obj <- as.data.frame(obj)
names(obj) <- names(x)
row.names(obj) <- c(toupper(head(attr(x, "row.names"), -1)), tail(attr(x, "row.names"), 1))
print(obj, quote=FALSE)
if(!any(!is.na(attr(x, "call")$subset))) subs <- ", subset=NA"
else subs <- paste0(", subset=c(\"", paste(attr(x, "call")$subset, collapse="\", \""), "\")")
cat("\ncall: turbulence(mast=", attr(x, "call")$mast, ", turb.set=", attr(x, "call")$turb.set, ", dir.set=", attr(x, "call")$dir.set, ", num.sectors=", attr(x, "call")$num.sectors, ", bins=c(", paste(attr(x, "call")$bins, collapse=", "), ")", subs, ", digits=", attr(x, "call")$digits, ", print=", attr(x, "call")$print, ")\n\n", sep="")
}
| /R/print.turbulence.R | no_license | paulponcet/bReeze | R | false | false | 874 | r | print.turbulence <-
function(x, ...) {
### summarising turbulence object information
cat("\n\tTurbulence intensity\n\n")
obj <- x[[1]]
if(length(x)>1) for(i in 2:length(x)) obj <- cbind(obj, x[[i]])
obj <- as.data.frame(obj)
names(obj) <- names(x)
row.names(obj) <- c(toupper(head(attr(x, "row.names"), -1)), tail(attr(x, "row.names"), 1))
print(obj, quote=FALSE)
if(!any(!is.na(attr(x, "call")$subset))) subs <- ", subset=NA"
else subs <- paste0(", subset=c(\"", paste(attr(x, "call")$subset, collapse="\", \""), "\")")
cat("\ncall: turbulence(mast=", attr(x, "call")$mast, ", turb.set=", attr(x, "call")$turb.set, ", dir.set=", attr(x, "call")$dir.set, ", num.sectors=", attr(x, "call")$num.sectors, ", bins=c(", paste(attr(x, "call")$bins, collapse=", "), ")", subs, ", digits=", attr(x, "call")$digits, ", print=", attr(x, "call")$print, ")\n\n", sep="")
}
|
#' Various small utility functions
#'
#' A bunch of tiny utility functions that we need off and on. Not intended for user interaction.
#'
continuous.distance <- function(two.trees){
# type = 1: RF distance
# type = 2: branch.score.difference
# type = 3: path difference
# type = 4: weighted path difference
d <- abs(two.trees[1] - two.trees[2])
d
}
cummean <- function(x){
r <- (cumsum(as.numeric(x)))/seq(1:length(x))
r
}
abs.diffs <- function(x){
d <- abs(diff(as.numeric(x)))
d
} | /rwty/R/rwty.utility.functions.R | no_license | jamiepg1/RWTY | R | false | false | 527 | r | #' Various small utility functions
#'
#' A bunch of tiny utility functions that we need off and on. Not intended for user interaction.
#'
continuous.distance <- function(two.trees){
# type = 1: RF distance
# type = 2: branch.score.difference
# type = 3: path difference
# type = 4: weighted path difference
d <- abs(two.trees[1] - two.trees[2])
d
}
cummean <- function(x){
r <- (cumsum(as.numeric(x)))/seq(1:length(x))
r
}
abs.diffs <- function(x){
d <- abs(diff(as.numeric(x)))
d
} |
# For your information, briefly, the model is that, as below,
# Y_ij = intercept + dummyX_ij * (beta + beta_i) + Z_ij * (b + b_i) + error_ij,
# where 'beta' and 'b' are fixed effects while 'b and 'b_i' are random slope effects.
# We conduct the test that H_0: variance of b_i = 0 v.s. H_a: variance of b_i > 0 through exactRLR.
# In this simulation, we use parallel computing in order to reduce the performing time.
# Setups
library(parallel)
simRep <- 1000 # Replication times in one simulation
pvalue.true <- .05 # Testing type I error
b.var <- c(0) # The set of varaince of random covariates b as random slope
# Below is the function defined for each node in parallel
run_one_sample <- function(iter){
library(refund)
library(lme4)
library(nlme)
library(arm)
library(RLRsim)
set.seed(iter)
nGroup <- 50 # Group number
nRep.sim <- 20 # Duplication in each group n_i
epsilon.sd <- 1 # or 0.5
intercept.true <- 0.5
# nRandCovariate <-
b.sim <- 2
beta.sim <- 2
betaVar.sim <- 1
z.mean <- 0
totalN <- nGroup * nRep.sim
z.var <- c(1)
ID.sim <- rep(1:nGroup, each = nRep.sim)
error.sim <- rnorm(n = totalN, mean = 0, sd = epsilon.sd)
z.sim <- mapply(rnorm, totalN, z.mean, rep(sqrt(z.var), nRandCovariate))
bV.sim <- mapply(rnorm, nGroup, b.sim, rep(sqrt(r.sim), nRandCovariate))
bV.sim <- bV.sim[rep(1:nrow(bV.sim), each = nRep.sim), ]
bV.sim <- bV.sim * z.sim
bV.sim <- rowSums(bV.sim)
betaV.sim <- mapply(rnorm, nGroup, beta.sim, rep(sqrt(betaVar.sim), 1))
betaV.sim <- betaV.sim[rep(1:nrow(betaV.sim), each = nRep.sim), ]
betaV2.sim <- mapply(rnorm, nGroup, beta.sim, rep(sqrt(betaVar.sim), 1))
betaV2.sim <- betaV2.sim[rep(1:nrow(betaV2.sim), each = nRep.sim), ]
dummyX <- rbinom(n = totalN, size = 1, prob = 0.5) # Shift dummyX
Y.sim <- (intercept.true + bV.sim) + dummyX * betaV.sim + (dummyX - 1) * betaV2.sim + error.sim # NEW add 'dummyX'
ID = ID.sim
Y = Y.sim
npc = nRandCovariate
designMatrix.pdIdent <- data.frame(rating = Y,
temp = factor(dummyX, labels=c("warm", "hot")),
ID = as.factor(ID),
a.score = z.sim)
# 'lme' model with 'pdIdent'
fullReml.pdIdent <- NA
noAScoreReml.pdIdent <- NA
notempReml.pdIdent <- NA
# if(npc == 1){
# fullReml.pdIdent <- lme(fixed = Y ~ 1 + dummyX + z.sim,
# random = list(ID = pdIdent(~ 0 + dummyX),
# ID = pdIdent(~ 0 + z.sim)),
# data = designMatrix,
# control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
# noZReml.pdIdent <- lme(fixed = Y ~ 1 + dummyX + z.sim,
# random = list(ID = pdIdent(~ 0 + dummyX)),
# data = designMatrix,
# control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
# noDummyXReml.pdIdent <- lme(fixed = Y ~ 1 + dummyX + z.sim,
# random = list(ID = pdIdent(~ 0 + z.sim)),
# data = designMatrix,
# control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
# }else
if(npc == 2){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else if(npc == 3){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else if(npc == 4){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 + a.score.4,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 + a.score.4)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 + a.score.4,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 + a.score.4,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 + a.score.4)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else if(npc == 5){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else if(npc == 6){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else if(npc == 7){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else if(npc == 8){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7 + a.score.8,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 +
a.score.7 + a.score.8)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7 + a.score.8,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7 + a.score.8,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 +
a.score.7 + a.score.8)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else if(npc == 9){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7 + a.score.8 + a.score.9,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 +
a.score.7 + a.score.8 + a.score.9)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7 + a.score.8 + a.score.9,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7 + a.score.8 + a.score.9,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 +
a.score.7 + a.score.8 + a.score.9)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else{
# additive0.sim <- paste(1:pca.npc, collapse = " + a.score.")
# modelFix.sim <- as.formula(paste("rating ~ 1 + temp + a.score.",
# additive0.sim,
# sep = ""))
# modelRan.sim <- as.formula(paste("~ 0 + a.score.",
# additive0.sim,
# sep = ""))
# fullReml.pdIdent <- lme(fixed = modelFix.sim,
# random = list(ID = pdIdent(~ 0 + temp),
# ID = pdIdent(modelRan.sim)),
# data = designMatrix.pdIdent)
# noAScoreReml.pdIdent <- lme(fixed = modelFix.sim,
# random = list(ID = pdIdent(~ 0 + temp)),
# data = designMatrix.pdIdent)
# notempReml.pdIdent <- lme(fixed = modelFix.sim,
# random = list(ID = pdIdent(modelRan.sim)),
# data = designMatrix.pdIdent)
}
tests1 <- exactRLRT(notempReml.pdIdent, fullReml.pdIdent, noAScoreReml.pdIdent) # , nsim = 100000
# 'lmer' model
designMatrix.lmm <- designMatrix.pdIdent
additive0.sim <- paste(1:npc, collapse = " + a.score.")
additive.sim <- paste(1:npc, collapse = " | ID) + (0 + a.score.")
# Confusion of modifying
model.sim <- as.formula(paste("rating ~ 1 + temp + a.score.",
additive0.sim,
" + (1 | temp : ID) + (0 + a.score.",
additive.sim,
" | ID)",
sep = ""))
fullReml <- lmer(model.sim, data = designMatrix.lmm)
tests2 <- list()
for(i in 1:npc){
ii <- paste("a.score.", i, sep = "")
f0 <- as.formula(paste(" . ~ . - (0 + ", ii, "| ID)"))
m0 <- update(fullReml, f0)
f.slope <- as.formula(paste("rating ~ 1 + temp + a.score.", additive0.sim, " + (0 +", ii, " | ID)",
sep = ""))
m.slope <- lmer(f.slope, data = designMatrix.lmm)
tests2[[i]] <- exactRLRT(m.slope, fullReml, m0)
}
multiTest1 <- sapply(tests2, function(x) {
c(statistic = x$statistic[1],
"p-value" = x$p[1])})
pvalues.bonf <- p.adjust(multiTest1[2,], "bonferroni")
# fullReml <- lmer(Y ~ 1 + dummyX + z.sim + (0 + dummyX | ID) + (0 + z.sim | ID), data = designMatrix) ## + (1 | temp : ID)
# m0 <- update(fullReml, . ~ . - (0 + z.sim | ID))
# m.slope <- update(fullReml, . ~ . - (0 + dummyX | ID))
# tests2 <- list()
# tests2[[1]] <- exactRLRT(m.slope, fullReml, m0) # , nsim = 100000
#
#
# tests2 <- sapply(tests2, function(x){c(statistic = x$statistic[1], "p-value" = x$p[1])})
# pvalues.bonf <- p.adjust(tests2[2,], "bonferroni")
return(list(realTau = r.sim,
pvalue = tests1$p[1],
pvalues.bonf = pvalues.bonf,
tests1 = tests1,
tests2 = multiTest1))
}
# Setup parallel
cores <- detectCores()
cluster <- makeCluster(cores)
clusterSetRNGStream(cluster, 20170822)
for(nRandCovariate in 1:5 * 2){ # START out-outer loop
clusterExport(cluster, c("nRandCovariate")) # casting the coefficient parameter on the random effects' covariance function
fileName <- paste("beta0_X_beta_betai_Z_b_bi-pd-2to10_grp50-rep20-", nRandCovariate,".RData", sep = "") # Saving file's name
# run the simulation
loopIndex <- 1
resultDoubleList.sim <- list()
power1.sim <- list()
power2.sim <- list()
for(r.sim in b.var){ # START outer loop
clusterExport(cluster, c("r.sim")) # casting the coefficient parameter on the random effects' covariance function
node_results <- parLapply(cluster, 1:simRep, run_one_sample)
result1.sim <- lapply(node_results, function(x) {list(realTau = x$realTau,
pvalue = x$pvalue)})
result2.sim <- lapply(node_results, function(x) {list(realTau = x$realTau,
pvalues.bonf = x$pvalues.bonf)})
resultDoubleList.sim[[loopIndex]] <- node_results
save.image(file=fileName) # Auto Save
table1.sim <- sapply(result1.sim, function(x) {
c(sens = (sum(x$pvalue <= pvalue.true) > 0))})
Power1 <- mean(table1.sim)
cat("nRandCovariate: ", nRandCovariate, fill = TRUE)
cat("Power1: ", Power1, fill = TRUE)
power1.sim[[loopIndex]] <- list(Power = Power1, realTau = r.sim)
table2.sim <- sapply(result2.sim, function(x) {
c(overall.sens = (sum(x$pvalues.bonf <= pvalue.true) > 0))})
Power2 <- mean(table2.sim)
cat("Power2: ", Power2, fill = TRUE)
power2.sim[[loopIndex]] <- list(Power = Power2, realTau = r.sim)
loopIndex <- loopIndex + 1
} # End outer loop
save.image(file=fileName) # Auto Save
par(mfrow=c(2,1))
# Histogram plots
hist(sapply(result1.sim, function(x) x$pvalue),
main = "Histogram of p-value for lme model",
xlab = "p-value")
hist(sapply(result2.sim, function(x) x$pvalues.bonf),
main = "Histogram of p-value for lmer model",
xlab = "p-value")
# hist(sapply(resultDoubleList.sim[[1]], function(x) (x$tests1)$statistic[1]),
# breaks = (0:110)/10,
# main = "Histogram of test-statistic for lme model",
# xlab = "Test Statistics")
#
# hist(sapply(resultDoubleList.sim[[1]], function(x) (x$tests2)[1,1]),
# breaks = (0:100)/10,
# main = "Histogram of test-statistic for lmer model",
# xlab = "Test Statistics")
} # End out-outer loop
stopCluster(cluster)
| /full simulation/old files/11.15.2017/beta0_X_beta_betai_Z_b_bi-pd-2to10_grp50-rep20.R | no_license | wma9/FMRI-project | R | false | false | 21,201 | r | # For your information, briefly, the model is that, as below,
# Y_ij = intercept + dummyX_ij * (beta + beta_i) + Z_ij * (b + b_i) + error_ij,
# where 'beta' and 'b' are fixed effects while 'b and 'b_i' are random slope effects.
# We conduct the test that H_0: variance of b_i = 0 v.s. H_a: variance of b_i > 0 through exactRLR.
# In this simulation, we use parallel computing in order to reduce the performing time.
# Setups
library(parallel)
simRep <- 1000 # Replication times in one simulation
pvalue.true <- .05 # Testing type I error
b.var <- c(0) # The set of varaince of random covariates b as random slope
# Below is the function defined for each node in parallel
run_one_sample <- function(iter){
library(refund)
library(lme4)
library(nlme)
library(arm)
library(RLRsim)
set.seed(iter)
nGroup <- 50 # Group number
nRep.sim <- 20 # Duplication in each group n_i
epsilon.sd <- 1 # or 0.5
intercept.true <- 0.5
# nRandCovariate <-
b.sim <- 2
beta.sim <- 2
betaVar.sim <- 1
z.mean <- 0
totalN <- nGroup * nRep.sim
z.var <- c(1)
ID.sim <- rep(1:nGroup, each = nRep.sim)
error.sim <- rnorm(n = totalN, mean = 0, sd = epsilon.sd)
z.sim <- mapply(rnorm, totalN, z.mean, rep(sqrt(z.var), nRandCovariate))
bV.sim <- mapply(rnorm, nGroup, b.sim, rep(sqrt(r.sim), nRandCovariate))
bV.sim <- bV.sim[rep(1:nrow(bV.sim), each = nRep.sim), ]
bV.sim <- bV.sim * z.sim
bV.sim <- rowSums(bV.sim)
betaV.sim <- mapply(rnorm, nGroup, beta.sim, rep(sqrt(betaVar.sim), 1))
betaV.sim <- betaV.sim[rep(1:nrow(betaV.sim), each = nRep.sim), ]
betaV2.sim <- mapply(rnorm, nGroup, beta.sim, rep(sqrt(betaVar.sim), 1))
betaV2.sim <- betaV2.sim[rep(1:nrow(betaV2.sim), each = nRep.sim), ]
dummyX <- rbinom(n = totalN, size = 1, prob = 0.5) # Shift dummyX
Y.sim <- (intercept.true + bV.sim) + dummyX * betaV.sim + (dummyX - 1) * betaV2.sim + error.sim # NEW add 'dummyX'
ID = ID.sim
Y = Y.sim
npc = nRandCovariate
designMatrix.pdIdent <- data.frame(rating = Y,
temp = factor(dummyX, labels=c("warm", "hot")),
ID = as.factor(ID),
a.score = z.sim)
# 'lme' model with 'pdIdent'
fullReml.pdIdent <- NA
noAScoreReml.pdIdent <- NA
notempReml.pdIdent <- NA
# if(npc == 1){
# fullReml.pdIdent <- lme(fixed = Y ~ 1 + dummyX + z.sim,
# random = list(ID = pdIdent(~ 0 + dummyX),
# ID = pdIdent(~ 0 + z.sim)),
# data = designMatrix,
# control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
# noZReml.pdIdent <- lme(fixed = Y ~ 1 + dummyX + z.sim,
# random = list(ID = pdIdent(~ 0 + dummyX)),
# data = designMatrix,
# control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
# noDummyXReml.pdIdent <- lme(fixed = Y ~ 1 + dummyX + z.sim,
# random = list(ID = pdIdent(~ 0 + z.sim)),
# data = designMatrix,
# control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
# }else
if(npc == 2){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else if(npc == 3){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else if(npc == 4){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 + a.score.4,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 + a.score.4)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 + a.score.4,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 + a.score.4,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 + a.score.4)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else if(npc == 5){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else if(npc == 6){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else if(npc == 7){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else if(npc == 8){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7 + a.score.8,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 +
a.score.7 + a.score.8)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7 + a.score.8,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7 + a.score.8,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 +
a.score.7 + a.score.8)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else if(npc == 9){
fullReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7 + a.score.8 + a.score.9,
random = list(ID = pdIdent(~ 0 + temp),
ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 +
a.score.7 + a.score.8 + a.score.9)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
noAScoreReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7 + a.score.8 + a.score.9,
random = list(ID = pdIdent(~ 0 + temp)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
notempReml.pdIdent <- lme(fixed = rating ~ 1 + temp + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 + a.score.7 + a.score.8 + a.score.9,
random = list(ID = pdIdent(~ 0 + a.score.1 + a.score.2 + a.score.3 +
a.score.4 + a.score.5 + a.score.6 +
a.score.7 + a.score.8 + a.score.9)),
data = designMatrix.pdIdent,
control = lmeControl(msVerbose = TRUE, opt = 'optim', singular.ok=TRUE, returnObject=TRUE))
}else{
# additive0.sim <- paste(1:pca.npc, collapse = " + a.score.")
# modelFix.sim <- as.formula(paste("rating ~ 1 + temp + a.score.",
# additive0.sim,
# sep = ""))
# modelRan.sim <- as.formula(paste("~ 0 + a.score.",
# additive0.sim,
# sep = ""))
# fullReml.pdIdent <- lme(fixed = modelFix.sim,
# random = list(ID = pdIdent(~ 0 + temp),
# ID = pdIdent(modelRan.sim)),
# data = designMatrix.pdIdent)
# noAScoreReml.pdIdent <- lme(fixed = modelFix.sim,
# random = list(ID = pdIdent(~ 0 + temp)),
# data = designMatrix.pdIdent)
# notempReml.pdIdent <- lme(fixed = modelFix.sim,
# random = list(ID = pdIdent(modelRan.sim)),
# data = designMatrix.pdIdent)
}
tests1 <- exactRLRT(notempReml.pdIdent, fullReml.pdIdent, noAScoreReml.pdIdent) # , nsim = 100000
# 'lmer' model
designMatrix.lmm <- designMatrix.pdIdent
additive0.sim <- paste(1:npc, collapse = " + a.score.")
additive.sim <- paste(1:npc, collapse = " | ID) + (0 + a.score.")
# Confusion of modifying
model.sim <- as.formula(paste("rating ~ 1 + temp + a.score.",
additive0.sim,
" + (1 | temp : ID) + (0 + a.score.",
additive.sim,
" | ID)",
sep = ""))
fullReml <- lmer(model.sim, data = designMatrix.lmm)
tests2 <- list()
for(i in 1:npc){
ii <- paste("a.score.", i, sep = "")
f0 <- as.formula(paste(" . ~ . - (0 + ", ii, "| ID)"))
m0 <- update(fullReml, f0)
f.slope <- as.formula(paste("rating ~ 1 + temp + a.score.", additive0.sim, " + (0 +", ii, " | ID)",
sep = ""))
m.slope <- lmer(f.slope, data = designMatrix.lmm)
tests2[[i]] <- exactRLRT(m.slope, fullReml, m0)
}
multiTest1 <- sapply(tests2, function(x) {
c(statistic = x$statistic[1],
"p-value" = x$p[1])})
pvalues.bonf <- p.adjust(multiTest1[2,], "bonferroni")
# fullReml <- lmer(Y ~ 1 + dummyX + z.sim + (0 + dummyX | ID) + (0 + z.sim | ID), data = designMatrix) ## + (1 | temp : ID)
# m0 <- update(fullReml, . ~ . - (0 + z.sim | ID))
# m.slope <- update(fullReml, . ~ . - (0 + dummyX | ID))
# tests2 <- list()
# tests2[[1]] <- exactRLRT(m.slope, fullReml, m0) # , nsim = 100000
#
#
# tests2 <- sapply(tests2, function(x){c(statistic = x$statistic[1], "p-value" = x$p[1])})
# pvalues.bonf <- p.adjust(tests2[2,], "bonferroni")
return(list(realTau = r.sim,
pvalue = tests1$p[1],
pvalues.bonf = pvalues.bonf,
tests1 = tests1,
tests2 = multiTest1))
}
# Setup parallel
cores <- detectCores()
cluster <- makeCluster(cores)
clusterSetRNGStream(cluster, 20170822)
for(nRandCovariate in 1:5 * 2){ # START out-outer loop
clusterExport(cluster, c("nRandCovariate")) # casting the coefficient parameter on the random effects' covariance function
fileName <- paste("beta0_X_beta_betai_Z_b_bi-pd-2to10_grp50-rep20-", nRandCovariate,".RData", sep = "") # Saving file's name
# run the simulation
loopIndex <- 1
resultDoubleList.sim <- list()
power1.sim <- list()
power2.sim <- list()
for(r.sim in b.var){ # START outer loop
clusterExport(cluster, c("r.sim")) # casting the coefficient parameter on the random effects' covariance function
node_results <- parLapply(cluster, 1:simRep, run_one_sample)
result1.sim <- lapply(node_results, function(x) {list(realTau = x$realTau,
pvalue = x$pvalue)})
result2.sim <- lapply(node_results, function(x) {list(realTau = x$realTau,
pvalues.bonf = x$pvalues.bonf)})
resultDoubleList.sim[[loopIndex]] <- node_results
save.image(file=fileName) # Auto Save
table1.sim <- sapply(result1.sim, function(x) {
c(sens = (sum(x$pvalue <= pvalue.true) > 0))})
Power1 <- mean(table1.sim)
cat("nRandCovariate: ", nRandCovariate, fill = TRUE)
cat("Power1: ", Power1, fill = TRUE)
power1.sim[[loopIndex]] <- list(Power = Power1, realTau = r.sim)
table2.sim <- sapply(result2.sim, function(x) {
c(overall.sens = (sum(x$pvalues.bonf <= pvalue.true) > 0))})
Power2 <- mean(table2.sim)
cat("Power2: ", Power2, fill = TRUE)
power2.sim[[loopIndex]] <- list(Power = Power2, realTau = r.sim)
loopIndex <- loopIndex + 1
} # End outer loop
save.image(file=fileName) # Auto Save
par(mfrow=c(2,1))
# Histogram plots
hist(sapply(result1.sim, function(x) x$pvalue),
main = "Histogram of p-value for lme model",
xlab = "p-value")
hist(sapply(result2.sim, function(x) x$pvalues.bonf),
main = "Histogram of p-value for lmer model",
xlab = "p-value")
# hist(sapply(resultDoubleList.sim[[1]], function(x) (x$tests1)$statistic[1]),
# breaks = (0:110)/10,
# main = "Histogram of test-statistic for lme model",
# xlab = "Test Statistics")
#
# hist(sapply(resultDoubleList.sim[[1]], function(x) (x$tests2)[1,1]),
# breaks = (0:100)/10,
# main = "Histogram of test-statistic for lmer model",
# xlab = "Test Statistics")
} # End out-outer loop
stopCluster(cluster)
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/LimDist.R
\name{LimDist}
\alias{LimDist}
\title{Tool to computate the limiting distribution for a Continuous Time Markov Chain, CTMC.}
\usage{
LimDist(X, rate, epsilon = 0.01, iter)
}
\arguments{
\item{X}{matrix, represents a rate matrix of a CTMC or the transition probability matrix of the DTMC associated to the CTMC.}
\item{rate}{boolean, if rate is equal to TRUE then the argument X represents the rate matrix of the CTMC. If rate is equal to FALSE then the argument X represents the probability transition matrix of the CTMC.}
\item{epsilon}{numeric, represents the error of approximation.}
\item{iter}{integer, represents the maximum of iterations.}
}
\description{
\code{LimDist} is used to obtain the limiting distribution of a homogeneous continuous time Markov chain.
}
\references{
Ross, S, Introduction to Probability Models, Eleven Edition. Academic Press, 2014.
Kulkarni V, Introduction to modeling and analysis of stochastic systems. Second Edition. Springer-Verlag, 2011.
}
\author{
Carlos Alberto Cardozo Delgado <cardozorpackages@gmail.com>.
}
| /man/LimDist.Rd | no_license | cran/modesto | R | false | true | 1,173 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/LimDist.R
\name{LimDist}
\alias{LimDist}
\title{Tool to computate the limiting distribution for a Continuous Time Markov Chain, CTMC.}
\usage{
LimDist(X, rate, epsilon = 0.01, iter)
}
\arguments{
\item{X}{matrix, represents a rate matrix of a CTMC or the transition probability matrix of the DTMC associated to the CTMC.}
\item{rate}{boolean, if rate is equal to TRUE then the argument X represents the rate matrix of the CTMC. If rate is equal to FALSE then the argument X represents the probability transition matrix of the CTMC.}
\item{epsilon}{numeric, represents the error of approximation.}
\item{iter}{integer, represents the maximum of iterations.}
}
\description{
\code{LimDist} is used to obtain the limiting distribution of a homogeneous continuous time Markov chain.
}
\references{
Ross, S, Introduction to Probability Models, Eleven Edition. Academic Press, 2014.
Kulkarni V, Introduction to modeling and analysis of stochastic systems. Second Edition. Springer-Verlag, 2011.
}
\author{
Carlos Alberto Cardozo Delgado <cardozorpackages@gmail.com>.
}
|
library(adePEM)
library(paleoTS)
#####
##### Calculate model statistics on all time series in uploaded folders #####
#####
# set directory to folder with fossil time series.
setwd("~/fossil time series")
temp = list.files(pattern="*.txt")
for (i in 1:length(temp)) assign(temp[i], read.csv(temp[i]))
nr_datasets<-length(temp)
nr_parameters<-66
replicates<-1000
out<-matrix(nrow=nr_datasets, ncol=nr_parameters, data=NA)
colnames(out)<-c("AICc.Directional.change","AICc.Random.walk", "AICc.Stasis",
"Akaike.wt.Directional.change","Akaike.wt.Random.walk","Akaike.wt.Stasis",
"theta","omega",
"auto.corr_stasis_est", "auto.corr_stasis_min","auto.corr_stasis_max","auto.corr_stasis_p", "auto.corr_stasis_result",
"runs.test_stasis_est", "runs.test_stasis_min","runs.test_stasis_max","runs.test_stasis_p", "runs.test_stasis_result",
"slope.test_stasis_est", "slope.test_stasis_min","slope.test_stasis_max","slope.test_stasis_p", "slope.test_stasis_result",
"net.change.test_stasis_est", "net.change.test_stasis_min","net.change.test_stasis_max","net.change.test_stasis_p", "net.change.test_stasis_result",
"vstep_RW",
"auto.corr_RW_est", "auto.corr_RW_min","auto.corr_RW_max","auto.corr_RW_p", "auto.corr_RW_result",
"runs.test_RW_est", "runs.test_RW_min","runs.test_RW_max","runs.test_RW_p", "runs.test_RW_result",
"slope.test_RW_est", "slope.test_RW_min","slope.test_RW_max","slope.test_RW_p", "slope.test_RW_result",
"mstep_trend", "vstep_trend",
"auto.corr_trend_est", "auto.corr_trend_min","auto.corr_trend_max","auto.corr_trend_p", "auto.corr_trend_result",
"runs.test_trend_est", "runs.test_trend_min","runs.test_trend_max","runs.test_trend_p", "runs.test_trend_result",
"slope.test_trend_est", "slope.test_trend_min","slope.test_trend_max","slope.test_trend_p", "slope.test_trend_result",
"interval.length.MY", "generation.time", "taxa", "dimensions", "species")
out<-as.data.frame(out)
for (i in 1:nr_datasets){
indata<-read.table(temp[i], header=T)
y<-as.paleoTS(indata$mm, indata$vv, indata$N, indata$age.in.MY)
if (indata$log[1] =="no") y<-ln.paleoTS(y);
if (indata$dimension[1] =="area") y$mm<-y$mm/2; y$vv<-y$vv/4;
out[i,1:3]<-fit3models(y, method = "Joint")[1:3,3]
out[i,4:6]<-fit3models(y, method = "Joint")[1:3,4]
theta<-opt.joint.Stasis(y)$par[1]
omega<-opt.joint.Stasis(y)$par[2]
out[i,7]<-theta
out[i,8]<-omega
# adequacy test of stasis
temp_Stasis<-fit4adequacy.stasis(y, nrep=replicates, plot = FALSE)
out[i,9:13]<-as.matrix(temp_Stasis$summary)[1,1:5]
out[i,14:18]<-as.matrix(temp_Stasis$summary)[2,1:5]
out[i,19:23]<-as.matrix(temp_Stasis$summary)[3,1:5]
out[i,24:28]<-as.matrix(temp_Stasis$summary)[4,1:5]
vstep_RW<-opt.joint.URW(y)$par[2]
out[i,29]<-vstep_RW
# adequacy test of RW
temp_RW<-fit3adequacy.RW(y, nrep=replicates, plot = FALSE)
out[i,30:34]<-as.matrix(temp_RW$summary)[1,1:5]
out[i,35:39]<-as.matrix(temp_RW$summary)[2,1:5]
out[i,40:44]<-as.matrix(temp_RW$summary)[3,1:5]
mstep_trend<-opt.joint.GRW(y)$par[2]
vstep_trend<-opt.joint.GRW(y)$par[3]
out[i,45]<-mstep_trend
out[i,46]<-vstep_trend
# adequacy tests of trend
temp_trend<-fit3adequacy.trend(y,nrep=replicates, plot = FALSE)
out[i,47:51]<-as.matrix(temp_trend$summary)[1,1:5]
out[i,52:56]<-as.matrix(temp_trend$summary)[2,1:5]
out[i,57:61]<-as.matrix(temp_trend$summary)[3,1:5]
out[i,62]<-indata$interval.length.MY[1]
out[i,63]<-indata$generation.time[1]
out[i,64]<-levels(droplevels(indata$taxa[1]))
out[i,65]<-levels(droplevels(indata$dimension[1]))
out[i,66]<-levels(droplevels(indata$species[1]))
print(i)
}
############################
############################
############################
# Frequency of the different modes:
mode<-rep(NA, length(out[,1]))
for (i in 1:length(mode)){
if ((max(c(out[i,4], out[i,5],out[i,6])) == out[i,4])) mode[i]<-"Directional"
if ((max(c(out[i,4], out[i,5],out[i,6])) == out[i,5])) mode[i]<-"Random walk"
if ((max(c(out[i,4], out[i,5],out[i,6])) == out[i,6])) mode[i]<-"Stasis"
}
table(mode)
# Finding out how many cases where the second best model has 2 or less AICc units less support compared to best model:
direct_RW<-rep(NA, length(out[,1]))
direct_Stasis<-rep(NA, length(out[,1]))
RW_Stasis<-rep(NA, length(out[,1]))
direct_RW_stasis<-rep(NA, length(out[,1]))
for (i in 1:length(direct_RW)){
if (mode[i]=="Random walk" & abs(out[i,1]-out[i,2]) <=2) direct_RW[i]<-"direct_RW"
if (mode[i]=="Directional" & abs(out[i,1]-out[i,2]) <=2) direct_RW[i]<-"direct_RW"
if (mode[i]=="Directional" & abs(out[i,1]-out[i,3]) <=2) direct_Stasis[i]<-"direct_stasis"
if (mode[i]=="Stasis" & abs(out[i,1]-out[i,3]) <=2) direct_Stasis[i]<-"direct_stasis"
if (mode[i]=="Random walk" & abs(out[i,2]-out[i,3]) <=2) RW_Stasis[i]<-"RW_Stasis"
if (mode[i]=="Stasis" & abs(out[i,2]-out[i,3]) <=2) RW_Stasis[i]<-"RW_Stasis"
if (mode[i]=="Random walk" & abs(out[i,1]-out[i,2]) <=2 & abs(out[i,1]-out[i,3]) <=2 & abs(out[i,2]-out[i,3]) <=2) direct_RW_stasis[i]<-"All_thee"
if (mode[i]=="Stasis" & abs(out[i,1]-out[i,2]) <=2 & abs(out[i,1]-out[i,3]) <=2 & abs(out[i,2]-out[i,3]) <=2) direct_RW_stasis[i]<-"All_thee"
if (mode[i]=="Directional" & abs(out[i,1]-out[i,2]) <=2 & abs(out[i,1]-out[i,3]) <=2 & abs(out[i,2]-out[i,3]) <=2) direct_RW_stasis[i]<-"All_thee"
}
#Combine large matrix with vectors
indata_3_modes<-cbind(out, mode, direct_RW, direct_Stasis, RW_Stasis, direct_RW_stasis)
passed_RW<-rep(NA, nrow(indata_3_modes))
passed_directional<-rep(NA, nrow(indata_3_modes))
passed_stasis<-rep(NA, nrow(indata_3_modes))
for (i in 1:nrow(indata_3_modes)){
if (indata_3_modes[i,13] == "PASSED" & indata_3_modes[i,18]=="PASSED" & indata_3_modes[i,23]=="PASSED" & indata_3_modes[i,28]=="PASSED") passed_stasis[i]<-"PASSED" else passed_stasis[i]<-"FAILED"
if (indata_3_modes[i,51] == "PASSED" & indata_3_modes[i,56]=="PASSED" & indata_3_modes[i,61]=="PASSED" ) passed_directional[i]<-"PASSED" else passed_directional[i]<-"FAILED"
if (indata_3_modes[i,34] == "PASSED" & indata_3_modes[i,39]=="PASSED" & indata_3_modes[i,44]=="PASSED" ) passed_RW[i]<-"PASSED" else passed_RW[i]<-"PASSED"
}
#Table summarizing wich data sets where the second best model has a relative fit =< 2AICc units compared to the best model, and to what extent adequacy models help in picking an adequate model:
test_two_aicc_units_difference<-cbind(passed_RW, passed_directional, passed_stasis, direct_RW, direct_Stasis, RW_Stasis, direct_RW_stasis)
# Check models that showed both a relative and absolute fit to the data:
stasis_only<-indata_3_modes[indata_3_modes[, "mode"] == "Stasis",]
BM_only<-indata_3_modes[indata_3_modes[, "mode"] == "Random walk",]
DT_only<-indata_3_modes[indata_3_modes[, "mode"] == "Directional",]
adequate_stasis.models<-rep(NA, nrow(stasis_only))
adequate_BM.models<-rep(NA, nrow(BM_only))
adequate_DT.models<-rep(NA, nrow(DT_only))
for (i in 1:length(stasis_only[,1])){
if (stasis_only[i,13] == "FAILED" | stasis_only[i,18]=="FAILED" | stasis_only[i,23]=="FAILED" | stasis_only[i,28]=="FAILED") adequate_stasis.models[i]<-FALSE else adequate_stasis.models[i]<-TRUE
}
for (i in 1:length(BM_only[,1])){
if (BM_only[i,34] == "FAILED" | BM_only[i,39]=="FAILED" | BM_only[i,44]=="FAILED") adequate_BM.models[i]<-FALSE else adequate_BM.models[i]<-TRUE
}
for (i in 1:length(DT_only[,1])){
if (DT_only[i,51] == "FAILED" | DT_only[i,56]=="FAILED" | DT_only[i,61]=="FAILED") adequate_DT.models[i]<-FALSE else adequate_DT.models[i]<-TRUE
}
# Combine data frames:
temp_data.frame<-as.data.frame(rbind(stasis_only[,1:67], BM_only[,1:67] ,DT_only[,1:67]))
new_3_modes<-cbind(temp_data.frame,c(adequate_stasis.models, adequate_BM.models, adequate_DT.models))
dim(new_3_modes)
names(new_3_modes)[68]<-"adequate"
stasis_models<-cbind(stasis_only, adequate_stasis.models)
BM_models<-cbind(BM_only, adequate_BM.models)
DT_models<-cbind(DT_only, adequate_DT.models)
# Remove lineages that failed to fit the model adequacy criteria:
new_3_modes_adequate<-new_3_modes[new_3_modes[, "adequate"] == "TRUE",]
dim(new_3_modes_adequate)
table(new_3_modes_adequate$mode)
### Done preparing data frames ###
#########
######### Analyze time series
#########
######## STASIS ########
#Filter out the data sets that fitted the stasis model in an adequate way
stasis_adequate<-stasis_models[stasis_models[, "adequate_stasis.models"] == "TRUE",]
dim(stasis_adequate)
######## BM ########
#Filter out the data sets that fitted the BM model in an adequate way
BM_adequate<-BM_models[BM_models[, "adequate_BM.models"] == "TRUE",]
dim(BM_adequate)
######## Directional change ########
#Filter out the data sets that fitted the DT model in an adequate way
DT_adequate<-DT_models[DT_models[, "adequate_DT.models"] == "TRUE",]
dim(DT_adequate)
####### Case studies
### Comparing the rate of evolution in coccoliths
# Success BM
indata<-read.table(temp[6], header=T)
y<-as.paleoTS(indata$mm, indata$vv, indata$N, indata$age.in.MY)
if (indata$log[1] =="no") y<-ln.paleoTS(y);
if (indata$dimension[1] =="area") y$mm<-y$mm/2; y$vv<-y$vv/4;
par(mfrow=c(1,1))
plot.paleoTS(y)
fit3models(y, method = "Joint")
fit3adequacy.RW(y, nrep=1000, plot = TRUE)
fit3adequacy.trend(y, nrep=1000, plot = TRUE)
# Failure Stasis
indata<-read.table(temp[65], header=T)
y<-as.paleoTS(indata$mm, indata$vv, indata$N, indata$age.in.MY)
if (indata$log[1] =="no") y<-ln.paleoTS(y);
if (indata$dimension[1] =="area") y$mm<-y$mm/2; y$vv<-y$vv/4;
plot.paleoTS(y)
fit3models(y, method = "Joint", pool=FALSE)
fit4adequacy.stasis(y,nrep=1000, plot = TRUE)
fit3adequacy.RW(y, nrep=1000, plot = TRUE)
fit3adequacy.trend(y, nrep=1000, plot = TRUE)
# Failure DT
indata<-read.table(temp[48], header=T)
y<-as.paleoTS(indata$mm, indata$vv, indata$N, indata$age.in.MY)
if (indata$log[1] =="no") y<-ln.paleoTS(y);
if (indata$dimension[1] =="area") y$mm<-y$mm/2; y$vv<-y$vv/4;
layout(1:1)
plot.paleoTS(y)
fit3models(y, method = "Joint")
fit3adequacy.trend(y, nrep=1000, plot = TRUE)
fit3adequacy.RW(y, nrep=1000, plot = TRUE)
###################
################### Model adequacy when not the best model according to AICc
### BM adequate model when stasis shows best relative fit
adequate_BM.stasis.best<-rep(NA, length(stasis_adequate[,1]))
for (i in 1:length(adequate_BM.stasis.best)){
if (stasis_adequate[i,34] == "PASSED" & stasis_adequate[i,39]=="PASSED" & stasis_adequate[i,44]=="PASSED") adequate_BM.stasis.best[i]<-TRUE else adequate_BM.stasis.best[i]<-FALSE
}
table(adequate_BM.stasis.best)
### DT adequate model when stasis shows best relative fit
adequate_DT.stasis.best<-rep(NA, length(stasis_adequate[,1]))
for (i in 1:length(adequate_DT.stasis.best)){
if (stasis_adequate[i,51] == "PASSED" & stasis_adequate[i,56]=="PASSED" & stasis_adequate[i,61]=="PASSED" ) adequate_DT.stasis.best[i]<-TRUE else adequate_DT.stasis.best[i]<-FALSE
}
table(adequate_DT.stasis.best)
### DT adequate model when BM shows best relative fit
adequate_DT.BM.best<-rep(NA, length(BM_adequate[,1]))
for (i in 1:length(adequate_DT.BM.best)){
if (BM_adequate[i,51] == "PASSED" & BM_adequate[i,56]=="PASSED" & BM_adequate[i,61]=="PASSED" ) adequate_DT.BM.best[i]<-TRUE else adequate_DT.BM.best[i]<-FALSE
}
table(adequate_DT.BM.best)
### stasis adequate model when BM shows best relative fit
adequate_stasis.BM.best<-rep(NA, length(BM_adequate[,1]))
for (i in 1:length(adequate_DT.BM.best)){
if (BM_adequate[i,13] == "PASSED" & BM_adequate[i,18]=="PASSED" & BM_adequate[i,23]=="PASSED" & BM_adequate[i,28]=="PASSED") adequate_stasis.BM.best[i]<-TRUE else adequate_stasis.BM.best[i]<-FALSE
}
table(adequate_stasis.BM.best)
### BM adequate model when DT shows best relative fit
adequate_BM.DT.best<-rep(NA, length(DT_adequate[,1]))
for (i in 1:length(adequate_BM.DT.best)){
if (DT_adequate[i,34] == "PASSED" & DT_adequate[i,39]=="PASSED" & DT_adequate[i,44]=="PASSED") adequate_BM.DT.best[i]<-TRUE else adequate_BM.DT.best[i]<-FALSE
}
table(adequate_BM.DT.best)
### stasis adequate model when DT shows best relative fit
adequate_stasis.DT.best<-rep(NA, length(DT_adequate[,1]))
for (i in 1:length(adequate_stasis.DT.best)){
if (DT_adequate[i,13] == "PASSED" & DT_adequate[i,18]=="PASSED" & DT_adequate[i,23]=="PASSED" & DT_adequate[i,28]=="PASSED") adequate_stasis.DT.best[i]<-TRUE else adequate_stasis.DT.best[i]<-FALSE
}
table(adequate_stasis.DT.best)
| /code/R script - model adequacy.R | no_license | klvoje/Phyletic_model_adequacy | R | false | false | 12,844 | r | library(adePEM)
library(paleoTS)
#####
##### Calculate model statistics on all time series in uploaded folders #####
#####
# set directory to folder with fossil time series.
setwd("~/fossil time series")
temp = list.files(pattern="*.txt")
for (i in 1:length(temp)) assign(temp[i], read.csv(temp[i]))
nr_datasets<-length(temp)
nr_parameters<-66
replicates<-1000
out<-matrix(nrow=nr_datasets, ncol=nr_parameters, data=NA)
colnames(out)<-c("AICc.Directional.change","AICc.Random.walk", "AICc.Stasis",
"Akaike.wt.Directional.change","Akaike.wt.Random.walk","Akaike.wt.Stasis",
"theta","omega",
"auto.corr_stasis_est", "auto.corr_stasis_min","auto.corr_stasis_max","auto.corr_stasis_p", "auto.corr_stasis_result",
"runs.test_stasis_est", "runs.test_stasis_min","runs.test_stasis_max","runs.test_stasis_p", "runs.test_stasis_result",
"slope.test_stasis_est", "slope.test_stasis_min","slope.test_stasis_max","slope.test_stasis_p", "slope.test_stasis_result",
"net.change.test_stasis_est", "net.change.test_stasis_min","net.change.test_stasis_max","net.change.test_stasis_p", "net.change.test_stasis_result",
"vstep_RW",
"auto.corr_RW_est", "auto.corr_RW_min","auto.corr_RW_max","auto.corr_RW_p", "auto.corr_RW_result",
"runs.test_RW_est", "runs.test_RW_min","runs.test_RW_max","runs.test_RW_p", "runs.test_RW_result",
"slope.test_RW_est", "slope.test_RW_min","slope.test_RW_max","slope.test_RW_p", "slope.test_RW_result",
"mstep_trend", "vstep_trend",
"auto.corr_trend_est", "auto.corr_trend_min","auto.corr_trend_max","auto.corr_trend_p", "auto.corr_trend_result",
"runs.test_trend_est", "runs.test_trend_min","runs.test_trend_max","runs.test_trend_p", "runs.test_trend_result",
"slope.test_trend_est", "slope.test_trend_min","slope.test_trend_max","slope.test_trend_p", "slope.test_trend_result",
"interval.length.MY", "generation.time", "taxa", "dimensions", "species")
out<-as.data.frame(out)
for (i in 1:nr_datasets){
indata<-read.table(temp[i], header=T)
y<-as.paleoTS(indata$mm, indata$vv, indata$N, indata$age.in.MY)
if (indata$log[1] =="no") y<-ln.paleoTS(y);
if (indata$dimension[1] =="area") y$mm<-y$mm/2; y$vv<-y$vv/4;
out[i,1:3]<-fit3models(y, method = "Joint")[1:3,3]
out[i,4:6]<-fit3models(y, method = "Joint")[1:3,4]
theta<-opt.joint.Stasis(y)$par[1]
omega<-opt.joint.Stasis(y)$par[2]
out[i,7]<-theta
out[i,8]<-omega
# adequacy test of stasis
temp_Stasis<-fit4adequacy.stasis(y, nrep=replicates, plot = FALSE)
out[i,9:13]<-as.matrix(temp_Stasis$summary)[1,1:5]
out[i,14:18]<-as.matrix(temp_Stasis$summary)[2,1:5]
out[i,19:23]<-as.matrix(temp_Stasis$summary)[3,1:5]
out[i,24:28]<-as.matrix(temp_Stasis$summary)[4,1:5]
vstep_RW<-opt.joint.URW(y)$par[2]
out[i,29]<-vstep_RW
# adequacy test of RW
temp_RW<-fit3adequacy.RW(y, nrep=replicates, plot = FALSE)
out[i,30:34]<-as.matrix(temp_RW$summary)[1,1:5]
out[i,35:39]<-as.matrix(temp_RW$summary)[2,1:5]
out[i,40:44]<-as.matrix(temp_RW$summary)[3,1:5]
mstep_trend<-opt.joint.GRW(y)$par[2]
vstep_trend<-opt.joint.GRW(y)$par[3]
out[i,45]<-mstep_trend
out[i,46]<-vstep_trend
# adequacy tests of trend
temp_trend<-fit3adequacy.trend(y,nrep=replicates, plot = FALSE)
out[i,47:51]<-as.matrix(temp_trend$summary)[1,1:5]
out[i,52:56]<-as.matrix(temp_trend$summary)[2,1:5]
out[i,57:61]<-as.matrix(temp_trend$summary)[3,1:5]
out[i,62]<-indata$interval.length.MY[1]
out[i,63]<-indata$generation.time[1]
out[i,64]<-levels(droplevels(indata$taxa[1]))
out[i,65]<-levels(droplevels(indata$dimension[1]))
out[i,66]<-levels(droplevels(indata$species[1]))
print(i)
}
############################
############################
############################
# Frequency of the different modes:
mode<-rep(NA, length(out[,1]))
for (i in 1:length(mode)){
if ((max(c(out[i,4], out[i,5],out[i,6])) == out[i,4])) mode[i]<-"Directional"
if ((max(c(out[i,4], out[i,5],out[i,6])) == out[i,5])) mode[i]<-"Random walk"
if ((max(c(out[i,4], out[i,5],out[i,6])) == out[i,6])) mode[i]<-"Stasis"
}
table(mode)
# Finding out how many cases where the second best model has 2 or less AICc units less support compared to best model:
direct_RW<-rep(NA, length(out[,1]))
direct_Stasis<-rep(NA, length(out[,1]))
RW_Stasis<-rep(NA, length(out[,1]))
direct_RW_stasis<-rep(NA, length(out[,1]))
for (i in 1:length(direct_RW)){
if (mode[i]=="Random walk" & abs(out[i,1]-out[i,2]) <=2) direct_RW[i]<-"direct_RW"
if (mode[i]=="Directional" & abs(out[i,1]-out[i,2]) <=2) direct_RW[i]<-"direct_RW"
if (mode[i]=="Directional" & abs(out[i,1]-out[i,3]) <=2) direct_Stasis[i]<-"direct_stasis"
if (mode[i]=="Stasis" & abs(out[i,1]-out[i,3]) <=2) direct_Stasis[i]<-"direct_stasis"
if (mode[i]=="Random walk" & abs(out[i,2]-out[i,3]) <=2) RW_Stasis[i]<-"RW_Stasis"
if (mode[i]=="Stasis" & abs(out[i,2]-out[i,3]) <=2) RW_Stasis[i]<-"RW_Stasis"
if (mode[i]=="Random walk" & abs(out[i,1]-out[i,2]) <=2 & abs(out[i,1]-out[i,3]) <=2 & abs(out[i,2]-out[i,3]) <=2) direct_RW_stasis[i]<-"All_thee"
if (mode[i]=="Stasis" & abs(out[i,1]-out[i,2]) <=2 & abs(out[i,1]-out[i,3]) <=2 & abs(out[i,2]-out[i,3]) <=2) direct_RW_stasis[i]<-"All_thee"
if (mode[i]=="Directional" & abs(out[i,1]-out[i,2]) <=2 & abs(out[i,1]-out[i,3]) <=2 & abs(out[i,2]-out[i,3]) <=2) direct_RW_stasis[i]<-"All_thee"
}
#Combine large matrix with vectors
indata_3_modes<-cbind(out, mode, direct_RW, direct_Stasis, RW_Stasis, direct_RW_stasis)
passed_RW<-rep(NA, nrow(indata_3_modes))
passed_directional<-rep(NA, nrow(indata_3_modes))
passed_stasis<-rep(NA, nrow(indata_3_modes))
for (i in 1:nrow(indata_3_modes)){
if (indata_3_modes[i,13] == "PASSED" & indata_3_modes[i,18]=="PASSED" & indata_3_modes[i,23]=="PASSED" & indata_3_modes[i,28]=="PASSED") passed_stasis[i]<-"PASSED" else passed_stasis[i]<-"FAILED"
if (indata_3_modes[i,51] == "PASSED" & indata_3_modes[i,56]=="PASSED" & indata_3_modes[i,61]=="PASSED" ) passed_directional[i]<-"PASSED" else passed_directional[i]<-"FAILED"
if (indata_3_modes[i,34] == "PASSED" & indata_3_modes[i,39]=="PASSED" & indata_3_modes[i,44]=="PASSED" ) passed_RW[i]<-"PASSED" else passed_RW[i]<-"PASSED"
}
#Table summarizing wich data sets where the second best model has a relative fit =< 2AICc units compared to the best model, and to what extent adequacy models help in picking an adequate model:
test_two_aicc_units_difference<-cbind(passed_RW, passed_directional, passed_stasis, direct_RW, direct_Stasis, RW_Stasis, direct_RW_stasis)
# Check models that showed both a relative and absolute fit to the data:
stasis_only<-indata_3_modes[indata_3_modes[, "mode"] == "Stasis",]
BM_only<-indata_3_modes[indata_3_modes[, "mode"] == "Random walk",]
DT_only<-indata_3_modes[indata_3_modes[, "mode"] == "Directional",]
adequate_stasis.models<-rep(NA, nrow(stasis_only))
adequate_BM.models<-rep(NA, nrow(BM_only))
adequate_DT.models<-rep(NA, nrow(DT_only))
for (i in 1:length(stasis_only[,1])){
if (stasis_only[i,13] == "FAILED" | stasis_only[i,18]=="FAILED" | stasis_only[i,23]=="FAILED" | stasis_only[i,28]=="FAILED") adequate_stasis.models[i]<-FALSE else adequate_stasis.models[i]<-TRUE
}
for (i in 1:length(BM_only[,1])){
if (BM_only[i,34] == "FAILED" | BM_only[i,39]=="FAILED" | BM_only[i,44]=="FAILED") adequate_BM.models[i]<-FALSE else adequate_BM.models[i]<-TRUE
}
for (i in 1:length(DT_only[,1])){
if (DT_only[i,51] == "FAILED" | DT_only[i,56]=="FAILED" | DT_only[i,61]=="FAILED") adequate_DT.models[i]<-FALSE else adequate_DT.models[i]<-TRUE
}
# Combine data frames:
temp_data.frame<-as.data.frame(rbind(stasis_only[,1:67], BM_only[,1:67] ,DT_only[,1:67]))
new_3_modes<-cbind(temp_data.frame,c(adequate_stasis.models, adequate_BM.models, adequate_DT.models))
dim(new_3_modes)
names(new_3_modes)[68]<-"adequate"
stasis_models<-cbind(stasis_only, adequate_stasis.models)
BM_models<-cbind(BM_only, adequate_BM.models)
DT_models<-cbind(DT_only, adequate_DT.models)
# Remove lineages that failed to fit the model adequacy criteria:
new_3_modes_adequate<-new_3_modes[new_3_modes[, "adequate"] == "TRUE",]
dim(new_3_modes_adequate)
table(new_3_modes_adequate$mode)
### Done preparing data frames ###
#########
######### Analyze time series
#########
######## STASIS ########
#Filter out the data sets that fitted the stasis model in an adequate way
stasis_adequate<-stasis_models[stasis_models[, "adequate_stasis.models"] == "TRUE",]
dim(stasis_adequate)
######## BM ########
#Filter out the data sets that fitted the BM model in an adequate way
BM_adequate<-BM_models[BM_models[, "adequate_BM.models"] == "TRUE",]
dim(BM_adequate)
######## Directional change ########
#Filter out the data sets that fitted the DT model in an adequate way
DT_adequate<-DT_models[DT_models[, "adequate_DT.models"] == "TRUE",]
dim(DT_adequate)
####### Case studies
### Comparing the rate of evolution in coccoliths
# Success BM
indata<-read.table(temp[6], header=T)
y<-as.paleoTS(indata$mm, indata$vv, indata$N, indata$age.in.MY)
if (indata$log[1] =="no") y<-ln.paleoTS(y);
if (indata$dimension[1] =="area") y$mm<-y$mm/2; y$vv<-y$vv/4;
par(mfrow=c(1,1))
plot.paleoTS(y)
fit3models(y, method = "Joint")
fit3adequacy.RW(y, nrep=1000, plot = TRUE)
fit3adequacy.trend(y, nrep=1000, plot = TRUE)
# Failure Stasis
indata<-read.table(temp[65], header=T)
y<-as.paleoTS(indata$mm, indata$vv, indata$N, indata$age.in.MY)
if (indata$log[1] =="no") y<-ln.paleoTS(y);
if (indata$dimension[1] =="area") y$mm<-y$mm/2; y$vv<-y$vv/4;
plot.paleoTS(y)
fit3models(y, method = "Joint", pool=FALSE)
fit4adequacy.stasis(y,nrep=1000, plot = TRUE)
fit3adequacy.RW(y, nrep=1000, plot = TRUE)
fit3adequacy.trend(y, nrep=1000, plot = TRUE)
# Failure DT
indata<-read.table(temp[48], header=T)
y<-as.paleoTS(indata$mm, indata$vv, indata$N, indata$age.in.MY)
if (indata$log[1] =="no") y<-ln.paleoTS(y);
if (indata$dimension[1] =="area") y$mm<-y$mm/2; y$vv<-y$vv/4;
layout(1:1)
plot.paleoTS(y)
fit3models(y, method = "Joint")
fit3adequacy.trend(y, nrep=1000, plot = TRUE)
fit3adequacy.RW(y, nrep=1000, plot = TRUE)
###################
################### Model adequacy when not the best model according to AICc
### BM adequate model when stasis shows best relative fit
adequate_BM.stasis.best<-rep(NA, length(stasis_adequate[,1]))
for (i in 1:length(adequate_BM.stasis.best)){
if (stasis_adequate[i,34] == "PASSED" & stasis_adequate[i,39]=="PASSED" & stasis_adequate[i,44]=="PASSED") adequate_BM.stasis.best[i]<-TRUE else adequate_BM.stasis.best[i]<-FALSE
}
table(adequate_BM.stasis.best)
### DT adequate model when stasis shows best relative fit
adequate_DT.stasis.best<-rep(NA, length(stasis_adequate[,1]))
for (i in 1:length(adequate_DT.stasis.best)){
if (stasis_adequate[i,51] == "PASSED" & stasis_adequate[i,56]=="PASSED" & stasis_adequate[i,61]=="PASSED" ) adequate_DT.stasis.best[i]<-TRUE else adequate_DT.stasis.best[i]<-FALSE
}
table(adequate_DT.stasis.best)
### DT adequate model when BM shows best relative fit
adequate_DT.BM.best<-rep(NA, length(BM_adequate[,1]))
for (i in 1:length(adequate_DT.BM.best)){
if (BM_adequate[i,51] == "PASSED" & BM_adequate[i,56]=="PASSED" & BM_adequate[i,61]=="PASSED" ) adequate_DT.BM.best[i]<-TRUE else adequate_DT.BM.best[i]<-FALSE
}
table(adequate_DT.BM.best)
### stasis adequate model when BM shows best relative fit
adequate_stasis.BM.best<-rep(NA, length(BM_adequate[,1]))
for (i in 1:length(adequate_DT.BM.best)){
if (BM_adequate[i,13] == "PASSED" & BM_adequate[i,18]=="PASSED" & BM_adequate[i,23]=="PASSED" & BM_adequate[i,28]=="PASSED") adequate_stasis.BM.best[i]<-TRUE else adequate_stasis.BM.best[i]<-FALSE
}
table(adequate_stasis.BM.best)
### BM adequate model when DT shows best relative fit
adequate_BM.DT.best<-rep(NA, length(DT_adequate[,1]))
for (i in 1:length(adequate_BM.DT.best)){
if (DT_adequate[i,34] == "PASSED" & DT_adequate[i,39]=="PASSED" & DT_adequate[i,44]=="PASSED") adequate_BM.DT.best[i]<-TRUE else adequate_BM.DT.best[i]<-FALSE
}
table(adequate_BM.DT.best)
### stasis adequate model when DT shows best relative fit
adequate_stasis.DT.best<-rep(NA, length(DT_adequate[,1]))
for (i in 1:length(adequate_stasis.DT.best)){
if (DT_adequate[i,13] == "PASSED" & DT_adequate[i,18]=="PASSED" & DT_adequate[i,23]=="PASSED" & DT_adequate[i,28]=="PASSED") adequate_stasis.DT.best[i]<-TRUE else adequate_stasis.DT.best[i]<-FALSE
}
table(adequate_stasis.DT.best)
|
library(data.table)
library(lubridate)
library(ggplot2)
library(VORtex)
library(pracma)
data.dt = as.data.table(read.csv("covid-confirmed-deaths-since-5th-death.csv"))
names(data.dt) = c('entity', 'code', 'date', 'deaths', 'days.since')
data.dt[, date := parse_date_time(as.character(date), orders="bdy")]
setkey(data.dt, entity, date)
data.dt[, d.deaths := deaths - VORtex::ts.lag(deaths, 1), by = entity]
# print total deaths summary
max.deaths.dt = data.dt[, list(max.deaths=max(deaths)), by = entity]
writelog("summary of max.deaths:")
summary(max.deaths.dt$max.deaths)
writelog("entities: %s", length(unique(data.dt$entity)))
sub.data.dt = data.dt[is.element(entity, max.deaths.dt[max.deaths >= 500]$entity)]
writelog("entities with more than 500 deaths: %s", length(unique(sub.data.dt$entity)))
non.countries = c("Africa", "Asia", "Asia excl. China", "Europe", "European Union", "High income", "Lower middle income", "North America", "South America", "Upper middle income", "World", "World excl. China", "World excl. China and South Korea", "World excl. China, South Korea, Japan and Singapore")
sub.data.dt = sub.data.dt[!is.element(entity, non.countries)]
sub.data.dt[, week := as.integer((.N - seq(.N)) / 7), by = entity]
byweek.dt = sub.data.dt[, list(d.deaths = sum(d.deaths)), keyby = list(entity, week)]
do.plot(byweek.dt, "week", "ourworldindata_500_countries_revweek.pdf")
peak.week.dt = byweek.dt[, list(peak.week = which.max(d.deaths)), by = entity]
peak.countries = peak.week.dt[peak.week >= 3, entity]
peak.dt = sub.data.dt[is.element(entity, peak.countries)]
do.plot(peak.dt, "date", "ourworldindata_500_countries_oldpeak.pdf")
# clean outliers
peak.dt[d.deaths == 0, d.deaths := NA]
peak.dt[, mean.d.deaths := ts.lag(ts.roll.mean(d.deaths, 3), 1), by = entity]
peak.dt[, mean.d.deaths.lag := ts.lag(mean.d.deaths, -2), by = entity]
do.plot = function(data.dt, x.name, path = NULL) {
if (!is.null(path)) {
pdf(width=10, height=3*length(unique(data.dt$entity)), file=path)
}
p = ggplot(data.dt, aes(x=get(x.name), y=d.deaths)) + facet_grid(entity~., scales="free") + geom_step() + labs(x=x.name)
print(p)
if (!is.null(path)) {
dev.off()
}
}
deaths.m = dcast(peak.dt[!is.na(days.since)], entity ~ days.since, value.var = "d.deaths", fill=NA_real_)
entities = deaths.m$entity
deaths.m[, entity := NULL]
deaths.m = as.matrix(deaths.m)
rownames(deaths.m) = entities
num.countries = nrow(deaths.m)
num.dates = ncol(deaths.m)
source("opt.R")
#compute.deaths(2, 10, c(1,1), c(1,1), 1, 1, c(1,1), c(1,1))
| /a.R | no_license | wmusial/covid | R | false | false | 2,549 | r | library(data.table)
library(lubridate)
library(ggplot2)
library(VORtex)
library(pracma)
data.dt = as.data.table(read.csv("covid-confirmed-deaths-since-5th-death.csv"))
names(data.dt) = c('entity', 'code', 'date', 'deaths', 'days.since')
data.dt[, date := parse_date_time(as.character(date), orders="bdy")]
setkey(data.dt, entity, date)
data.dt[, d.deaths := deaths - VORtex::ts.lag(deaths, 1), by = entity]
# print total deaths summary
max.deaths.dt = data.dt[, list(max.deaths=max(deaths)), by = entity]
writelog("summary of max.deaths:")
summary(max.deaths.dt$max.deaths)
writelog("entities: %s", length(unique(data.dt$entity)))
sub.data.dt = data.dt[is.element(entity, max.deaths.dt[max.deaths >= 500]$entity)]
writelog("entities with more than 500 deaths: %s", length(unique(sub.data.dt$entity)))
non.countries = c("Africa", "Asia", "Asia excl. China", "Europe", "European Union", "High income", "Lower middle income", "North America", "South America", "Upper middle income", "World", "World excl. China", "World excl. China and South Korea", "World excl. China, South Korea, Japan and Singapore")
sub.data.dt = sub.data.dt[!is.element(entity, non.countries)]
sub.data.dt[, week := as.integer((.N - seq(.N)) / 7), by = entity]
byweek.dt = sub.data.dt[, list(d.deaths = sum(d.deaths)), keyby = list(entity, week)]
do.plot(byweek.dt, "week", "ourworldindata_500_countries_revweek.pdf")
peak.week.dt = byweek.dt[, list(peak.week = which.max(d.deaths)), by = entity]
peak.countries = peak.week.dt[peak.week >= 3, entity]
peak.dt = sub.data.dt[is.element(entity, peak.countries)]
do.plot(peak.dt, "date", "ourworldindata_500_countries_oldpeak.pdf")
# clean outliers
peak.dt[d.deaths == 0, d.deaths := NA]
peak.dt[, mean.d.deaths := ts.lag(ts.roll.mean(d.deaths, 3), 1), by = entity]
peak.dt[, mean.d.deaths.lag := ts.lag(mean.d.deaths, -2), by = entity]
do.plot = function(data.dt, x.name, path = NULL) {
if (!is.null(path)) {
pdf(width=10, height=3*length(unique(data.dt$entity)), file=path)
}
p = ggplot(data.dt, aes(x=get(x.name), y=d.deaths)) + facet_grid(entity~., scales="free") + geom_step() + labs(x=x.name)
print(p)
if (!is.null(path)) {
dev.off()
}
}
deaths.m = dcast(peak.dt[!is.na(days.since)], entity ~ days.since, value.var = "d.deaths", fill=NA_real_)
entities = deaths.m$entity
deaths.m[, entity := NULL]
deaths.m = as.matrix(deaths.m)
rownames(deaths.m) = entities
num.countries = nrow(deaths.m)
num.dates = ncol(deaths.m)
source("opt.R")
#compute.deaths(2, 10, c(1,1), c(1,1), 1, 1, c(1,1), c(1,1))
|
Sys.setenv("plotly_username"="sarthak12")
Sys.setenv("plotly_api_key"="ww0uv901l0")
library(OIsurv)
library(devtools)
library(plotly)
library(IRdisplay)
library(ggplot2)
library(survival)
library(GGally)
data(cancer, package = "survival")
summary(cancer)
head(cancer)
attach(cancer)
sf.cancer <- survfit(Surv(time, status) ~ 1, data = cancer)
p <- ggsurv(sf.cancer)
ggplotly(p)
plotly_POST(p, "Survival vs Time")
sf.sex <- survfit(Surv(time, status) ~ sex, data = cancer)
pl.sex <- ggsurv(sf.sex)
ggplotly(pl.sex)
plotly_POST(pl.sex, "Gender wise - Survival vs Time")
| /Assignment 2/Part1/SurvivalAnalysis_plotly.R | no_license | agsarthak/Engineering-of-Big-Data-systems-INFO7350 | R | false | false | 575 | r | Sys.setenv("plotly_username"="sarthak12")
Sys.setenv("plotly_api_key"="ww0uv901l0")
library(OIsurv)
library(devtools)
library(plotly)
library(IRdisplay)
library(ggplot2)
library(survival)
library(GGally)
data(cancer, package = "survival")
summary(cancer)
head(cancer)
attach(cancer)
sf.cancer <- survfit(Surv(time, status) ~ 1, data = cancer)
p <- ggsurv(sf.cancer)
ggplotly(p)
plotly_POST(p, "Survival vs Time")
sf.sex <- survfit(Surv(time, status) ~ sex, data = cancer)
pl.sex <- ggsurv(sf.sex)
ggplotly(pl.sex)
plotly_POST(pl.sex, "Gender wise - Survival vs Time")
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/write.R
\name{write_stars}
\alias{write_stars}
\alias{write_stars.stars}
\alias{write_stars.stars_proxy}
\alias{detect.driver}
\title{write stars object to gdal dataset (typically: to file)}
\usage{
write_stars(obj, dsn, layer, ...)
\method{write_stars}{stars}(
obj,
dsn,
layer = 1,
...,
driver = detect.driver(dsn),
options = character(0),
type = "Float32",
NA_value = NA_real_,
update = FALSE,
normalize_path = TRUE
)
\method{write_stars}{stars_proxy}(
obj,
dsn,
layer = 1,
...,
driver = detect.driver(dsn),
options = character(0),
type = "Float32",
NA_value = NA_real_,
chunk_size = c(dim(obj)[1], floor(2.5e+07/dim(obj)[1])),
progress = TRUE
)
detect.driver(filename)
}
\arguments{
\item{obj}{object of class \code{stars}}
\item{dsn}{gdal dataset (file) name}
\item{layer}{attribute name; if missing, the first attribute is written}
\item{...}{passed on to \link[sf:gdal]{gdal_write}}
\item{driver}{driver driver name; see \link[sf]{st_drivers}}
\item{options}{character vector with options}
\item{type}{character; output binary type, one of: \code{Byte} for eight bit unsigned integer, \code{UInt16} for sixteen bit unsigned integer, \code{Int16} for sixteen bit signed integer, \code{UInt32} for thirty two bit unsigned integer, \code{Int32} for thirty two bit signed integer, \code{Float32} for thirty two bit floating point, \code{Float64} for sixty four bit floating point.}
\item{NA_value}{non-NA value that should represent R's \code{NA} value in the target raster file; if set to \code{NA}, it will be ignored.}
\item{update}{logical; if \code{TRUE}, an existing file is being updated}
\item{normalize_path}{logical; see \link{read_stars}}
\item{chunk_size}{length two integer vector with the number of pixels (x, y) used in the read/write loop; see details.}
\item{progress}{logical; if \code{TRUE}, a progress bar is shown}
\item{filename}{character; used for guessing driver short name based on file
extension; see examples}
}
\description{
write stars object to gdal dataset (typically: to file)
}
\details{
\code{write_stars} first creates the target file, then updates it sequentially by writing blocks of \code{chunk_size}.
}
\examples{
detect.driver("L7_ETMs.tif")
}
| /man/write_stars.Rd | permissive | michaeldorman/stars | R | false | true | 2,321 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/write.R
\name{write_stars}
\alias{write_stars}
\alias{write_stars.stars}
\alias{write_stars.stars_proxy}
\alias{detect.driver}
\title{write stars object to gdal dataset (typically: to file)}
\usage{
write_stars(obj, dsn, layer, ...)
\method{write_stars}{stars}(
obj,
dsn,
layer = 1,
...,
driver = detect.driver(dsn),
options = character(0),
type = "Float32",
NA_value = NA_real_,
update = FALSE,
normalize_path = TRUE
)
\method{write_stars}{stars_proxy}(
obj,
dsn,
layer = 1,
...,
driver = detect.driver(dsn),
options = character(0),
type = "Float32",
NA_value = NA_real_,
chunk_size = c(dim(obj)[1], floor(2.5e+07/dim(obj)[1])),
progress = TRUE
)
detect.driver(filename)
}
\arguments{
\item{obj}{object of class \code{stars}}
\item{dsn}{gdal dataset (file) name}
\item{layer}{attribute name; if missing, the first attribute is written}
\item{...}{passed on to \link[sf:gdal]{gdal_write}}
\item{driver}{driver driver name; see \link[sf]{st_drivers}}
\item{options}{character vector with options}
\item{type}{character; output binary type, one of: \code{Byte} for eight bit unsigned integer, \code{UInt16} for sixteen bit unsigned integer, \code{Int16} for sixteen bit signed integer, \code{UInt32} for thirty two bit unsigned integer, \code{Int32} for thirty two bit signed integer, \code{Float32} for thirty two bit floating point, \code{Float64} for sixty four bit floating point.}
\item{NA_value}{non-NA value that should represent R's \code{NA} value in the target raster file; if set to \code{NA}, it will be ignored.}
\item{update}{logical; if \code{TRUE}, an existing file is being updated}
\item{normalize_path}{logical; see \link{read_stars}}
\item{chunk_size}{length two integer vector with the number of pixels (x, y) used in the read/write loop; see details.}
\item{progress}{logical; if \code{TRUE}, a progress bar is shown}
\item{filename}{character; used for guessing driver short name based on file
extension; see examples}
}
\description{
write stars object to gdal dataset (typically: to file)
}
\details{
\code{write_stars} first creates the target file, then updates it sequentially by writing blocks of \code{chunk_size}.
}
\examples{
detect.driver("L7_ETMs.tif")
}
|
#########################################################################################################
#
# Machine Learning Based Estimation of Average Treatment Effects under Unconfoundedness
#
# Elias Moor, ETHZ
#
# Description: This file defines the "DGP Settings" tab of the UI
#
#########################################################################################################
list(
conditionalPanel(condition = "input.datatype == 'simulate_diamond1'", ##############################################
conditionalPanel(condition = "input.comparison_mode != 'analysis' | (input.comparison_mode == 'analysis' &
input.analysisDim != 'linAdd')",
# Select D~X relationship
selectInput(inputId = "scenarioD",
label = "D~X relationship:",
choices = choices_DX,
selected = "DG"),
# Select Y~X relationship
selectInput(inputId = "scenarioY",
label = "Y~X relationship:",
choices = choices_YX,
selected = "YG"))
),
conditionalPanel(condition = "input.datatype == 'simulate_diamond1' | input.datatype == 'simulate_busso'", #######################
conditionalPanel(condition = "input.comparison_mode != 'analysis' | (input.comparison_mode == 'analysis' &
input.analysisDim != 'n_sim')",
# Select number of observations
selectInput(inputId = "n_sim",
label = "Number of Observations:",
choices = c("250" = "250",
"500" = "500",
"1000" = "1000",
"2000" = "2000",
"5000" = "5000"),
selected = "1000")),
conditionalPanel(condition = "input.comparison_mode != 'analysis' | (input.comparison_mode == 'analysis' &
input.analysisDim != 'select_into_D')",
# Select selection into treatment
selectInput(inputId = "select_into_D",
label = "Strength Selection into Treatment:",
choices = c("Strong (2)" = "2",
"Default (1)" = "1",
"Reduced (0.5)" = "0.5",
"Weak (0.2)" = "0.2",
"Random (0)" = "0"),
selected = "1")),
conditionalPanel(condition = "input.comparison_mode != 'analysis' | (input.comparison_mode == 'analysis' &
input.analysisDim != 'Ynoise')",
# Select whether additional noise is added to Y1/Y0
selectInput(inputId = "Ynoise",
label = "Noise in Outcome Specification:",
choices = choices_Ynoise,
selected = "1"))
),
conditionalPanel(condition = "input.datatype == 'real_nsw'", ##############################################
# Select gender
selectInput(inputId = "gender",
label = "Gender:",
choices = c("Men" = "men",
"Women" = "women"),
selected = "men"),
# Select subsample
selectInput(inputId = "subsample",
label = "Subsample:",
choices = c("Lalonde" = "Lalonde",
"Dehejia/Wahba" = "Dehejia",
"Smith/Todd" = "SmithTodd"),
selected = "Dehejia"),
# Select experimental group
selectInput(inputId = "exper_group",
label = "Experimental group:",
choices = c("Treatment" = "treat",
"Control" = "control"),
selected = "control"),
conditionalPanel(condition = "input.gender == 'women'", ######################
# Select comparison group
selectInput(inputId = "comp_group_women",
label = "Comparison group:",
choices = c("NSW" = "nsw",
"PSID1" = "psid1",
"PSID2" = "psid2"),
selected = "psid1")
),
conditionalPanel(condition = "input.gender == 'men'", ######################
# Select comparison group
selectInput(inputId = "comp_group_men",
label = "Comparison group:",
choices = c("NSW" = "nsw",
"PSID1" = "psid1",
"PSID2" = "psid2",
"PSID3" = "psid3",
"CPS1" = "cps1",
"CPS2" = "cps2",
"CPS3" = "cps3"),
selected = "psid1")
)
)
)
| /Shiny App/UI_Side_DGP.R | no_license | emoor/mlevaluation | R | false | false | 5,374 | r | #########################################################################################################
#
# Machine Learning Based Estimation of Average Treatment Effects under Unconfoundedness
#
# Elias Moor, ETHZ
#
# Description: This file defines the "DGP Settings" tab of the UI
#
#########################################################################################################
list(
conditionalPanel(condition = "input.datatype == 'simulate_diamond1'", ##############################################
conditionalPanel(condition = "input.comparison_mode != 'analysis' | (input.comparison_mode == 'analysis' &
input.analysisDim != 'linAdd')",
# Select D~X relationship
selectInput(inputId = "scenarioD",
label = "D~X relationship:",
choices = choices_DX,
selected = "DG"),
# Select Y~X relationship
selectInput(inputId = "scenarioY",
label = "Y~X relationship:",
choices = choices_YX,
selected = "YG"))
),
conditionalPanel(condition = "input.datatype == 'simulate_diamond1' | input.datatype == 'simulate_busso'", #######################
conditionalPanel(condition = "input.comparison_mode != 'analysis' | (input.comparison_mode == 'analysis' &
input.analysisDim != 'n_sim')",
# Select number of observations
selectInput(inputId = "n_sim",
label = "Number of Observations:",
choices = c("250" = "250",
"500" = "500",
"1000" = "1000",
"2000" = "2000",
"5000" = "5000"),
selected = "1000")),
conditionalPanel(condition = "input.comparison_mode != 'analysis' | (input.comparison_mode == 'analysis' &
input.analysisDim != 'select_into_D')",
# Select selection into treatment
selectInput(inputId = "select_into_D",
label = "Strength Selection into Treatment:",
choices = c("Strong (2)" = "2",
"Default (1)" = "1",
"Reduced (0.5)" = "0.5",
"Weak (0.2)" = "0.2",
"Random (0)" = "0"),
selected = "1")),
conditionalPanel(condition = "input.comparison_mode != 'analysis' | (input.comparison_mode == 'analysis' &
input.analysisDim != 'Ynoise')",
# Select whether additional noise is added to Y1/Y0
selectInput(inputId = "Ynoise",
label = "Noise in Outcome Specification:",
choices = choices_Ynoise,
selected = "1"))
),
conditionalPanel(condition = "input.datatype == 'real_nsw'", ##############################################
# Select gender
selectInput(inputId = "gender",
label = "Gender:",
choices = c("Men" = "men",
"Women" = "women"),
selected = "men"),
# Select subsample
selectInput(inputId = "subsample",
label = "Subsample:",
choices = c("Lalonde" = "Lalonde",
"Dehejia/Wahba" = "Dehejia",
"Smith/Todd" = "SmithTodd"),
selected = "Dehejia"),
# Select experimental group
selectInput(inputId = "exper_group",
label = "Experimental group:",
choices = c("Treatment" = "treat",
"Control" = "control"),
selected = "control"),
conditionalPanel(condition = "input.gender == 'women'", ######################
# Select comparison group
selectInput(inputId = "comp_group_women",
label = "Comparison group:",
choices = c("NSW" = "nsw",
"PSID1" = "psid1",
"PSID2" = "psid2"),
selected = "psid1")
),
conditionalPanel(condition = "input.gender == 'men'", ######################
# Select comparison group
selectInput(inputId = "comp_group_men",
label = "Comparison group:",
choices = c("NSW" = "nsw",
"PSID1" = "psid1",
"PSID2" = "psid2",
"PSID3" = "psid3",
"CPS1" = "cps1",
"CPS2" = "cps2",
"CPS3" = "cps3"),
selected = "psid1")
)
)
)
|
#' An indexed array.
#'
#' Create a indexed array, a space efficient way of indexing into a large
#' array.
#'
#' @param env environment containing data frame
#' @param index list of indices
#' @keywords internal
#' @aliases indexed_array [[.indexed_array names.indexed_array
#' length.indexed_array
indexed_array <- function(env, index) {
exact <- all(unlist(llply(index, is.numeric)))
# Situations that should use [
# * data.frame
# * normal array
# * normal vector
# * list-array with inexact indexing
#
# Situations that should use [[
# * list
# * list-array with exact indexing
if (is.list(env$data)) {
if (is.data.frame(env$data) || (is.array(env$data) && !exact)) {
subs <- "["
} else {
subs <- "[["
}
} else {
subs <- "["
}
# Don't drop if data is a data frame
drop <- !is.data.frame(env$data)
structure(
list(env = env, index = index, drop = drop, subs = as.name(subs)),
class = c("indexed_array", "indexed")
)
}
#' @S3method length indexed_array
length.indexed_array <- function(x) nrow(x$index)
#' @S3method [[ indexed_array
"[[.indexed_array" <- function(x, i) {
indices <- unname(x$index[i, , drop = TRUE])
indices <- lapply(indices, function(x) if (x == "") bquote() else x)
call <- as.call(c(
list(x$subs, quote(x$env$data)),
indices,
list(drop = x$drop)))
eval(call)
}
#' @S3method names indexed
names.indexed_array <- function(x) rownames(x$index)
| /R/indexed-array.r | no_license | talgalili/plyr | R | false | false | 1,477 | r | #' An indexed array.
#'
#' Create a indexed array, a space efficient way of indexing into a large
#' array.
#'
#' @param env environment containing data frame
#' @param index list of indices
#' @keywords internal
#' @aliases indexed_array [[.indexed_array names.indexed_array
#' length.indexed_array
indexed_array <- function(env, index) {
exact <- all(unlist(llply(index, is.numeric)))
# Situations that should use [
# * data.frame
# * normal array
# * normal vector
# * list-array with inexact indexing
#
# Situations that should use [[
# * list
# * list-array with exact indexing
if (is.list(env$data)) {
if (is.data.frame(env$data) || (is.array(env$data) && !exact)) {
subs <- "["
} else {
subs <- "[["
}
} else {
subs <- "["
}
# Don't drop if data is a data frame
drop <- !is.data.frame(env$data)
structure(
list(env = env, index = index, drop = drop, subs = as.name(subs)),
class = c("indexed_array", "indexed")
)
}
#' @S3method length indexed_array
length.indexed_array <- function(x) nrow(x$index)
#' @S3method [[ indexed_array
"[[.indexed_array" <- function(x, i) {
indices <- unname(x$index[i, , drop = TRUE])
indices <- lapply(indices, function(x) if (x == "") bquote() else x)
call <- as.call(c(
list(x$subs, quote(x$env$data)),
indices,
list(drop = x$drop)))
eval(call)
}
#' @S3method names indexed
names.indexed_array <- function(x) rownames(x$index)
|
test_that("getDateFromFilePath works", {
d <- datetimeutil$new()
epoch <- d$getDateFromFilePath("20150105","08:59:34","%Y%m%d %H:%M:%S")
expect_equal(1420448374,epoch)
})
test_that("isOverlappingPeriod with overlapping", {
d <- datetimeutil$new()
isOverlap <- d$isOverlappingPeriod(1420448374,1420459414,1420444500,1420453620,600)
expect_equal(TRUE,isOverlap)
})
test_that("isOverlappingPeriod with no overlapping", {
d <- datetimeutil$new()
isOverlap <- d$isOverlappingPeriod(1420448374,1420459414,1421444500,1421453620,600)
expect_equal(FALSE,isOverlap)
})
| /tests/testthat/test-datetimeutil.R | no_license | minnieteng/vitalsignprocessor | R | false | false | 581 | r | test_that("getDateFromFilePath works", {
d <- datetimeutil$new()
epoch <- d$getDateFromFilePath("20150105","08:59:34","%Y%m%d %H:%M:%S")
expect_equal(1420448374,epoch)
})
test_that("isOverlappingPeriod with overlapping", {
d <- datetimeutil$new()
isOverlap <- d$isOverlappingPeriod(1420448374,1420459414,1420444500,1420453620,600)
expect_equal(TRUE,isOverlap)
})
test_that("isOverlappingPeriod with no overlapping", {
d <- datetimeutil$new()
isOverlap <- d$isOverlappingPeriod(1420448374,1420459414,1421444500,1421453620,600)
expect_equal(FALSE,isOverlap)
})
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot_wide_cor.R
\name{plot_wide_cor}
\alias{plot_wide_cor}
\title{Plot wide formated dataframe correlations per clone
in log scale}
\usage{
plot_wide_cor(wf_wide, main = "Correlation", ...)
}
\arguments{
\item{wf_wide}{wide formatted data by clone}
}
\value{
\code{pairs} plot of correlation
}
\description{
Plot wide formated dataframe correlations per clone
in log scale
}
\examples{
# plot_wide.cor(efficacy.list(ef)$mean)
}
| /man/plot_wide_cor.Rd | no_license | faustovrz/bugcount | R | false | true | 506 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot_wide_cor.R
\name{plot_wide_cor}
\alias{plot_wide_cor}
\title{Plot wide formated dataframe correlations per clone
in log scale}
\usage{
plot_wide_cor(wf_wide, main = "Correlation", ...)
}
\arguments{
\item{wf_wide}{wide formatted data by clone}
}
\value{
\code{pairs} plot of correlation
}
\description{
Plot wide formated dataframe correlations per clone
in log scale
}
\examples{
# plot_wide.cor(efficacy.list(ef)$mean)
}
|
########## repair_data import ############
RepairExample_English <- read_csv("data/RepairExample_English.csv", na = c("", "NA"),
col_types = cols(caseID = col_character() , RepairCode = col_character(),
timestamp = col_datetime(format = "%Y-%m-%d %H:%M"),
objectKey = col_character()))
######### transform ###############
RepairExample_English$caseID <- as.factor(RepairExample_English$caseID)
RepairExample_English$taskID <- as.factor(RepairExample_English$taskID)
RepairExample_English$originator <- as.factor(RepairExample_English$originator)
RepairExample_English$eventtype <- as.factor(RepairExample_English$eventtype)
RepairExample_English$contact <- as.factor(RepairExample_English$contact)
RepairExample_English$objectKey <- as.factor(RepairExample_English$objectKey)
RepairExample_English$RepairCode <- as.factor(RepairExample_English$RepairCode)
RepairExample_English$RepairType <- as.factor(RepairExample_English$RepairType)
repair_process_df <- RepairExample_English %>% select(caseID,taskID,originator,eventtype,timestamp)
repair_attribute_df <- RepairExample_English %>% select(caseID,contact,RepairType,objectKey,RepairInternally,
EstimatedRepairTime,RepairCode,RepairOK)
| /munge/01-repair_data_example.R | no_license | chickchop/repair_data_analysis | R | false | false | 1,378 | r | ########## repair_data import ############
RepairExample_English <- read_csv("data/RepairExample_English.csv", na = c("", "NA"),
col_types = cols(caseID = col_character() , RepairCode = col_character(),
timestamp = col_datetime(format = "%Y-%m-%d %H:%M"),
objectKey = col_character()))
######### transform ###############
RepairExample_English$caseID <- as.factor(RepairExample_English$caseID)
RepairExample_English$taskID <- as.factor(RepairExample_English$taskID)
RepairExample_English$originator <- as.factor(RepairExample_English$originator)
RepairExample_English$eventtype <- as.factor(RepairExample_English$eventtype)
RepairExample_English$contact <- as.factor(RepairExample_English$contact)
RepairExample_English$objectKey <- as.factor(RepairExample_English$objectKey)
RepairExample_English$RepairCode <- as.factor(RepairExample_English$RepairCode)
RepairExample_English$RepairType <- as.factor(RepairExample_English$RepairType)
repair_process_df <- RepairExample_English %>% select(caseID,taskID,originator,eventtype,timestamp)
repair_attribute_df <- RepairExample_English %>% select(caseID,contact,RepairType,objectKey,RepairInternally,
EstimatedRepairTime,RepairCode,RepairOK)
|
library(MXM)
### Name: Backward phase of MMPC
### Title: Backward phase of MMPC
### Aliases: mmpcbackphase
### Keywords: SES Multiple Feature Signatures Feature Selection Variable
### Selection
### ** Examples
set.seed(123)
#simulate a dataset with continuous data
dataset <- matrix(runif(1000 * 200, 1, 100), ncol = 200)
#define a simulated class variable
target <- 3 * dataset[, 10] + 2 * dataset[, 100] + 3 * dataset[, 20] + rnorm(1000, 0, 5)
# define some simulated equivalences
dataset[, 15] <- dataset[, 10] + rnorm(1000, 0, 2)
dataset[, 150] <- dataset[, 100] + rnorm(1000, 0, 2)
dataset[, 130] <- dataset[, 100] + rnorm(1000, 0, 2)
# MMPC algorithm
m1 <- MMPC(target, dataset, max_k = 3, threshold = 0.05, test="testIndFisher");
m2 <- MMPC(target, dataset, max_k = 3, threshold = 0.05, test="testIndFisher", backward = TRUE);
x <- dataset[, m1@selectedVars]
mmpcbackphase(target, x, test = testIndFisher)
| /data/genthat_extracted_code/MXM/examples/mmpcbackphase.Rd.R | no_license | surayaaramli/typeRrh | R | false | false | 929 | r | library(MXM)
### Name: Backward phase of MMPC
### Title: Backward phase of MMPC
### Aliases: mmpcbackphase
### Keywords: SES Multiple Feature Signatures Feature Selection Variable
### Selection
### ** Examples
set.seed(123)
#simulate a dataset with continuous data
dataset <- matrix(runif(1000 * 200, 1, 100), ncol = 200)
#define a simulated class variable
target <- 3 * dataset[, 10] + 2 * dataset[, 100] + 3 * dataset[, 20] + rnorm(1000, 0, 5)
# define some simulated equivalences
dataset[, 15] <- dataset[, 10] + rnorm(1000, 0, 2)
dataset[, 150] <- dataset[, 100] + rnorm(1000, 0, 2)
dataset[, 130] <- dataset[, 100] + rnorm(1000, 0, 2)
# MMPC algorithm
m1 <- MMPC(target, dataset, max_k = 3, threshold = 0.05, test="testIndFisher");
m2 <- MMPC(target, dataset, max_k = 3, threshold = 0.05, test="testIndFisher", backward = TRUE);
x <- dataset[, m1@selectedVars]
mmpcbackphase(target, x, test = testIndFisher)
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/repgrid-plots.r
\name{biplotDraw}
\alias{biplotDraw}
\title{biplotDraw is the workhorse doing the drawing of a 2D biplot.}
\usage{
biplotDraw(x, inner.positioning = TRUE, outer.positioning = TRUE,
c.labels.inside = F, flipaxes = c(F, F), strokes.x = 0.1,
strokes.y = 0.1, offsetting = TRUE, offset.labels = 0,
offset.e = 1, axis.ext = 0.1, mai = c(0.2, 1.5, 0.2, 1.5),
rect.margins = c(0.01, 0.01), srt = 45, cex.pos = 0.7,
xpd = TRUE, c.lines = TRUE, col.c.lines = grey(0.9), zoom = 1,
...)
}
\arguments{
\item{x}{\code{repgrid} object.}
\item{inner.positioning}{Logical. Whether to calculate positions to minimize overplotting of
elements and construct labels (default is\code{TRUE}). Note that
the positioning may slow down the plotting.}
\item{outer.positioning}{Logical. Whether to calculate positions to minimize overplotting of
of construct labels on the outer borders (default is\code{TRUE}). Note that
the positioning may slow down the plotting.}
\item{c.labels.inside}{Logical. Whether to print construct labels next to the points.
Can be useful during inspection of the plot (default \code{FALSE}).}
\item{flipaxes}{Logical vector of length two. Whether x and y axes are reversed
(default is \code{c(F,F)}).}
\item{strokes.x}{Length of outer strokes in x direction in NDC.}
\item{strokes.y}{Length of outer strokes in y direction in NDC.}
\item{offsetting}{Do offsetting? (TODO)}
\item{offset.labels}{Offsetting parameter for labels (TODO).}
\item{offset.e}{offsetting parameter for elements (TODO).}
\item{axis.ext}{Axis extension factor (default is \code{.1}). A bigger value will
zoom out the plot.}
\item{mai}{Margins available for plotting the labels in inch
(default is \code{c(.2, 1.5, .2, 1.5)}).}
\item{rect.margins}{Vector of length two (default is \code{c(.07, .07)}). Two values
specifying the additional horizontal and vertical margin around each
label.}
\item{srt}{Angle to rotate construct label text. Only used in case \code{offsetting=FALSE}.}
\item{cex.pos}{Cex parameter used during positioning of labels if prompted. Does
usually not have to be changed by user.}
\item{xpd}{Logical (default is \code{TRUE}). Wether to extend text labels
over figure region. Usually not needed by the user.}
\item{c.lines}{Logical. Whether construct lines from the center of the biplot
to the sourrounding box are drawn (default is \code{FALSE}).}
\item{col.c.lines}{The color of the construct lines from the center to the borders
of the plot (default is \code{gray(.9)}).}
\item{zoom}{Scaling factor for all vectors. Can be used to zoom
the plot in and out (default \code{1}).}
\item{...}{Not evaluated.}
}
\value{
Invisible return of dataframe used during construction of plot
(useful for developers).
}
\description{
When the number of elements and constructs differs to a large extent, the
absolute values of the coordinates for either constructs or elements
will be much smaller or greater. This is an inherent property of the biplot.
In the case it is not necessary to be able to read off the original
data entries from the plot, the axes for elements and constructs
can be scaled seperately. The proportional projection values will
stay unaffetced. the absolue will change though. For grid interpretation
the absolze values are usually oh no importance. Thus, there is an optional
argument \code{normalize} which is \code{FALSE} as a default which
rescales the axes so the longest construct and element vector will be
set to the length of \code{1}.
}
\author{
Mark Heckmann
}
\keyword{internal}
| /man/biplotDraw.Rd | no_license | artoo-git/OpenRepGrid | R | false | true | 3,667 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/repgrid-plots.r
\name{biplotDraw}
\alias{biplotDraw}
\title{biplotDraw is the workhorse doing the drawing of a 2D biplot.}
\usage{
biplotDraw(x, inner.positioning = TRUE, outer.positioning = TRUE,
c.labels.inside = F, flipaxes = c(F, F), strokes.x = 0.1,
strokes.y = 0.1, offsetting = TRUE, offset.labels = 0,
offset.e = 1, axis.ext = 0.1, mai = c(0.2, 1.5, 0.2, 1.5),
rect.margins = c(0.01, 0.01), srt = 45, cex.pos = 0.7,
xpd = TRUE, c.lines = TRUE, col.c.lines = grey(0.9), zoom = 1,
...)
}
\arguments{
\item{x}{\code{repgrid} object.}
\item{inner.positioning}{Logical. Whether to calculate positions to minimize overplotting of
elements and construct labels (default is\code{TRUE}). Note that
the positioning may slow down the plotting.}
\item{outer.positioning}{Logical. Whether to calculate positions to minimize overplotting of
of construct labels on the outer borders (default is\code{TRUE}). Note that
the positioning may slow down the plotting.}
\item{c.labels.inside}{Logical. Whether to print construct labels next to the points.
Can be useful during inspection of the plot (default \code{FALSE}).}
\item{flipaxes}{Logical vector of length two. Whether x and y axes are reversed
(default is \code{c(F,F)}).}
\item{strokes.x}{Length of outer strokes in x direction in NDC.}
\item{strokes.y}{Length of outer strokes in y direction in NDC.}
\item{offsetting}{Do offsetting? (TODO)}
\item{offset.labels}{Offsetting parameter for labels (TODO).}
\item{offset.e}{offsetting parameter for elements (TODO).}
\item{axis.ext}{Axis extension factor (default is \code{.1}). A bigger value will
zoom out the plot.}
\item{mai}{Margins available for plotting the labels in inch
(default is \code{c(.2, 1.5, .2, 1.5)}).}
\item{rect.margins}{Vector of length two (default is \code{c(.07, .07)}). Two values
specifying the additional horizontal and vertical margin around each
label.}
\item{srt}{Angle to rotate construct label text. Only used in case \code{offsetting=FALSE}.}
\item{cex.pos}{Cex parameter used during positioning of labels if prompted. Does
usually not have to be changed by user.}
\item{xpd}{Logical (default is \code{TRUE}). Wether to extend text labels
over figure region. Usually not needed by the user.}
\item{c.lines}{Logical. Whether construct lines from the center of the biplot
to the sourrounding box are drawn (default is \code{FALSE}).}
\item{col.c.lines}{The color of the construct lines from the center to the borders
of the plot (default is \code{gray(.9)}).}
\item{zoom}{Scaling factor for all vectors. Can be used to zoom
the plot in and out (default \code{1}).}
\item{...}{Not evaluated.}
}
\value{
Invisible return of dataframe used during construction of plot
(useful for developers).
}
\description{
When the number of elements and constructs differs to a large extent, the
absolute values of the coordinates for either constructs or elements
will be much smaller or greater. This is an inherent property of the biplot.
In the case it is not necessary to be able to read off the original
data entries from the plot, the axes for elements and constructs
can be scaled seperately. The proportional projection values will
stay unaffetced. the absolue will change though. For grid interpretation
the absolze values are usually oh no importance. Thus, there is an optional
argument \code{normalize} which is \code{FALSE} as a default which
rescales the axes so the longest construct and element vector will be
set to the length of \code{1}.
}
\author{
Mark Heckmann
}
\keyword{internal}
|
#####
#09-29-16- Real data 13
#Network Analysis
####
library(igraph)
library(network)
library(entropy)
#############################################################################
#ADELAIDE
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "ADEL"
KIoutcome = "Goal_F"
ADEL13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
ADEL13_Gg2 <- data.frame(ADEL13_G)
ADEL13_Gg2 <- ADEL13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_Gg2$player1
player2vector <- ADEL13_Gg2$player2
ADEL13_Gg3 <- ADEL13_Gg2
ADEL13_Gg3$p1inp2vec <- is.element(ADEL13_Gg3$player1, player2vector)
ADEL13_Gg3$p2inp1vec <- is.element(ADEL13_Gg3$player2, player1vector)
addPlayer1 <- ADEL13_Gg3[ which(ADEL13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_Gg3[ which(ADEL13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_Gg2 <- rbind(ADEL13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
ADEL13_Gft <- ftable(ADEL13_Gg2$player1, ADEL13_Gg2$player2)
ADEL13_Gft2 <- as.matrix(ADEL13_Gft)
numRows <- nrow(ADEL13_Gft2)
numCols <- ncol(ADEL13_Gft2)
ADEL13_Gft3 <- ADEL13_Gft2[c(2:numRows) , c(2:numCols)]
ADEL13_GTable <- graph.adjacency(ADEL13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(ADEL13_GTable, vertex.label = V(ADEL13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
ADEL13_G.clusterCoef <- transitivity(ADEL13_GTable, type="global") #cluster coefficient
ADEL13_G.degreeCent <- centralization.degree(ADEL13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_Gftn <- as.network.matrix(ADEL13_Gft)
ADEL13_G.netDensity <- network.density(ADEL13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_G.entropy <- entropy(ADEL13_Gft) #entropy
ADEL13_G.netMx <- cbind(ADEL13_G.netMx, ADEL13_G.clusterCoef, ADEL13_G.degreeCent$centralization,
ADEL13_G.netDensity, ADEL13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
#NA
round = 13
teamName = "ADEL"
KIoutcome = "Behind_F"
ADEL13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
ADEL13_Bg2 <- data.frame(ADEL13_B)
ADEL13_Bg2 <- ADEL13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_Bg2$player1
player2vector <- ADEL13_Bg2$player2
ADEL13_Bg3 <- ADEL13_Bg2
ADEL13_Bg3$p1inp2vec <- is.element(ADEL13_Bg3$player1, player2vector)
ADEL13_Bg3$p2inp1vec <- is.element(ADEL13_Bg3$player2, player1vector)
addPlayer1 <- ADEL13_Bg3[ which(ADEL13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_Bg3[ which(ADEL13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_Bg2 <- rbind(ADEL13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
ADEL13_Bft <- ftable(ADEL13_Bg2$player1, ADEL13_Bg2$player2)
ADEL13_Bft2 <- as.matrix(ADEL13_Bft)
numRows <- nrow(ADEL13_Bft2)
numCols <- ncol(ADEL13_Bft2)
ADEL13_Bft3 <- ADEL13_Bft2[c(2:numRows) , c(2:numCols)]
ADEL13_BTable <- graph.adjacency(ADEL13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(ADEL13_BTable, vertex.label = V(ADEL13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
ADEL13_B.clusterCoef <- transitivity(ADEL13_BTable, type="global") #cluster coefficient
ADEL13_B.degreeCent <- centralization.degree(ADEL13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_Bftn <- as.network.matrix(ADEL13_Bft)
ADEL13_B.netDensity <- network.density(ADEL13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_B.entropy <- entropy(ADEL13_Bft) #entropy
ADEL13_B.netMx <- cbind(ADEL13_B.netMx, ADEL13_B.clusterCoef, ADEL13_B.degreeCent$centralization,
ADEL13_B.netDensity, ADEL13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "ADEL"
KIoutcome = "Stoppage_F"
ADEL13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
ADEL13_SFg2 <- data.frame(ADEL13_SF)
ADEL13_SFg2 <- ADEL13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_SFg2$player1
player2vector <- ADEL13_SFg2$player2
ADEL13_SFg3 <- ADEL13_SFg2
ADEL13_SFg3$p1inp2vec <- is.element(ADEL13_SFg3$player1, player2vector)
ADEL13_SFg3$p2inp1vec <- is.element(ADEL13_SFg3$player2, player1vector)
addPlayer1 <- ADEL13_SFg3[ which(ADEL13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_SFg3[ which(ADEL13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_SFg2 <- rbind(ADEL13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
ADEL13_SFft <- ftable(ADEL13_SFg2$player1, ADEL13_SFg2$player2)
ADEL13_SFft2 <- as.matrix(ADEL13_SFft)
numRows <- nrow(ADEL13_SFft2)
numCols <- ncol(ADEL13_SFft2)
ADEL13_SFft3 <- ADEL13_SFft2[c(2:numRows) , c(2:numCols)]
ADEL13_SFTable <- graph.adjacency(ADEL13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(ADEL13_SFTable, vertex.label = V(ADEL13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
ADEL13_SF.clusterCoef <- transitivity(ADEL13_SFTable, type="global") #cluster coefficient
ADEL13_SF.degreeCent <- centralization.degree(ADEL13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_SFftn <- as.network.matrix(ADEL13_SFft)
ADEL13_SF.netDensity <- network.density(ADEL13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_SF.entropy <- entropy(ADEL13_SFft) #entropy
ADEL13_SF.netMx <- cbind(ADEL13_SF.netMx, ADEL13_SF.clusterCoef, ADEL13_SF.degreeCent$centralization,
ADEL13_SF.netDensity, ADEL13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "ADEL"
KIoutcome = "Turnover_F"
ADEL13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
ADEL13_TFg2 <- data.frame(ADEL13_TF)
ADEL13_TFg2 <- ADEL13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_TFg2$player1
player2vector <- ADEL13_TFg2$player2
ADEL13_TFg3 <- ADEL13_TFg2
ADEL13_TFg3$p1inp2vec <- is.element(ADEL13_TFg3$player1, player2vector)
ADEL13_TFg3$p2inp1vec <- is.element(ADEL13_TFg3$player2, player1vector)
addPlayer1 <- ADEL13_TFg3[ which(ADEL13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_TFg3[ which(ADEL13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_TFg2 <- rbind(ADEL13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
ADEL13_TFft <- ftable(ADEL13_TFg2$player1, ADEL13_TFg2$player2)
ADEL13_TFft2 <- as.matrix(ADEL13_TFft)
numRows <- nrow(ADEL13_TFft2)
numCols <- ncol(ADEL13_TFft2)
ADEL13_TFft3 <- ADEL13_TFft2[c(2:numRows) , c(2:numCols)]
ADEL13_TFTable <- graph.adjacency(ADEL13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(ADEL13_TFTable, vertex.label = V(ADEL13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
ADEL13_TF.clusterCoef <- transitivity(ADEL13_TFTable, type="global") #cluster coefficient
ADEL13_TF.degreeCent <- centralization.degree(ADEL13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_TFftn <- as.network.matrix(ADEL13_TFft)
ADEL13_TF.netDensity <- network.density(ADEL13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_TF.entropy <- entropy(ADEL13_TFft) #entropy
ADEL13_TF.netMx <- cbind(ADEL13_TF.netMx, ADEL13_TF.clusterCoef, ADEL13_TF.degreeCent$centralization,
ADEL13_TF.netDensity, ADEL13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
round = 13
teamName = "ADEL"
KIoutcome = "Stoppage_AM"
ADEL13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
ADEL13_SAMg2 <- data.frame(ADEL13_SAM)
ADEL13_SAMg2 <- ADEL13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_SAMg2$player1
player2vector <- ADEL13_SAMg2$player2
ADEL13_SAMg3 <- ADEL13_SAMg2
ADEL13_SAMg3$p1inp2vec <- is.element(ADEL13_SAMg3$player1, player2vector)
ADEL13_SAMg3$p2inp1vec <- is.element(ADEL13_SAMg3$player2, player1vector)
addPlayer1 <- ADEL13_SAMg3[ which(ADEL13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_SAMg3[ which(ADEL13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_SAMg2 <- rbind(ADEL13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
ADEL13_SAMft <- ftable(ADEL13_SAMg2$player1, ADEL13_SAMg2$player2)
ADEL13_SAMft2 <- as.matrix(ADEL13_SAMft)
numRows <- nrow(ADEL13_SAMft2)
numCols <- ncol(ADEL13_SAMft2)
ADEL13_SAMft3 <- ADEL13_SAMft2[c(2:numRows) , c(2:numCols)]
ADEL13_SAMTable <- graph.adjacency(ADEL13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(ADEL13_SAMTable, vertex.label = V(ADEL13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
ADEL13_SAM.clusterCoef <- transitivity(ADEL13_SAMTable, type="global") #cluster coefficient
ADEL13_SAM.degreeCent <- centralization.degree(ADEL13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_SAMftn <- as.network.matrix(ADEL13_SAMft)
ADEL13_SAM.netDensity <- network.density(ADEL13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_SAM.entropy <- entropy(ADEL13_SAMft) #entropy
ADEL13_SAM.netMx <- cbind(ADEL13_SAM.netMx, ADEL13_SAM.clusterCoef, ADEL13_SAM.degreeCent$centralization,
ADEL13_SAM.netDensity, ADEL13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "ADEL"
KIoutcome = "Turnover_AM"
ADEL13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
ADEL13_TAMg2 <- data.frame(ADEL13_TAM)
ADEL13_TAMg2 <- ADEL13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_TAMg2$player1
player2vector <- ADEL13_TAMg2$player2
ADEL13_TAMg3 <- ADEL13_TAMg2
ADEL13_TAMg3$p1inp2vec <- is.element(ADEL13_TAMg3$player1, player2vector)
ADEL13_TAMg3$p2inp1vec <- is.element(ADEL13_TAMg3$player2, player1vector)
addPlayer1 <- ADEL13_TAMg3[ which(ADEL13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_TAMg3[ which(ADEL13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_TAMg2 <- rbind(ADEL13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
ADEL13_TAMft <- ftable(ADEL13_TAMg2$player1, ADEL13_TAMg2$player2)
ADEL13_TAMft2 <- as.matrix(ADEL13_TAMft)
numRows <- nrow(ADEL13_TAMft2)
numCols <- ncol(ADEL13_TAMft2)
ADEL13_TAMft3 <- ADEL13_TAMft2[c(2:numRows) , c(2:numCols)]
ADEL13_TAMTable <- graph.adjacency(ADEL13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(ADEL13_TAMTable, vertex.label = V(ADEL13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
ADEL13_TAM.clusterCoef <- transitivity(ADEL13_TAMTable, type="global") #cluster coefficient
ADEL13_TAM.degreeCent <- centralization.degree(ADEL13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_TAMftn <- as.network.matrix(ADEL13_TAMft)
ADEL13_TAM.netDensity <- network.density(ADEL13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_TAM.entropy <- entropy(ADEL13_TAMft) #entropy
ADEL13_TAM.netMx <- cbind(ADEL13_TAM.netMx, ADEL13_TAM.clusterCoef, ADEL13_TAM.degreeCent$centralization,
ADEL13_TAM.netDensity, ADEL13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
#NA
round = 13
teamName = "ADEL"
KIoutcome = "Stoppage_DM"
ADEL13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
ADEL13_SDMg2 <- data.frame(ADEL13_SDM)
ADEL13_SDMg2 <- ADEL13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_SDMg2$player1
player2vector <- ADEL13_SDMg2$player2
ADEL13_SDMg3 <- ADEL13_SDMg2
ADEL13_SDMg3$p1inp2vec <- is.element(ADEL13_SDMg3$player1, player2vector)
ADEL13_SDMg3$p2inp1vec <- is.element(ADEL13_SDMg3$player2, player1vector)
addPlayer1 <- ADEL13_SDMg3[ which(ADEL13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_SDMg3[ which(ADEL13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_SDMg2 <- rbind(ADEL13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
ADEL13_SDMft <- ftable(ADEL13_SDMg2$player1, ADEL13_SDMg2$player2)
ADEL13_SDMft2 <- as.matrix(ADEL13_SDMft)
numRows <- nrow(ADEL13_SDMft2)
numCols <- ncol(ADEL13_SDMft2)
ADEL13_SDMft3 <- ADEL13_SDMft2[c(2:numRows) , c(2:numCols)]
ADEL13_SDMTable <- graph.adjacency(ADEL13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(ADEL13_SDMTable, vertex.label = V(ADEL13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
ADEL13_SDM.clusterCoef <- transitivity(ADEL13_SDMTable, type="global") #cluster coefficient
ADEL13_SDM.degreeCent <- centralization.degree(ADEL13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_SDMftn <- as.network.matrix(ADEL13_SDMft)
ADEL13_SDM.netDensity <- network.density(ADEL13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_SDM.entropy <- entropy(ADEL13_SDMft) #entropy
ADEL13_SDM.netMx <- cbind(ADEL13_SDM.netMx, ADEL13_SDM.clusterCoef, ADEL13_SDM.degreeCent$centralization,
ADEL13_SDM.netDensity, ADEL13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "ADEL"
KIoutcome = "Turnover_DM"
ADEL13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
ADEL13_TDMg2 <- data.frame(ADEL13_TDM)
ADEL13_TDMg2 <- ADEL13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_TDMg2$player1
player2vector <- ADEL13_TDMg2$player2
ADEL13_TDMg3 <- ADEL13_TDMg2
ADEL13_TDMg3$p1inp2vec <- is.element(ADEL13_TDMg3$player1, player2vector)
ADEL13_TDMg3$p2inp1vec <- is.element(ADEL13_TDMg3$player2, player1vector)
addPlayer1 <- ADEL13_TDMg3[ which(ADEL13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, empty, zero)
addPlayer2 <- ADEL13_TDMg3[ which(ADEL13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_TDMg2 <- rbind(ADEL13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
ADEL13_TDMft <- ftable(ADEL13_TDMg2$player1, ADEL13_TDMg2$player2)
ADEL13_TDMft2 <- as.matrix(ADEL13_TDMft)
numRows <- nrow(ADEL13_TDMft2)
numCols <- ncol(ADEL13_TDMft2)
ADEL13_TDMft3 <- ADEL13_TDMft2[c(2:numRows) , c(2:numCols)]
ADEL13_TDMTable <- graph.adjacency(ADEL13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(ADEL13_TDMTable, vertex.label = V(ADEL13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
ADEL13_TDM.clusterCoef <- transitivity(ADEL13_TDMTable, type="global") #cluster coefficient
ADEL13_TDM.degreeCent <- centralization.degree(ADEL13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_TDMftn <- as.network.matrix(ADEL13_TDMft)
ADEL13_TDM.netDensity <- network.density(ADEL13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_TDM.entropy <- entropy(ADEL13_TDMft) #entropy
ADEL13_TDM.netMx <- cbind(ADEL13_TDM.netMx, ADEL13_TDM.clusterCoef, ADEL13_TDM.degreeCent$centralization,
ADEL13_TDM.netDensity, ADEL13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "ADEL"
KIoutcome = "Stoppage_D"
ADEL13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
ADEL13_SDg2 <- data.frame(ADEL13_SD)
ADEL13_SDg2 <- ADEL13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_SDg2$player1
player2vector <- ADEL13_SDg2$player2
ADEL13_SDg3 <- ADEL13_SDg2
ADEL13_SDg3$p1inp2vec <- is.element(ADEL13_SDg3$player1, player2vector)
ADEL13_SDg3$p2inp1vec <- is.element(ADEL13_SDg3$player2, player1vector)
addPlayer1 <- ADEL13_SDg3[ which(ADEL13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_SDg3[ which(ADEL13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_SDg2 <- rbind(ADEL13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
ADEL13_SDft <- ftable(ADEL13_SDg2$player1, ADEL13_SDg2$player2)
ADEL13_SDft2 <- as.matrix(ADEL13_SDft)
numRows <- nrow(ADEL13_SDft2)
numCols <- ncol(ADEL13_SDft2)
ADEL13_SDft3 <- ADEL13_SDft2[c(2:numRows) , c(2:numCols)]
ADEL13_SDTable <- graph.adjacency(ADEL13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(ADEL13_SDTable, vertex.label = V(ADEL13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
ADEL13_SD.clusterCoef <- transitivity(ADEL13_SDTable, type="global") #cluster coefficient
ADEL13_SD.degreeCent <- centralization.degree(ADEL13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_SDftn <- as.network.matrix(ADEL13_SDft)
ADEL13_SD.netDensity <- network.density(ADEL13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_SD.entropy <- entropy(ADEL13_SDft) #entropy
ADEL13_SD.netMx <- cbind(ADEL13_SD.netMx, ADEL13_SD.clusterCoef, ADEL13_SD.degreeCent$centralization,
ADEL13_SD.netDensity, ADEL13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "ADEL"
KIoutcome = "Turnover_D"
ADEL13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
ADEL13_TDg2 <- data.frame(ADEL13_TD)
ADEL13_TDg2 <- ADEL13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_TDg2$player1
player2vector <- ADEL13_TDg2$player2
ADEL13_TDg3 <- ADEL13_TDg2
ADEL13_TDg3$p1inp2vec <- is.element(ADEL13_TDg3$player1, player2vector)
ADEL13_TDg3$p2inp1vec <- is.element(ADEL13_TDg3$player2, player1vector)
addPlayer1 <- ADEL13_TDg3[ which(ADEL13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_TDg3[ which(ADEL13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_TDg2 <- rbind(ADEL13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
ADEL13_TDft <- ftable(ADEL13_TDg2$player1, ADEL13_TDg2$player2)
ADEL13_TDft2 <- as.matrix(ADEL13_TDft)
numRows <- nrow(ADEL13_TDft2)
numCols <- ncol(ADEL13_TDft2)
ADEL13_TDft3 <- ADEL13_TDft2[c(2:numRows) , c(2:numCols)]
ADEL13_TDTable <- graph.adjacency(ADEL13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(ADEL13_TDTable, vertex.label = V(ADEL13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
ADEL13_TD.clusterCoef <- transitivity(ADEL13_TDTable, type="global") #cluster coefficient
ADEL13_TD.degreeCent <- centralization.degree(ADEL13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_TDftn <- as.network.matrix(ADEL13_TDft)
ADEL13_TD.netDensity <- network.density(ADEL13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_TD.entropy <- entropy(ADEL13_TDft) #entropy
ADEL13_TD.netMx <- cbind(ADEL13_TD.netMx, ADEL13_TD.clusterCoef, ADEL13_TD.degreeCent$centralization,
ADEL13_TD.netDensity, ADEL13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "ADEL"
KIoutcome = "End of Qtr_DM"
ADEL13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
ADEL13_QTg2 <- data.frame(ADEL13_QT)
ADEL13_QTg2 <- ADEL13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_QTg2$player1
player2vector <- ADEL13_QTg2$player2
ADEL13_QTg3 <- ADEL13_QTg2
ADEL13_QTg3$p1inp2vec <- is.element(ADEL13_QTg3$player1, player2vector)
ADEL13_QTg3$p2inp1vec <- is.element(ADEL13_QTg3$player2, player1vector)
addPlayer1 <- ADEL13_QTg3[ which(ADEL13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_QTg3[ which(ADEL13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_QTg2 <- rbind(ADEL13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
ADEL13_QTft <- ftable(ADEL13_QTg2$player1, ADEL13_QTg2$player2)
ADEL13_QTft2 <- as.matrix(ADEL13_QTft)
numRows <- nrow(ADEL13_QTft2)
numCols <- ncol(ADEL13_QTft2)
ADEL13_QTft3 <- ADEL13_QTft2[c(2:numRows) , c(2:numCols)]
ADEL13_QTTable <- graph.adjacency(ADEL13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(ADEL13_QTTable, vertex.label = V(ADEL13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
ADEL13_QT.clusterCoef <- transitivity(ADEL13_QTTable, type="global") #cluster coefficient
ADEL13_QT.degreeCent <- centralization.degree(ADEL13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_QTftn <- as.network.matrix(ADEL13_QTft)
ADEL13_QT.netDensity <- network.density(ADEL13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_QT.entropy <- entropy(ADEL13_QTft) #entropy
ADEL13_QT.netMx <- cbind(ADEL13_QT.netMx, ADEL13_QT.clusterCoef, ADEL13_QT.degreeCent$centralization,
ADEL13_QT.netDensity, ADEL13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_QT.netMx) <- varnames
#############################################################################
#BRISBANE
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "BL"
KIoutcome = "Goal_F"
BL13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
BL13_Gg2 <- data.frame(BL13_G)
BL13_Gg2 <- BL13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_Gg2$player1
player2vector <- BL13_Gg2$player2
BL13_Gg3 <- BL13_Gg2
BL13_Gg3$p1inp2vec <- is.element(BL13_Gg3$player1, player2vector)
BL13_Gg3$p2inp1vec <- is.element(BL13_Gg3$player2, player1vector)
addPlayer1 <- BL13_Gg3[ which(BL13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_Gg3[ which(BL13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_Gg2 <- rbind(BL13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
BL13_Gft <- ftable(BL13_Gg2$player1, BL13_Gg2$player2)
BL13_Gft2 <- as.matrix(BL13_Gft)
numRows <- nrow(BL13_Gft2)
numCols <- ncol(BL13_Gft2)
BL13_Gft3 <- BL13_Gft2[c(2:numRows) , c(2:numCols)]
BL13_GTable <- graph.adjacency(BL13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(BL13_GTable, vertex.label = V(BL13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
BL13_G.clusterCoef <- transitivity(BL13_GTable, type="global") #cluster coefficient
BL13_G.degreeCent <- centralization.degree(BL13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_Gftn <- as.network.matrix(BL13_Gft)
BL13_G.netDensity <- network.density(BL13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_G.entropy <- entropy(BL13_Gft) #entropy
BL13_G.netMx <- cbind(BL13_G.netMx, BL13_G.clusterCoef, BL13_G.degreeCent$centralization,
BL13_G.netDensity, BL13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
#NA
round = 13
teamName = "BL"
KIoutcome = "Behind_F"
BL13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
BL13_Bg2 <- data.frame(BL13_B)
BL13_Bg2 <- BL13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_Bg2$player1
player2vector <- BL13_Bg2$player2
BL13_Bg3 <- BL13_Bg2
BL13_Bg3$p1inp2vec <- is.element(BL13_Bg3$player1, player2vector)
BL13_Bg3$p2inp1vec <- is.element(BL13_Bg3$player2, player1vector)
addPlayer1 <- BL13_Bg3[ which(BL13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_Bg3[ which(BL13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_Bg2 <- rbind(BL13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
BL13_Bft <- ftable(BL13_Bg2$player1, BL13_Bg2$player2)
BL13_Bft2 <- as.matrix(BL13_Bft)
numRows <- nrow(BL13_Bft2)
numCols <- ncol(BL13_Bft2)
BL13_Bft3 <- BL13_Bft2[c(2:numRows) , c(2:numCols)]
BL13_BTable <- graph.adjacency(BL13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(BL13_BTable, vertex.label = V(BL13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
BL13_B.clusterCoef <- transitivity(BL13_BTable, type="global") #cluster coefficient
BL13_B.degreeCent <- centralization.degree(BL13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_Bftn <- as.network.matrix(BL13_Bft)
BL13_B.netDensity <- network.density(BL13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_B.entropy <- entropy(BL13_Bft) #entropy
BL13_B.netMx <- cbind(BL13_B.netMx, BL13_B.clusterCoef, BL13_B.degreeCent$centralization,
BL13_B.netDensity, BL13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "BL"
KIoutcome = "Stoppage_F"
BL13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
BL13_SFg2 <- data.frame(BL13_SF)
BL13_SFg2 <- BL13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_SFg2$player1
player2vector <- BL13_SFg2$player2
BL13_SFg3 <- BL13_SFg2
BL13_SFg3$p1inp2vec <- is.element(BL13_SFg3$player1, player2vector)
BL13_SFg3$p2inp1vec <- is.element(BL13_SFg3$player2, player1vector)
addPlayer1 <- BL13_SFg3[ which(BL13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_SFg3[ which(BL13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_SFg2 <- rbind(BL13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
BL13_SFft <- ftable(BL13_SFg2$player1, BL13_SFg2$player2)
BL13_SFft2 <- as.matrix(BL13_SFft)
numRows <- nrow(BL13_SFft2)
numCols <- ncol(BL13_SFft2)
BL13_SFft3 <- BL13_SFft2[c(2:numRows) , c(2:numCols)]
BL13_SFTable <- graph.adjacency(BL13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(BL13_SFTable, vertex.label = V(BL13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
BL13_SF.clusterCoef <- transitivity(BL13_SFTable, type="global") #cluster coefficient
BL13_SF.degreeCent <- centralization.degree(BL13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_SFftn <- as.network.matrix(BL13_SFft)
BL13_SF.netDensity <- network.density(BL13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_SF.entropy <- entropy(BL13_SFft) #entropy
BL13_SF.netMx <- cbind(BL13_SF.netMx, BL13_SF.clusterCoef, BL13_SF.degreeCent$centralization,
BL13_SF.netDensity, BL13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "BL"
KIoutcome = "Turnover_F"
BL13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
BL13_TFg2 <- data.frame(BL13_TF)
BL13_TFg2 <- BL13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_TFg2$player1
player2vector <- BL13_TFg2$player2
BL13_TFg3 <- BL13_TFg2
BL13_TFg3$p1inp2vec <- is.element(BL13_TFg3$player1, player2vector)
BL13_TFg3$p2inp1vec <- is.element(BL13_TFg3$player2, player1vector)
addPlayer1 <- BL13_TFg3[ which(BL13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_TFg3[ which(BL13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_TFg2 <- rbind(BL13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
BL13_TFft <- ftable(BL13_TFg2$player1, BL13_TFg2$player2)
BL13_TFft2 <- as.matrix(BL13_TFft)
numRows <- nrow(BL13_TFft2)
numCols <- ncol(BL13_TFft2)
BL13_TFft3 <- BL13_TFft2[c(2:numRows) , c(2:numCols)]
BL13_TFTable <- graph.adjacency(BL13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(BL13_TFTable, vertex.label = V(BL13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
BL13_TF.clusterCoef <- transitivity(BL13_TFTable, type="global") #cluster coefficient
BL13_TF.degreeCent <- centralization.degree(BL13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_TFftn <- as.network.matrix(BL13_TFft)
BL13_TF.netDensity <- network.density(BL13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_TF.entropy <- entropy(BL13_TFft) #entropy
BL13_TF.netMx <- cbind(BL13_TF.netMx, BL13_TF.clusterCoef, BL13_TF.degreeCent$centralization,
BL13_TF.netDensity, BL13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
round = 13
teamName = "BL"
KIoutcome = "Stoppage_AM"
BL13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
BL13_SAMg2 <- data.frame(BL13_SAM)
BL13_SAMg2 <- BL13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_SAMg2$player1
player2vector <- BL13_SAMg2$player2
BL13_SAMg3 <- BL13_SAMg2
BL13_SAMg3$p1inp2vec <- is.element(BL13_SAMg3$player1, player2vector)
BL13_SAMg3$p2inp1vec <- is.element(BL13_SAMg3$player2, player1vector)
addPlayer1 <- BL13_SAMg3[ which(BL13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_SAMg3[ which(BL13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_SAMg2 <- rbind(BL13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
BL13_SAMft <- ftable(BL13_SAMg2$player1, BL13_SAMg2$player2)
BL13_SAMft2 <- as.matrix(BL13_SAMft)
numRows <- nrow(BL13_SAMft2)
numCols <- ncol(BL13_SAMft2)
BL13_SAMft3 <- BL13_SAMft2[c(2:numRows) , c(2:numCols)]
BL13_SAMTable <- graph.adjacency(BL13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(BL13_SAMTable, vertex.label = V(BL13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
BL13_SAM.clusterCoef <- transitivity(BL13_SAMTable, type="global") #cluster coefficient
BL13_SAM.degreeCent <- centralization.degree(BL13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_SAMftn <- as.network.matrix(BL13_SAMft)
BL13_SAM.netDensity <- network.density(BL13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_SAM.entropy <- entropy(BL13_SAMft) #entropy
BL13_SAM.netMx <- cbind(BL13_SAM.netMx, BL13_SAM.clusterCoef, BL13_SAM.degreeCent$centralization,
BL13_SAM.netDensity, BL13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "BL"
KIoutcome = "Turnover_AM"
BL13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
BL13_TAMg2 <- data.frame(BL13_TAM)
BL13_TAMg2 <- BL13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_TAMg2$player1
player2vector <- BL13_TAMg2$player2
BL13_TAMg3 <- BL13_TAMg2
BL13_TAMg3$p1inp2vec <- is.element(BL13_TAMg3$player1, player2vector)
BL13_TAMg3$p2inp1vec <- is.element(BL13_TAMg3$player2, player1vector)
addPlayer1 <- BL13_TAMg3[ which(BL13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_TAMg3[ which(BL13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_TAMg2 <- rbind(BL13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
BL13_TAMft <- ftable(BL13_TAMg2$player1, BL13_TAMg2$player2)
BL13_TAMft2 <- as.matrix(BL13_TAMft)
numRows <- nrow(BL13_TAMft2)
numCols <- ncol(BL13_TAMft2)
BL13_TAMft3 <- BL13_TAMft2[c(2:numRows) , c(2:numCols)]
BL13_TAMTable <- graph.adjacency(BL13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(BL13_TAMTable, vertex.label = V(BL13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
BL13_TAM.clusterCoef <- transitivity(BL13_TAMTable, type="global") #cluster coefficient
BL13_TAM.degreeCent <- centralization.degree(BL13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_TAMftn <- as.network.matrix(BL13_TAMft)
BL13_TAM.netDensity <- network.density(BL13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_TAM.entropy <- entropy(BL13_TAMft) #entropy
BL13_TAM.netMx <- cbind(BL13_TAM.netMx, BL13_TAM.clusterCoef, BL13_TAM.degreeCent$centralization,
BL13_TAM.netDensity, BL13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "BL"
KIoutcome = "Stoppage_DM"
BL13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
BL13_SDMg2 <- data.frame(BL13_SDM)
BL13_SDMg2 <- BL13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_SDMg2$player1
player2vector <- BL13_SDMg2$player2
BL13_SDMg3 <- BL13_SDMg2
BL13_SDMg3$p1inp2vec <- is.element(BL13_SDMg3$player1, player2vector)
BL13_SDMg3$p2inp1vec <- is.element(BL13_SDMg3$player2, player1vector)
addPlayer1 <- BL13_SDMg3[ which(BL13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_SDMg3[ which(BL13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_SDMg2 <- rbind(BL13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
BL13_SDMft <- ftable(BL13_SDMg2$player1, BL13_SDMg2$player2)
BL13_SDMft2 <- as.matrix(BL13_SDMft)
numRows <- nrow(BL13_SDMft2)
numCols <- ncol(BL13_SDMft2)
BL13_SDMft3 <- BL13_SDMft2[c(2:numRows) , c(2:numCols)]
BL13_SDMTable <- graph.adjacency(BL13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(BL13_SDMTable, vertex.label = V(BL13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
BL13_SDM.clusterCoef <- transitivity(BL13_SDMTable, type="global") #cluster coefficient
BL13_SDM.degreeCent <- centralization.degree(BL13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_SDMftn <- as.network.matrix(BL13_SDMft)
BL13_SDM.netDensity <- network.density(BL13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_SDM.entropy <- entropy(BL13_SDMft) #entropy
BL13_SDM.netMx <- cbind(BL13_SDM.netMx, BL13_SDM.clusterCoef, BL13_SDM.degreeCent$centralization,
BL13_SDM.netDensity, BL13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "BL"
KIoutcome = "Turnover_DM"
BL13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
BL13_TDMg2 <- data.frame(BL13_TDM)
BL13_TDMg2 <- BL13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_TDMg2$player1
player2vector <- BL13_TDMg2$player2
BL13_TDMg3 <- BL13_TDMg2
BL13_TDMg3$p1inp2vec <- is.element(BL13_TDMg3$player1, player2vector)
BL13_TDMg3$p2inp1vec <- is.element(BL13_TDMg3$player2, player1vector)
addPlayer1 <- BL13_TDMg3[ which(BL13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_TDMg3[ which(BL13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_TDMg2 <- rbind(BL13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
BL13_TDMft <- ftable(BL13_TDMg2$player1, BL13_TDMg2$player2)
BL13_TDMft2 <- as.matrix(BL13_TDMft)
numRows <- nrow(BL13_TDMft2)
numCols <- ncol(BL13_TDMft2)
BL13_TDMft3 <- BL13_TDMft2[c(2:numRows) , c(2:numCols)]
BL13_TDMTable <- graph.adjacency(BL13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(BL13_TDMTable, vertex.label = V(BL13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
BL13_TDM.clusterCoef <- transitivity(BL13_TDMTable, type="global") #cluster coefficient
BL13_TDM.degreeCent <- centralization.degree(BL13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_TDMftn <- as.network.matrix(BL13_TDMft)
BL13_TDM.netDensity <- network.density(BL13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_TDM.entropy <- entropy(BL13_TDMft) #entropy
BL13_TDM.netMx <- cbind(BL13_TDM.netMx, BL13_TDM.clusterCoef, BL13_TDM.degreeCent$centralization,
BL13_TDM.netDensity, BL13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "BL"
KIoutcome = "Stoppage_D"
BL13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
BL13_SDg2 <- data.frame(BL13_SD)
BL13_SDg2 <- BL13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_SDg2$player1
player2vector <- BL13_SDg2$player2
BL13_SDg3 <- BL13_SDg2
BL13_SDg3$p1inp2vec <- is.element(BL13_SDg3$player1, player2vector)
BL13_SDg3$p2inp1vec <- is.element(BL13_SDg3$player2, player1vector)
addPlayer1 <- BL13_SDg3[ which(BL13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_SDg3[ which(BL13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_SDg2 <- rbind(BL13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
BL13_SDft <- ftable(BL13_SDg2$player1, BL13_SDg2$player2)
BL13_SDft2 <- as.matrix(BL13_SDft)
numRows <- nrow(BL13_SDft2)
numCols <- ncol(BL13_SDft2)
BL13_SDft3 <- BL13_SDft2[c(2:numRows) , c(2:numCols)]
BL13_SDTable <- graph.adjacency(BL13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(BL13_SDTable, vertex.label = V(BL13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
BL13_SD.clusterCoef <- transitivity(BL13_SDTable, type="global") #cluster coefficient
BL13_SD.degreeCent <- centralization.degree(BL13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_SDftn <- as.network.matrix(BL13_SDft)
BL13_SD.netDensity <- network.density(BL13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_SD.entropy <- entropy(BL13_SDft) #entropy
BL13_SD.netMx <- cbind(BL13_SD.netMx, BL13_SD.clusterCoef, BL13_SD.degreeCent$centralization,
BL13_SD.netDensity, BL13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "BL"
KIoutcome = "Turnover_D"
BL13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
BL13_TDg2 <- data.frame(BL13_TD)
BL13_TDg2 <- BL13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_TDg2$player1
player2vector <- BL13_TDg2$player2
BL13_TDg3 <- BL13_TDg2
BL13_TDg3$p1inp2vec <- is.element(BL13_TDg3$player1, player2vector)
BL13_TDg3$p2inp1vec <- is.element(BL13_TDg3$player2, player1vector)
addPlayer1 <- BL13_TDg3[ which(BL13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_TDg3[ which(BL13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_TDg2 <- rbind(BL13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
BL13_TDft <- ftable(BL13_TDg2$player1, BL13_TDg2$player2)
BL13_TDft2 <- as.matrix(BL13_TDft)
numRows <- nrow(BL13_TDft2)
numCols <- ncol(BL13_TDft2)
BL13_TDft3 <- BL13_TDft2[c(2:numRows) , c(2:numCols)]
BL13_TDTable <- graph.adjacency(BL13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(BL13_TDTable, vertex.label = V(BL13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
BL13_TD.clusterCoef <- transitivity(BL13_TDTable, type="global") #cluster coefficient
BL13_TD.degreeCent <- centralization.degree(BL13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_TDftn <- as.network.matrix(BL13_TDft)
BL13_TD.netDensity <- network.density(BL13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_TD.entropy <- entropy(BL13_TDft) #entropy
BL13_TD.netMx <- cbind(BL13_TD.netMx, BL13_TD.clusterCoef, BL13_TD.degreeCent$centralization,
BL13_TD.netDensity, BL13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "BL"
KIoutcome = "End of Qtr_DM"
BL13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
BL13_QTg2 <- data.frame(BL13_QT)
BL13_QTg2 <- BL13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_QTg2$player1
player2vector <- BL13_QTg2$player2
BL13_QTg3 <- BL13_QTg2
BL13_QTg3$p1inp2vec <- is.element(BL13_QTg3$player1, player2vector)
BL13_QTg3$p2inp1vec <- is.element(BL13_QTg3$player2, player1vector)
addPlayer1 <- BL13_QTg3[ which(BL13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_QTg3[ which(BL13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_QTg2 <- rbind(BL13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
BL13_QTft <- ftable(BL13_QTg2$player1, BL13_QTg2$player2)
BL13_QTft2 <- as.matrix(BL13_QTft)
numRows <- nrow(BL13_QTft2)
numCols <- ncol(BL13_QTft2)
BL13_QTft3 <- BL13_QTft2[c(2:numRows) , c(2:numCols)]
BL13_QTTable <- graph.adjacency(BL13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(BL13_QTTable, vertex.label = V(BL13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
BL13_QT.clusterCoef <- transitivity(BL13_QTTable, type="global") #cluster coefficient
BL13_QT.degreeCent <- centralization.degree(BL13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_QTftn <- as.network.matrix(BL13_QTft)
BL13_QT.netDensity <- network.density(BL13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_QT.entropy <- entropy(BL13_QTft) #entropy
BL13_QT.netMx <- cbind(BL13_QT.netMx, BL13_QT.clusterCoef, BL13_QT.degreeCent$centralization,
BL13_QT.netDensity, BL13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_QT.netMx) <- varnames
#############################################################################
#CARLTON
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
round = 13
teamName = "CARL"
KIoutcome = "Goal_F"
CARL13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
CARL13_Gg2 <- data.frame(CARL13_G)
CARL13_Gg2 <- CARL13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_Gg2$player1
player2vector <- CARL13_Gg2$player2
CARL13_Gg3 <- CARL13_Gg2
CARL13_Gg3$p1inp2vec <- is.element(CARL13_Gg3$player1, player2vector)
CARL13_Gg3$p2inp1vec <- is.element(CARL13_Gg3$player2, player1vector)
addPlayer1 <- CARL13_Gg3[ which(CARL13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_Gg3[ which(CARL13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_Gg2 <- rbind(CARL13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
CARL13_Gft <- ftable(CARL13_Gg2$player1, CARL13_Gg2$player2)
CARL13_Gft2 <- as.matrix(CARL13_Gft)
numRows <- nrow(CARL13_Gft2)
numCols <- ncol(CARL13_Gft2)
CARL13_Gft3 <- CARL13_Gft2[c(2:numRows) , c(2:numCols)]
CARL13_GTable <- graph.adjacency(CARL13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(CARL13_GTable, vertex.label = V(CARL13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
CARL13_G.clusterCoef <- transitivity(CARL13_GTable, type="global") #cluster coefficient
CARL13_G.degreeCent <- centralization.degree(CARL13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_Gftn <- as.network.matrix(CARL13_Gft)
CARL13_G.netDensity <- network.density(CARL13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_G.entropy <- entropy(CARL13_Gft) #entropy
CARL13_G.netMx <- cbind(CARL13_G.netMx, CARL13_G.clusterCoef, CARL13_G.degreeCent$centralization,
CARL13_G.netDensity, CARL13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
round = 13
teamName = "CARL"
KIoutcome = "Behind_F"
CARL13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
CARL13_Bg2 <- data.frame(CARL13_B)
CARL13_Bg2 <- CARL13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_Bg2$player1
player2vector <- CARL13_Bg2$player2
CARL13_Bg3 <- CARL13_Bg2
CARL13_Bg3$p1inp2vec <- is.element(CARL13_Bg3$player1, player2vector)
CARL13_Bg3$p2inp1vec <- is.element(CARL13_Bg3$player2, player1vector)
addPlayer1 <- CARL13_Bg3[ which(CARL13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, empty, zero)
addPlayer2 <- CARL13_Bg3[ which(CARL13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_Bg2 <- rbind(CARL13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
CARL13_Bft <- ftable(CARL13_Bg2$player1, CARL13_Bg2$player2)
CARL13_Bft2 <- as.matrix(CARL13_Bft)
numRows <- nrow(CARL13_Bft2)
numCols <- ncol(CARL13_Bft2)
CARL13_Bft3 <- CARL13_Bft2[c(2:numRows) , c(2:numCols)]
CARL13_BTable <- graph.adjacency(CARL13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(CARL13_BTable, vertex.label = V(CARL13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
CARL13_B.clusterCoef <- transitivity(CARL13_BTable, type="global") #cluster coefficient
CARL13_B.degreeCent <- centralization.degree(CARL13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_Bftn <- as.network.matrix(CARL13_Bft)
CARL13_B.netDensity <- network.density(CARL13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_B.entropy <- entropy(CARL13_Bft) #entropy
CARL13_B.netMx <- cbind(CARL13_B.netMx, CARL13_B.clusterCoef, CARL13_B.degreeCent$centralization,
CARL13_B.netDensity, CARL13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
round = 13
teamName = "CARL"
KIoutcome = "Stoppage_F"
CARL13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
CARL13_SFg2 <- data.frame(CARL13_SF)
CARL13_SFg2 <- CARL13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_SFg2$player1
player2vector <- CARL13_SFg2$player2
CARL13_SFg3 <- CARL13_SFg2
CARL13_SFg3$p1inp2vec <- is.element(CARL13_SFg3$player1, player2vector)
CARL13_SFg3$p2inp1vec <- is.element(CARL13_SFg3$player2, player1vector)
addPlayer1 <- CARL13_SFg3[ which(CARL13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_SFg3[ which(CARL13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_SFg2 <- rbind(CARL13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
CARL13_SFft <- ftable(CARL13_SFg2$player1, CARL13_SFg2$player2)
CARL13_SFft2 <- as.matrix(CARL13_SFft)
numRows <- nrow(CARL13_SFft2)
numCols <- ncol(CARL13_SFft2)
CARL13_SFft3 <- CARL13_SFft2[c(2:numRows) , c(2:numCols)]
CARL13_SFTable <- graph.adjacency(CARL13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(CARL13_SFTable, vertex.label = V(CARL13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
CARL13_SF.clusterCoef <- transitivity(CARL13_SFTable, type="global") #cluster coefficient
CARL13_SF.degreeCent <- centralization.degree(CARL13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_SFftn <- as.network.matrix(CARL13_SFft)
CARL13_SF.netDensity <- network.density(CARL13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_SF.entropy <- entropy(CARL13_SFft) #entropy
CARL13_SF.netMx <- cbind(CARL13_SF.netMx, CARL13_SF.clusterCoef, CARL13_SF.degreeCent$centralization,
CARL13_SF.netDensity, CARL13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
#NA
round = 13
teamName = "CARL"
KIoutcome = "Turnover_F"
CARL13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
CARL13_TFg2 <- data.frame(CARL13_TF)
CARL13_TFg2 <- CARL13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_TFg2$player1
player2vector <- CARL13_TFg2$player2
CARL13_TFg3 <- CARL13_TFg2
CARL13_TFg3$p1inp2vec <- is.element(CARL13_TFg3$player1, player2vector)
CARL13_TFg3$p2inp1vec <- is.element(CARL13_TFg3$player2, player1vector)
addPlayer1 <- CARL13_TFg3[ which(CARL13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_TFg3[ which(CARL13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_TFg2 <- rbind(CARL13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
CARL13_TFft <- ftable(CARL13_TFg2$player1, CARL13_TFg2$player2)
CARL13_TFft2 <- as.matrix(CARL13_TFft)
numRows <- nrow(CARL13_TFft2)
numCols <- ncol(CARL13_TFft2)
CARL13_TFft3 <- CARL13_TFft2[c(2:numRows) , c(2:numCols)]
CARL13_TFTable <- graph.adjacency(CARL13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(CARL13_TFTable, vertex.label = V(CARL13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
CARL13_TF.clusterCoef <- transitivity(CARL13_TFTable, type="global") #cluster coefficient
CARL13_TF.degreeCent <- centralization.degree(CARL13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_TFftn <- as.network.matrix(CARL13_TFft)
CARL13_TF.netDensity <- network.density(CARL13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_TF.entropy <- entropy(CARL13_TFft) #entropy
CARL13_TF.netMx <- cbind(CARL13_TF.netMx, CARL13_TF.clusterCoef, CARL13_TF.degreeCent$centralization,
CARL13_TF.netDensity, CARL13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
round = 13
teamName = "CARL"
KIoutcome = "Stoppage_AM"
CARL13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
CARL13_SAMg2 <- data.frame(CARL13_SAM)
CARL13_SAMg2 <- CARL13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_SAMg2$player1
player2vector <- CARL13_SAMg2$player2
CARL13_SAMg3 <- CARL13_SAMg2
CARL13_SAMg3$p1inp2vec <- is.element(CARL13_SAMg3$player1, player2vector)
CARL13_SAMg3$p2inp1vec <- is.element(CARL13_SAMg3$player2, player1vector)
addPlayer1 <- CARL13_SAMg3[ which(CARL13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_SAMg3[ which(CARL13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_SAMg2 <- rbind(CARL13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
CARL13_SAMft <- ftable(CARL13_SAMg2$player1, CARL13_SAMg2$player2)
CARL13_SAMft2 <- as.matrix(CARL13_SAMft)
numRows <- nrow(CARL13_SAMft2)
numCols <- ncol(CARL13_SAMft2)
CARL13_SAMft3 <- CARL13_SAMft2[c(2:numRows) , c(2:numCols)]
CARL13_SAMTable <- graph.adjacency(CARL13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(CARL13_SAMTable, vertex.label = V(CARL13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
CARL13_SAM.clusterCoef <- transitivity(CARL13_SAMTable, type="global") #cluster coefficient
CARL13_SAM.degreeCent <- centralization.degree(CARL13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_SAMftn <- as.network.matrix(CARL13_SAMft)
CARL13_SAM.netDensity <- network.density(CARL13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_SAM.entropy <- entropy(CARL13_SAMft) #entropy
CARL13_SAM.netMx <- cbind(CARL13_SAM.netMx, CARL13_SAM.clusterCoef, CARL13_SAM.degreeCent$centralization,
CARL13_SAM.netDensity, CARL13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "CARL"
KIoutcome = "Turnover_AM"
CARL13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
CARL13_TAMg2 <- data.frame(CARL13_TAM)
CARL13_TAMg2 <- CARL13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_TAMg2$player1
player2vector <- CARL13_TAMg2$player2
CARL13_TAMg3 <- CARL13_TAMg2
CARL13_TAMg3$p1inp2vec <- is.element(CARL13_TAMg3$player1, player2vector)
CARL13_TAMg3$p2inp1vec <- is.element(CARL13_TAMg3$player2, player1vector)
addPlayer1 <- CARL13_TAMg3[ which(CARL13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_TAMg3[ which(CARL13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(empty, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_TAMg2 <- rbind(CARL13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
CARL13_TAMft <- ftable(CARL13_TAMg2$player1, CARL13_TAMg2$player2)
CARL13_TAMft2 <- as.matrix(CARL13_TAMft)
numRows <- nrow(CARL13_TAMft2)
numCols <- ncol(CARL13_TAMft2)
CARL13_TAMft3 <- CARL13_TAMft2[c(2:numRows) , c(2:numCols)]
CARL13_TAMTable <- graph.adjacency(CARL13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(CARL13_TAMTable, vertex.label = V(CARL13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
CARL13_TAM.clusterCoef <- transitivity(CARL13_TAMTable, type="global") #cluster coefficient
CARL13_TAM.degreeCent <- centralization.degree(CARL13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_TAMftn <- as.network.matrix(CARL13_TAMft)
CARL13_TAM.netDensity <- network.density(CARL13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_TAM.entropy <- entropy(CARL13_TAMft) #entropy
CARL13_TAM.netMx <- cbind(CARL13_TAM.netMx, CARL13_TAM.clusterCoef, CARL13_TAM.degreeCent$centralization,
CARL13_TAM.netDensity, CARL13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "CARL"
KIoutcome = "Stoppage_DM"
CARL13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
CARL13_SDMg2 <- data.frame(CARL13_SDM)
CARL13_SDMg2 <- CARL13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_SDMg2$player1
player2vector <- CARL13_SDMg2$player2
CARL13_SDMg3 <- CARL13_SDMg2
CARL13_SDMg3$p1inp2vec <- is.element(CARL13_SDMg3$player1, player2vector)
CARL13_SDMg3$p2inp1vec <- is.element(CARL13_SDMg3$player2, player1vector)
addPlayer1 <- CARL13_SDMg3[ which(CARL13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_SDMg3[ which(CARL13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_SDMg2 <- rbind(CARL13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
CARL13_SDMft <- ftable(CARL13_SDMg2$player1, CARL13_SDMg2$player2)
CARL13_SDMft2 <- as.matrix(CARL13_SDMft)
numRows <- nrow(CARL13_SDMft2)
numCols <- ncol(CARL13_SDMft2)
CARL13_SDMft3 <- CARL13_SDMft2[c(2:numRows) , c(2:numCols)]
CARL13_SDMTable <- graph.adjacency(CARL13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(CARL13_SDMTable, vertex.label = V(CARL13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
CARL13_SDM.clusterCoef <- transitivity(CARL13_SDMTable, type="global") #cluster coefficient
CARL13_SDM.degreeCent <- centralization.degree(CARL13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_SDMftn <- as.network.matrix(CARL13_SDMft)
CARL13_SDM.netDensity <- network.density(CARL13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_SDM.entropy <- entropy(CARL13_SDMft) #entropy
CARL13_SDM.netMx <- cbind(CARL13_SDM.netMx, CARL13_SDM.clusterCoef, CARL13_SDM.degreeCent$centralization,
CARL13_SDM.netDensity, CARL13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "CARL"
KIoutcome = "Turnover_DM"
CARL13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
CARL13_TDMg2 <- data.frame(CARL13_TDM)
CARL13_TDMg2 <- CARL13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_TDMg2$player1
player2vector <- CARL13_TDMg2$player2
CARL13_TDMg3 <- CARL13_TDMg2
CARL13_TDMg3$p1inp2vec <- is.element(CARL13_TDMg3$player1, player2vector)
CARL13_TDMg3$p2inp1vec <- is.element(CARL13_TDMg3$player2, player1vector)
addPlayer1 <- CARL13_TDMg3[ which(CARL13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_TDMg3[ which(CARL13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_TDMg2 <- rbind(CARL13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
CARL13_TDMft <- ftable(CARL13_TDMg2$player1, CARL13_TDMg2$player2)
CARL13_TDMft2 <- as.matrix(CARL13_TDMft)
numRows <- nrow(CARL13_TDMft2)
numCols <- ncol(CARL13_TDMft2)
CARL13_TDMft3 <- CARL13_TDMft2[c(2:numRows) , c(2:numCols)]
CARL13_TDMTable <- graph.adjacency(CARL13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(CARL13_TDMTable, vertex.label = V(CARL13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
CARL13_TDM.clusterCoef <- transitivity(CARL13_TDMTable, type="global") #cluster coefficient
CARL13_TDM.degreeCent <- centralization.degree(CARL13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_TDMftn <- as.network.matrix(CARL13_TDMft)
CARL13_TDM.netDensity <- network.density(CARL13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_TDM.entropy <- entropy(CARL13_TDMft) #entropy
CARL13_TDM.netMx <- cbind(CARL13_TDM.netMx, CARL13_TDM.clusterCoef, CARL13_TDM.degreeCent$centralization,
CARL13_TDM.netDensity, CARL13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "CARL"
KIoutcome = "Stoppage_D"
CARL13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
CARL13_SDg2 <- data.frame(CARL13_SD)
CARL13_SDg2 <- CARL13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_SDg2$player1
player2vector <- CARL13_SDg2$player2
CARL13_SDg3 <- CARL13_SDg2
CARL13_SDg3$p1inp2vec <- is.element(CARL13_SDg3$player1, player2vector)
CARL13_SDg3$p2inp1vec <- is.element(CARL13_SDg3$player2, player1vector)
addPlayer1 <- CARL13_SDg3[ which(CARL13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_SDg3[ which(CARL13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_SDg2 <- rbind(CARL13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
CARL13_SDft <- ftable(CARL13_SDg2$player1, CARL13_SDg2$player2)
CARL13_SDft2 <- as.matrix(CARL13_SDft)
numRows <- nrow(CARL13_SDft2)
numCols <- ncol(CARL13_SDft2)
CARL13_SDft3 <- CARL13_SDft2[c(2:numRows) , c(2:numCols)]
CARL13_SDTable <- graph.adjacency(CARL13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(CARL13_SDTable, vertex.label = V(CARL13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
CARL13_SD.clusterCoef <- transitivity(CARL13_SDTable, type="global") #cluster coefficient
CARL13_SD.degreeCent <- centralization.degree(CARL13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_SDftn <- as.network.matrix(CARL13_SDft)
CARL13_SD.netDensity <- network.density(CARL13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_SD.entropy <- entropy(CARL13_SDft) #entropy
CARL13_SD.netMx <- cbind(CARL13_SD.netMx, CARL13_SD.clusterCoef, CARL13_SD.degreeCent$centralization,
CARL13_SD.netDensity, CARL13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "CARL"
KIoutcome = "Turnover_D"
CARL13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
CARL13_TDg2 <- data.frame(CARL13_TD)
CARL13_TDg2 <- CARL13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_TDg2$player1
player2vector <- CARL13_TDg2$player2
CARL13_TDg3 <- CARL13_TDg2
CARL13_TDg3$p1inp2vec <- is.element(CARL13_TDg3$player1, player2vector)
CARL13_TDg3$p2inp1vec <- is.element(CARL13_TDg3$player2, player1vector)
addPlayer1 <- CARL13_TDg3[ which(CARL13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_TDg3[ which(CARL13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_TDg2 <- rbind(CARL13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
CARL13_TDft <- ftable(CARL13_TDg2$player1, CARL13_TDg2$player2)
CARL13_TDft2 <- as.matrix(CARL13_TDft)
numRows <- nrow(CARL13_TDft2)
numCols <- ncol(CARL13_TDft2)
CARL13_TDft3 <- CARL13_TDft2[c(2:numRows) , c(2:numCols)]
CARL13_TDTable <- graph.adjacency(CARL13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(CARL13_TDTable, vertex.label = V(CARL13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
CARL13_TD.clusterCoef <- transitivity(CARL13_TDTable, type="global") #cluster coefficient
CARL13_TD.degreeCent <- centralization.degree(CARL13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_TDftn <- as.network.matrix(CARL13_TDft)
CARL13_TD.netDensity <- network.density(CARL13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_TD.entropy <- entropy(CARL13_TDft) #entropy
CARL13_TD.netMx <- cbind(CARL13_TD.netMx, CARL13_TD.clusterCoef, CARL13_TD.degreeCent$centralization,
CARL13_TD.netDensity, CARL13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
round = 13
teamName = "CARL"
KIoutcome = "End of Qtr_DM"
CARL13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
CARL13_QTg2 <- data.frame(CARL13_QT)
CARL13_QTg2 <- CARL13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_QTg2$player1
player2vector <- CARL13_QTg2$player2
CARL13_QTg3 <- CARL13_QTg2
CARL13_QTg3$p1inp2vec <- is.element(CARL13_QTg3$player1, player2vector)
CARL13_QTg3$p2inp1vec <- is.element(CARL13_QTg3$player2, player1vector)
addPlayer1 <- CARL13_QTg3[ which(CARL13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_QTg3[ which(CARL13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_QTg2 <- rbind(CARL13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
CARL13_QTft <- ftable(CARL13_QTg2$player1, CARL13_QTg2$player2)
CARL13_QTft2 <- as.matrix(CARL13_QTft)
numRows <- nrow(CARL13_QTft2)
numCols <- ncol(CARL13_QTft2)
CARL13_QTft3 <- CARL13_QTft2[c(2:numRows) , c(2:numCols)]
CARL13_QTTable <- graph.adjacency(CARL13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(CARL13_QTTable, vertex.label = V(CARL13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
CARL13_QT.clusterCoef <- transitivity(CARL13_QTTable, type="global") #cluster coefficient
CARL13_QT.degreeCent <- centralization.degree(CARL13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_QTftn <- as.network.matrix(CARL13_QTft)
CARL13_QT.netDensity <- network.density(CARL13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_QT.entropy <- entropy(CARL13_QTft) #entropy
CARL13_QT.netMx <- cbind(CARL13_QT.netMx, CARL13_QT.clusterCoef, CARL13_QT.degreeCent$centralization,
CARL13_QT.netDensity, CARL13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_QT.netMx) <- varnames
#############################################################################
#COLLINGWOOD
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "COLL"
KIoutcome = "Goal_F"
COLL13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
COLL13_Gg2 <- data.frame(COLL13_G)
COLL13_Gg2 <- COLL13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_Gg2$player1
player2vector <- COLL13_Gg2$player2
COLL13_Gg3 <- COLL13_Gg2
COLL13_Gg3$p1inp2vec <- is.element(COLL13_Gg3$player1, player2vector)
COLL13_Gg3$p2inp1vec <- is.element(COLL13_Gg3$player2, player1vector)
addPlayer1 <- COLL13_Gg3[ which(COLL13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_Gg3[ which(COLL13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_Gg2 <- rbind(COLL13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
COLL13_Gft <- ftable(COLL13_Gg2$player1, COLL13_Gg2$player2)
COLL13_Gft2 <- as.matrix(COLL13_Gft)
numRows <- nrow(COLL13_Gft2)
numCols <- ncol(COLL13_Gft2)
COLL13_Gft3 <- COLL13_Gft2[c(2:numRows) , c(2:numCols)]
COLL13_GTable <- graph.adjacency(COLL13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(COLL13_GTable, vertex.label = V(COLL13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
COLL13_G.clusterCoef <- transitivity(COLL13_GTable, type="global") #cluster coefficient
COLL13_G.degreeCent <- centralization.degree(COLL13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_Gftn <- as.network.matrix(COLL13_Gft)
COLL13_G.netDensity <- network.density(COLL13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_G.entropy <- entropy(COLL13_Gft) #entropy
COLL13_G.netMx <- cbind(COLL13_G.netMx, COLL13_G.clusterCoef, COLL13_G.degreeCent$centralization,
COLL13_G.netDensity, COLL13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
#NA
round = 13
teamName = "COLL"
KIoutcome = "Behind_F"
COLL13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
COLL13_Bg2 <- data.frame(COLL13_B)
COLL13_Bg2 <- COLL13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_Bg2$player1
player2vector <- COLL13_Bg2$player2
COLL13_Bg3 <- COLL13_Bg2
COLL13_Bg3$p1inp2vec <- is.element(COLL13_Bg3$player1, player2vector)
COLL13_Bg3$p2inp1vec <- is.element(COLL13_Bg3$player2, player1vector)
addPlayer1 <- COLL13_Bg3[ which(COLL13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_Bg3[ which(COLL13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_Bg2 <- rbind(COLL13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
COLL13_Bft <- ftable(COLL13_Bg2$player1, COLL13_Bg2$player2)
COLL13_Bft2 <- as.matrix(COLL13_Bft)
numRows <- nrow(COLL13_Bft2)
numCols <- ncol(COLL13_Bft2)
COLL13_Bft3 <- COLL13_Bft2[c(2:numRows) , c(2:numCols)]
COLL13_BTable <- graph.adjacency(COLL13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(COLL13_BTable, vertex.label = V(COLL13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
COLL13_B.clusterCoef <- transitivity(COLL13_BTable, type="global") #cluster coefficient
COLL13_B.degreeCent <- centralization.degree(COLL13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_Bftn <- as.network.matrix(COLL13_Bft)
COLL13_B.netDensity <- network.density(COLL13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_B.entropy <- entropy(COLL13_Bft) #entropy
COLL13_B.netMx <- cbind(COLL13_B.netMx, COLL13_B.clusterCoef, COLL13_B.degreeCent$centralization,
COLL13_B.netDensity, COLL13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
round = 13
teamName = "COLL"
KIoutcome = "Stoppage_F"
COLL13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
COLL13_SFg2 <- data.frame(COLL13_SF)
COLL13_SFg2 <- COLL13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_SFg2$player1
player2vector <- COLL13_SFg2$player2
COLL13_SFg3 <- COLL13_SFg2
COLL13_SFg3$p1inp2vec <- is.element(COLL13_SFg3$player1, player2vector)
COLL13_SFg3$p2inp1vec <- is.element(COLL13_SFg3$player2, player1vector)
addPlayer1 <- COLL13_SFg3[ which(COLL13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_SFg3[ which(COLL13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_SFg2 <- rbind(COLL13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
COLL13_SFft <- ftable(COLL13_SFg2$player1, COLL13_SFg2$player2)
COLL13_SFft2 <- as.matrix(COLL13_SFft)
numRows <- nrow(COLL13_SFft2)
numCols <- ncol(COLL13_SFft2)
COLL13_SFft3 <- COLL13_SFft2[c(2:numRows) , c(2:numCols)]
COLL13_SFTable <- graph.adjacency(COLL13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(COLL13_SFTable, vertex.label = V(COLL13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
COLL13_SF.clusterCoef <- transitivity(COLL13_SFTable, type="global") #cluster coefficient
COLL13_SF.degreeCent <- centralization.degree(COLL13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_SFftn <- as.network.matrix(COLL13_SFft)
COLL13_SF.netDensity <- network.density(COLL13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_SF.entropy <- entropy(COLL13_SFft) #entropy
COLL13_SF.netMx <- cbind(COLL13_SF.netMx, COLL13_SF.clusterCoef, COLL13_SF.degreeCent$centralization,
COLL13_SF.netDensity, COLL13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "COLL"
KIoutcome = "Turnover_F"
COLL13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
COLL13_TFg2 <- data.frame(COLL13_TF)
COLL13_TFg2 <- COLL13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_TFg2$player1
player2vector <- COLL13_TFg2$player2
COLL13_TFg3 <- COLL13_TFg2
COLL13_TFg3$p1inp2vec <- is.element(COLL13_TFg3$player1, player2vector)
COLL13_TFg3$p2inp1vec <- is.element(COLL13_TFg3$player2, player1vector)
addPlayer1 <- COLL13_TFg3[ which(COLL13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_TFg3[ which(COLL13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_TFg2 <- rbind(COLL13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
COLL13_TFft <- ftable(COLL13_TFg2$player1, COLL13_TFg2$player2)
COLL13_TFft2 <- as.matrix(COLL13_TFft)
numRows <- nrow(COLL13_TFft2)
numCols <- ncol(COLL13_TFft2)
COLL13_TFft3 <- COLL13_TFft2[c(2:numRows) , c(2:numCols)]
COLL13_TFTable <- graph.adjacency(COLL13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(COLL13_TFTable, vertex.label = V(COLL13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
COLL13_TF.clusterCoef <- transitivity(COLL13_TFTable, type="global") #cluster coefficient
COLL13_TF.degreeCent <- centralization.degree(COLL13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_TFftn <- as.network.matrix(COLL13_TFft)
COLL13_TF.netDensity <- network.density(COLL13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_TF.entropy <- entropy(COLL13_TFft) #entropy
COLL13_TF.netMx <- cbind(COLL13_TF.netMx, COLL13_TF.clusterCoef, COLL13_TF.degreeCent$centralization,
COLL13_TF.netDensity, COLL13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
#NA
round = 13
teamName = "COLL"
KIoutcome = "Stoppage_AM"
COLL13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
COLL13_SAMg2 <- data.frame(COLL13_SAM)
COLL13_SAMg2 <- COLL13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_SAMg2$player1
player2vector <- COLL13_SAMg2$player2
COLL13_SAMg3 <- COLL13_SAMg2
COLL13_SAMg3$p1inp2vec <- is.element(COLL13_SAMg3$player1, player2vector)
COLL13_SAMg3$p2inp1vec <- is.element(COLL13_SAMg3$player2, player1vector)
addPlayer1 <- COLL13_SAMg3[ which(COLL13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_SAMg3[ which(COLL13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_SAMg2 <- rbind(COLL13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
COLL13_SAMft <- ftable(COLL13_SAMg2$player1, COLL13_SAMg2$player2)
COLL13_SAMft2 <- as.matrix(COLL13_SAMft)
numRows <- nrow(COLL13_SAMft2)
numCols <- ncol(COLL13_SAMft2)
COLL13_SAMft3 <- COLL13_SAMft2[c(2:numRows) , c(2:numCols)]
COLL13_SAMTable <- graph.adjacency(COLL13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(COLL13_SAMTable, vertex.label = V(COLL13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
COLL13_SAM.clusterCoef <- transitivity(COLL13_SAMTable, type="global") #cluster coefficient
COLL13_SAM.degreeCent <- centralization.degree(COLL13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_SAMftn <- as.network.matrix(COLL13_SAMft)
COLL13_SAM.netDensity <- network.density(COLL13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_SAM.entropy <- entropy(COLL13_SAMft) #entropy
COLL13_SAM.netMx <- cbind(COLL13_SAM.netMx, COLL13_SAM.clusterCoef, COLL13_SAM.degreeCent$centralization,
COLL13_SAM.netDensity, COLL13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "COLL"
KIoutcome = "Turnover_AM"
COLL13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
COLL13_TAMg2 <- data.frame(COLL13_TAM)
COLL13_TAMg2 <- COLL13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_TAMg2$player1
player2vector <- COLL13_TAMg2$player2
COLL13_TAMg3 <- COLL13_TAMg2
COLL13_TAMg3$p1inp2vec <- is.element(COLL13_TAMg3$player1, player2vector)
COLL13_TAMg3$p2inp1vec <- is.element(COLL13_TAMg3$player2, player1vector)
addPlayer1 <- COLL13_TAMg3[ which(COLL13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_TAMg3[ which(COLL13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_TAMg2 <- rbind(COLL13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
COLL13_TAMft <- ftable(COLL13_TAMg2$player1, COLL13_TAMg2$player2)
COLL13_TAMft2 <- as.matrix(COLL13_TAMft)
numRows <- nrow(COLL13_TAMft2)
numCols <- ncol(COLL13_TAMft2)
COLL13_TAMft3 <- COLL13_TAMft2[c(2:numRows) , c(2:numCols)]
COLL13_TAMTable <- graph.adjacency(COLL13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(COLL13_TAMTable, vertex.label = V(COLL13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
COLL13_TAM.clusterCoef <- transitivity(COLL13_TAMTable, type="global") #cluster coefficient
COLL13_TAM.degreeCent <- centralization.degree(COLL13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_TAMftn <- as.network.matrix(COLL13_TAMft)
COLL13_TAM.netDensity <- network.density(COLL13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_TAM.entropy <- entropy(COLL13_TAMft) #entropy
COLL13_TAM.netMx <- cbind(COLL13_TAM.netMx, COLL13_TAM.clusterCoef, COLL13_TAM.degreeCent$centralization,
COLL13_TAM.netDensity, COLL13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "COLL"
KIoutcome = "Stoppage_DM"
COLL13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
COLL13_SDMg2 <- data.frame(COLL13_SDM)
COLL13_SDMg2 <- COLL13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_SDMg2$player1
player2vector <- COLL13_SDMg2$player2
COLL13_SDMg3 <- COLL13_SDMg2
COLL13_SDMg3$p1inp2vec <- is.element(COLL13_SDMg3$player1, player2vector)
COLL13_SDMg3$p2inp1vec <- is.element(COLL13_SDMg3$player2, player1vector)
addPlayer1 <- COLL13_SDMg3[ which(COLL13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_SDMg3[ which(COLL13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_SDMg2 <- rbind(COLL13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
COLL13_SDMft <- ftable(COLL13_SDMg2$player1, COLL13_SDMg2$player2)
COLL13_SDMft2 <- as.matrix(COLL13_SDMft)
numRows <- nrow(COLL13_SDMft2)
numCols <- ncol(COLL13_SDMft2)
COLL13_SDMft3 <- COLL13_SDMft2[c(2:numRows) , c(2:numCols)]
COLL13_SDMTable <- graph.adjacency(COLL13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(COLL13_SDMTable, vertex.label = V(COLL13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
COLL13_SDM.clusterCoef <- transitivity(COLL13_SDMTable, type="global") #cluster coefficient
COLL13_SDM.degreeCent <- centralization.degree(COLL13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_SDMftn <- as.network.matrix(COLL13_SDMft)
COLL13_SDM.netDensity <- network.density(COLL13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_SDM.entropy <- entropy(COLL13_SDMft) #entropy
COLL13_SDM.netMx <- cbind(COLL13_SDM.netMx, COLL13_SDM.clusterCoef, COLL13_SDM.degreeCent$centralization,
COLL13_SDM.netDensity, COLL13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "COLL"
KIoutcome = "Turnover_DM"
COLL13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
COLL13_TDMg2 <- data.frame(COLL13_TDM)
COLL13_TDMg2 <- COLL13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_TDMg2$player1
player2vector <- COLL13_TDMg2$player2
COLL13_TDMg3 <- COLL13_TDMg2
COLL13_TDMg3$p1inp2vec <- is.element(COLL13_TDMg3$player1, player2vector)
COLL13_TDMg3$p2inp1vec <- is.element(COLL13_TDMg3$player2, player1vector)
addPlayer1 <- COLL13_TDMg3[ which(COLL13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_TDMg3[ which(COLL13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_TDMg2 <- rbind(COLL13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
COLL13_TDMft <- ftable(COLL13_TDMg2$player1, COLL13_TDMg2$player2)
COLL13_TDMft2 <- as.matrix(COLL13_TDMft)
numRows <- nrow(COLL13_TDMft2)
numCols <- ncol(COLL13_TDMft2)
COLL13_TDMft3 <- COLL13_TDMft2[c(2:numRows) , c(2:numCols)]
COLL13_TDMTable <- graph.adjacency(COLL13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(COLL13_TDMTable, vertex.label = V(COLL13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
COLL13_TDM.clusterCoef <- transitivity(COLL13_TDMTable, type="global") #cluster coefficient
COLL13_TDM.degreeCent <- centralization.degree(COLL13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_TDMftn <- as.network.matrix(COLL13_TDMft)
COLL13_TDM.netDensity <- network.density(COLL13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_TDM.entropy <- entropy(COLL13_TDMft) #entropy
COLL13_TDM.netMx <- cbind(COLL13_TDM.netMx, COLL13_TDM.clusterCoef, COLL13_TDM.degreeCent$centralization,
COLL13_TDM.netDensity, COLL13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
round = 13
teamName = "COLL"
KIoutcome = "Stoppage_D"
COLL13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
COLL13_SDg2 <- data.frame(COLL13_SD)
COLL13_SDg2 <- COLL13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_SDg2$player1
player2vector <- COLL13_SDg2$player2
COLL13_SDg3 <- COLL13_SDg2
COLL13_SDg3$p1inp2vec <- is.element(COLL13_SDg3$player1, player2vector)
COLL13_SDg3$p2inp1vec <- is.element(COLL13_SDg3$player2, player1vector)
addPlayer1 <- COLL13_SDg3[ which(COLL13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_SDg3[ which(COLL13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_SDg2 <- rbind(COLL13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
COLL13_SDft <- ftable(COLL13_SDg2$player1, COLL13_SDg2$player2)
COLL13_SDft2 <- as.matrix(COLL13_SDft)
numRows <- nrow(COLL13_SDft2)
numCols <- ncol(COLL13_SDft2)
COLL13_SDft3 <- COLL13_SDft2[c(2:numRows) , c(2:numCols)]
COLL13_SDTable <- graph.adjacency(COLL13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(COLL13_SDTable, vertex.label = V(COLL13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
COLL13_SD.clusterCoef <- transitivity(COLL13_SDTable, type="global") #cluster coefficient
COLL13_SD.degreeCent <- centralization.degree(COLL13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_SDftn <- as.network.matrix(COLL13_SDft)
COLL13_SD.netDensity <- network.density(COLL13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_SD.entropy <- entropy(COLL13_SDft) #entropy
COLL13_SD.netMx <- cbind(COLL13_SD.netMx, COLL13_SD.clusterCoef, COLL13_SD.degreeCent$centralization,
COLL13_SD.netDensity, COLL13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "COLL"
KIoutcome = "Turnover_D"
COLL13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
COLL13_TDg2 <- data.frame(COLL13_TD)
COLL13_TDg2 <- COLL13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_TDg2$player1
player2vector <- COLL13_TDg2$player2
COLL13_TDg3 <- COLL13_TDg2
COLL13_TDg3$p1inp2vec <- is.element(COLL13_TDg3$player1, player2vector)
COLL13_TDg3$p2inp1vec <- is.element(COLL13_TDg3$player2, player1vector)
addPlayer1 <- COLL13_TDg3[ which(COLL13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_TDg3[ which(COLL13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_TDg2 <- rbind(COLL13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
COLL13_TDft <- ftable(COLL13_TDg2$player1, COLL13_TDg2$player2)
COLL13_TDft2 <- as.matrix(COLL13_TDft)
numRows <- nrow(COLL13_TDft2)
numCols <- ncol(COLL13_TDft2)
COLL13_TDft3 <- COLL13_TDft2[c(2:numRows) , c(2:numCols)]
COLL13_TDTable <- graph.adjacency(COLL13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(COLL13_TDTable, vertex.label = V(COLL13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
COLL13_TD.clusterCoef <- transitivity(COLL13_TDTable, type="global") #cluster coefficient
COLL13_TD.degreeCent <- centralization.degree(COLL13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_TDftn <- as.network.matrix(COLL13_TDft)
COLL13_TD.netDensity <- network.density(COLL13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_TD.entropy <- entropy(COLL13_TDft) #entropy
COLL13_TD.netMx <- cbind(COLL13_TD.netMx, COLL13_TD.clusterCoef, COLL13_TD.degreeCent$centralization,
COLL13_TD.netDensity, COLL13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "COLL"
KIoutcome = "End of Qtr_DM"
COLL13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
COLL13_QTg2 <- data.frame(COLL13_QT)
COLL13_QTg2 <- COLL13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_QTg2$player1
player2vector <- COLL13_QTg2$player2
COLL13_QTg3 <- COLL13_QTg2
COLL13_QTg3$p1inp2vec <- is.element(COLL13_QTg3$player1, player2vector)
COLL13_QTg3$p2inp1vec <- is.element(COLL13_QTg3$player2, player1vector)
addPlayer1 <- COLL13_QTg3[ which(COLL13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_QTg3[ which(COLL13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_QTg2 <- rbind(COLL13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
COLL13_QTft <- ftable(COLL13_QTg2$player1, COLL13_QTg2$player2)
COLL13_QTft2 <- as.matrix(COLL13_QTft)
numRows <- nrow(COLL13_QTft2)
numCols <- ncol(COLL13_QTft2)
COLL13_QTft3 <- COLL13_QTft2[c(2:numRows) , c(2:numCols)]
COLL13_QTTable <- graph.adjacency(COLL13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(COLL13_QTTable, vertex.label = V(COLL13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
COLL13_QT.clusterCoef <- transitivity(COLL13_QTTable, type="global") #cluster coefficient
COLL13_QT.degreeCent <- centralization.degree(COLL13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_QTftn <- as.network.matrix(COLL13_QTft)
COLL13_QT.netDensity <- network.density(COLL13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_QT.entropy <- entropy(COLL13_QTft) #entropy
COLL13_QT.netMx <- cbind(COLL13_QT.netMx, COLL13_QT.clusterCoef, COLL13_QT.degreeCent$centralization,
COLL13_QT.netDensity, COLL13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_QT.netMx) <- varnames
#############################################################################
#ESSENDON
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
round = 13
teamName = "ESS"
KIoutcome = "Goal_F"
ESS13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
ESS13_Gg2 <- data.frame(ESS13_G)
ESS13_Gg2 <- ESS13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_Gg2$player1
player2vector <- ESS13_Gg2$player2
ESS13_Gg3 <- ESS13_Gg2
ESS13_Gg3$p1inp2vec <- is.element(ESS13_Gg3$player1, player2vector)
ESS13_Gg3$p2inp1vec <- is.element(ESS13_Gg3$player2, player1vector)
addPlayer1 <- ESS13_Gg3[ which(ESS13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, empty, zero)
addPlayer2 <- ESS13_Gg3[ which(ESS13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_Gg2 <- rbind(ESS13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
ESS13_Gft <- ftable(ESS13_Gg2$player1, ESS13_Gg2$player2)
ESS13_Gft2 <- as.matrix(ESS13_Gft)
numRows <- nrow(ESS13_Gft2)
numCols <- ncol(ESS13_Gft2)
ESS13_Gft3 <- ESS13_Gft2[c(2:numRows) , c(2:numCols)]
ESS13_GTable <- graph.adjacency(ESS13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(ESS13_GTable, vertex.label = V(ESS13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
ESS13_G.clusterCoef <- transitivity(ESS13_GTable, type="global") #cluster coefficient
ESS13_G.degreeCent <- centralization.degree(ESS13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_Gftn <- as.network.matrix(ESS13_Gft)
ESS13_G.netDensity <- network.density(ESS13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_G.entropy <- entropy(ESS13_Gft) #entropy
ESS13_G.netMx <- cbind(ESS13_G.netMx, ESS13_G.clusterCoef, ESS13_G.degreeCent$centralization,
ESS13_G.netDensity, ESS13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
round = 13
teamName = "ESS"
KIoutcome = "Behind_F"
ESS13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
ESS13_Bg2 <- data.frame(ESS13_B)
ESS13_Bg2 <- ESS13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_Bg2$player1
player2vector <- ESS13_Bg2$player2
ESS13_Bg3 <- ESS13_Bg2
ESS13_Bg3$p1inp2vec <- is.element(ESS13_Bg3$player1, player2vector)
ESS13_Bg3$p2inp1vec <- is.element(ESS13_Bg3$player2, player1vector)
addPlayer1 <- ESS13_Bg3[ which(ESS13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_Bg3[ which(ESS13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_Bg2 <- rbind(ESS13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
ESS13_Bft <- ftable(ESS13_Bg2$player1, ESS13_Bg2$player2)
ESS13_Bft2 <- as.matrix(ESS13_Bft)
numRows <- nrow(ESS13_Bft2)
numCols <- ncol(ESS13_Bft2)
ESS13_Bft3 <- ESS13_Bft2[c(2:numRows) , c(2:numCols)]
ESS13_BTable <- graph.adjacency(ESS13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(ESS13_BTable, vertex.label = V(ESS13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
ESS13_B.clusterCoef <- transitivity(ESS13_BTable, type="global") #cluster coefficient
ESS13_B.degreeCent <- centralization.degree(ESS13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_Bftn <- as.network.matrix(ESS13_Bft)
ESS13_B.netDensity <- network.density(ESS13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_B.entropy <- entropy(ESS13_Bft) #entropy
ESS13_B.netMx <- cbind(ESS13_B.netMx, ESS13_B.clusterCoef, ESS13_B.degreeCent$centralization,
ESS13_B.netDensity, ESS13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "ESS"
KIoutcome = "Stoppage_F"
ESS13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
ESS13_SFg2 <- data.frame(ESS13_SF)
ESS13_SFg2 <- ESS13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_SFg2$player1
player2vector <- ESS13_SFg2$player2
ESS13_SFg3 <- ESS13_SFg2
ESS13_SFg3$p1inp2vec <- is.element(ESS13_SFg3$player1, player2vector)
ESS13_SFg3$p2inp1vec <- is.element(ESS13_SFg3$player2, player1vector)
addPlayer1 <- ESS13_SFg3[ which(ESS13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_SFg3[ which(ESS13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_SFg2 <- rbind(ESS13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
ESS13_SFft <- ftable(ESS13_SFg2$player1, ESS13_SFg2$player2)
ESS13_SFft2 <- as.matrix(ESS13_SFft)
numRows <- nrow(ESS13_SFft2)
numCols <- ncol(ESS13_SFft2)
ESS13_SFft3 <- ESS13_SFft2[c(2:numRows) , c(2:numCols)]
ESS13_SFTable <- graph.adjacency(ESS13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(ESS13_SFTable, vertex.label = V(ESS13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
ESS13_SF.clusterCoef <- transitivity(ESS13_SFTable, type="global") #cluster coefficient
ESS13_SF.degreeCent <- centralization.degree(ESS13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_SFftn <- as.network.matrix(ESS13_SFft)
ESS13_SF.netDensity <- network.density(ESS13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_SF.entropy <- entropy(ESS13_SFft) #entropy
ESS13_SF.netMx <- cbind(ESS13_SF.netMx, ESS13_SF.clusterCoef, ESS13_SF.degreeCent$centralization,
ESS13_SF.netDensity, ESS13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
#NA
round = 13
teamName = "ESS"
KIoutcome = "Turnover_F"
ESS13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
ESS13_TFg2 <- data.frame(ESS13_TF)
ESS13_TFg2 <- ESS13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_TFg2$player1
player2vector <- ESS13_TFg2$player2
ESS13_TFg3 <- ESS13_TFg2
ESS13_TFg3$p1inp2vec <- is.element(ESS13_TFg3$player1, player2vector)
ESS13_TFg3$p2inp1vec <- is.element(ESS13_TFg3$player2, player1vector)
addPlayer1 <- ESS13_TFg3[ which(ESS13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_TFg3[ which(ESS13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_TFg2 <- rbind(ESS13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
ESS13_TFft <- ftable(ESS13_TFg2$player1, ESS13_TFg2$player2)
ESS13_TFft2 <- as.matrix(ESS13_TFft)
numRows <- nrow(ESS13_TFft2)
numCols <- ncol(ESS13_TFft2)
ESS13_TFft3 <- ESS13_TFft2[c(2:numRows) , c(2:numCols)]
ESS13_TFTable <- graph.adjacency(ESS13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(ESS13_TFTable, vertex.label = V(ESS13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
ESS13_TF.clusterCoef <- transitivity(ESS13_TFTable, type="global") #cluster coefficient
ESS13_TF.degreeCent <- centralization.degree(ESS13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_TFftn <- as.network.matrix(ESS13_TFft)
ESS13_TF.netDensity <- network.density(ESS13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_TF.entropy <- entropy(ESS13_TFft) #entropy
ESS13_TF.netMx <- cbind(ESS13_TF.netMx, ESS13_TF.clusterCoef, ESS13_TF.degreeCent$centralization,
ESS13_TF.netDensity, ESS13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
#NA
round = 13
teamName = "ESS"
KIoutcome = "Stoppage_AM"
ESS13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
ESS13_SAMg2 <- data.frame(ESS13_SAM)
ESS13_SAMg2 <- ESS13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_SAMg2$player1
player2vector <- ESS13_SAMg2$player2
ESS13_SAMg3 <- ESS13_SAMg2
ESS13_SAMg3$p1inp2vec <- is.element(ESS13_SAMg3$player1, player2vector)
ESS13_SAMg3$p2inp1vec <- is.element(ESS13_SAMg3$player2, player1vector)
addPlayer1 <- ESS13_SAMg3[ which(ESS13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_SAMg3[ which(ESS13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_SAMg2 <- rbind(ESS13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
ESS13_SAMft <- ftable(ESS13_SAMg2$player1, ESS13_SAMg2$player2)
ESS13_SAMft2 <- as.matrix(ESS13_SAMft)
numRows <- nrow(ESS13_SAMft2)
numCols <- ncol(ESS13_SAMft2)
ESS13_SAMft3 <- ESS13_SAMft2[c(2:numRows) , c(2:numCols)]
ESS13_SAMTable <- graph.adjacency(ESS13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(ESS13_SAMTable, vertex.label = V(ESS13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
ESS13_SAM.clusterCoef <- transitivity(ESS13_SAMTable, type="global") #cluster coefficient
ESS13_SAM.degreeCent <- centralization.degree(ESS13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_SAMftn <- as.network.matrix(ESS13_SAMft)
ESS13_SAM.netDensity <- network.density(ESS13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_SAM.entropy <- entropy(ESS13_SAMft) #entropy
ESS13_SAM.netMx <- cbind(ESS13_SAM.netMx, ESS13_SAM.clusterCoef, ESS13_SAM.degreeCent$centralization,
ESS13_SAM.netDensity, ESS13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "ESS"
KIoutcome = "Turnover_AM"
ESS13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
ESS13_TAMg2 <- data.frame(ESS13_TAM)
ESS13_TAMg2 <- ESS13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_TAMg2$player1
player2vector <- ESS13_TAMg2$player2
ESS13_TAMg3 <- ESS13_TAMg2
ESS13_TAMg3$p1inp2vec <- is.element(ESS13_TAMg3$player1, player2vector)
ESS13_TAMg3$p2inp1vec <- is.element(ESS13_TAMg3$player2, player1vector)
addPlayer1 <- ESS13_TAMg3[ which(ESS13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_TAMg3[ which(ESS13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_TAMg2 <- rbind(ESS13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
ESS13_TAMft <- ftable(ESS13_TAMg2$player1, ESS13_TAMg2$player2)
ESS13_TAMft2 <- as.matrix(ESS13_TAMft)
numRows <- nrow(ESS13_TAMft2)
numCols <- ncol(ESS13_TAMft2)
ESS13_TAMft3 <- ESS13_TAMft2[c(2:numRows) , c(2:numCols)]
ESS13_TAMTable <- graph.adjacency(ESS13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(ESS13_TAMTable, vertex.label = V(ESS13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
ESS13_TAM.clusterCoef <- transitivity(ESS13_TAMTable, type="global") #cluster coefficient
ESS13_TAM.degreeCent <- centralization.degree(ESS13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_TAMftn <- as.network.matrix(ESS13_TAMft)
ESS13_TAM.netDensity <- network.density(ESS13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_TAM.entropy <- entropy(ESS13_TAMft) #entropy
ESS13_TAM.netMx <- cbind(ESS13_TAM.netMx, ESS13_TAM.clusterCoef, ESS13_TAM.degreeCent$centralization,
ESS13_TAM.netDensity, ESS13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
#NA
round = 13
teamName = "ESS"
KIoutcome = "Stoppage_DM"
ESS13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
ESS13_SDMg2 <- data.frame(ESS13_SDM)
ESS13_SDMg2 <- ESS13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_SDMg2$player1
player2vector <- ESS13_SDMg2$player2
ESS13_SDMg3 <- ESS13_SDMg2
ESS13_SDMg3$p1inp2vec <- is.element(ESS13_SDMg3$player1, player2vector)
ESS13_SDMg3$p2inp1vec <- is.element(ESS13_SDMg3$player2, player1vector)
addPlayer1 <- ESS13_SDMg3[ which(ESS13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_SDMg3[ which(ESS13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_SDMg2 <- rbind(ESS13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
ESS13_SDMft <- ftable(ESS13_SDMg2$player1, ESS13_SDMg2$player2)
ESS13_SDMft2 <- as.matrix(ESS13_SDMft)
numRows <- nrow(ESS13_SDMft2)
numCols <- ncol(ESS13_SDMft2)
ESS13_SDMft3 <- ESS13_SDMft2[c(2:numRows) , c(2:numCols)]
ESS13_SDMTable <- graph.adjacency(ESS13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(ESS13_SDMTable, vertex.label = V(ESS13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
ESS13_SDM.clusterCoef <- transitivity(ESS13_SDMTable, type="global") #cluster coefficient
ESS13_SDM.degreeCent <- centralization.degree(ESS13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_SDMftn <- as.network.matrix(ESS13_SDMft)
ESS13_SDM.netDensity <- network.density(ESS13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_SDM.entropy <- entropy(ESS13_SDMft) #entropy
ESS13_SDM.netMx <- cbind(ESS13_SDM.netMx, ESS13_SDM.clusterCoef, ESS13_SDM.degreeCent$centralization,
ESS13_SDM.netDensity, ESS13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "ESS"
KIoutcome = "Turnover_DM"
ESS13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
ESS13_TDMg2 <- data.frame(ESS13_TDM)
ESS13_TDMg2 <- ESS13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_TDMg2$player1
player2vector <- ESS13_TDMg2$player2
ESS13_TDMg3 <- ESS13_TDMg2
ESS13_TDMg3$p1inp2vec <- is.element(ESS13_TDMg3$player1, player2vector)
ESS13_TDMg3$p2inp1vec <- is.element(ESS13_TDMg3$player2, player1vector)
addPlayer1 <- ESS13_TDMg3[ which(ESS13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_TDMg3[ which(ESS13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(empty, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_TDMg2 <- rbind(ESS13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
ESS13_TDMft <- ftable(ESS13_TDMg2$player1, ESS13_TDMg2$player2)
ESS13_TDMft2 <- as.matrix(ESS13_TDMft)
numRows <- nrow(ESS13_TDMft2)
numCols <- ncol(ESS13_TDMft2)
ESS13_TDMft3 <- ESS13_TDMft2[c(2:numRows) , c(2:numCols)] #Had to change no of cols when only adding rows
ESS13_TDMTable <- graph.adjacency(ESS13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(ESS13_TDMTable, vertex.label = V(ESS13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
ESS13_TDM.clusterCoef <- transitivity(ESS13_TDMTable, type="global") #cluster coefficient
ESS13_TDM.degreeCent <- centralization.degree(ESS13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_TDMftn <- as.network.matrix(ESS13_TDMft)
ESS13_TDM.netDensity <- network.density(ESS13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_TDM.entropy <- entropy(ESS13_TDMft) #entropy
ESS13_TDM.netMx <- cbind(ESS13_TDM.netMx, ESS13_TDM.clusterCoef, ESS13_TDM.degreeCent$centralization,
ESS13_TDM.netDensity, ESS13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "ESS"
KIoutcome = "Stoppage_D"
ESS13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
ESS13_SDg2 <- data.frame(ESS13_SD)
ESS13_SDg2 <- ESS13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_SDg2$player1
player2vector <- ESS13_SDg2$player2
ESS13_SDg3 <- ESS13_SDg2
ESS13_SDg3$p1inp2vec <- is.element(ESS13_SDg3$player1, player2vector)
ESS13_SDg3$p2inp1vec <- is.element(ESS13_SDg3$player2, player1vector)
addPlayer1 <- ESS13_SDg3[ which(ESS13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_SDg3[ which(ESS13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_SDg2 <- rbind(ESS13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
ESS13_SDft <- ftable(ESS13_SDg2$player1, ESS13_SDg2$player2)
ESS13_SDft2 <- as.matrix(ESS13_SDft)
numRows <- nrow(ESS13_SDft2)
numCols <- ncol(ESS13_SDft2)
ESS13_SDft3 <- ESS13_SDft2[c(2:numRows) , c(2:numCols)]
ESS13_SDTable <- graph.adjacency(ESS13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(ESS13_SDTable, vertex.label = V(ESS13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
ESS13_SD.clusterCoef <- transitivity(ESS13_SDTable, type="global") #cluster coefficient
ESS13_SD.degreeCent <- centralization.degree(ESS13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_SDftn <- as.network.matrix(ESS13_SDft)
ESS13_SD.netDensity <- network.density(ESS13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_SD.entropy <- entropy(ESS13_SDft) #entropy
ESS13_SD.netMx <- cbind(ESS13_SD.netMx, ESS13_SD.clusterCoef, ESS13_SD.degreeCent$centralization,
ESS13_SD.netDensity, ESS13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
round = 13
teamName = "ESS"
KIoutcome = "Turnover_D"
ESS13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
ESS13_TDg2 <- data.frame(ESS13_TD)
ESS13_TDg2 <- ESS13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_TDg2$player1
player2vector <- ESS13_TDg2$player2
ESS13_TDg3 <- ESS13_TDg2
ESS13_TDg3$p1inp2vec <- is.element(ESS13_TDg3$player1, player2vector)
ESS13_TDg3$p2inp1vec <- is.element(ESS13_TDg3$player2, player1vector)
addPlayer1 <- ESS13_TDg3[ which(ESS13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_TDg3[ which(ESS13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_TDg2 <- rbind(ESS13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
ESS13_TDft <- ftable(ESS13_TDg2$player1, ESS13_TDg2$player2)
ESS13_TDft2 <- as.matrix(ESS13_TDft)
numRows <- nrow(ESS13_TDft2)
numCols <- ncol(ESS13_TDft2)
ESS13_TDft3 <- ESS13_TDft2[c(2:numRows) , c(2:numCols)]
ESS13_TDTable <- graph.adjacency(ESS13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(ESS13_TDTable, vertex.label = V(ESS13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
ESS13_TD.clusterCoef <- transitivity(ESS13_TDTable, type="global") #cluster coefficient
ESS13_TD.degreeCent <- centralization.degree(ESS13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_TDftn <- as.network.matrix(ESS13_TDft)
ESS13_TD.netDensity <- network.density(ESS13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_TD.entropy <- entropy(ESS13_TDft) #entropy
ESS13_TD.netMx <- cbind(ESS13_TD.netMx, ESS13_TD.clusterCoef, ESS13_TD.degreeCent$centralization,
ESS13_TD.netDensity, ESS13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
round = 13
teamName = "ESS"
KIoutcome = "End of Qtr_DM"
ESS13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
ESS13_QTg2 <- data.frame(ESS13_QT)
ESS13_QTg2 <- ESS13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_QTg2$player1
player2vector <- ESS13_QTg2$player2
ESS13_QTg3 <- ESS13_QTg2
ESS13_QTg3$p1inp2vec <- is.element(ESS13_QTg3$player1, player2vector)
ESS13_QTg3$p2inp1vec <- is.element(ESS13_QTg3$player2, player1vector)
addPlayer1 <- ESS13_QTg3[ which(ESS13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_QTg3[ which(ESS13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(empty, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_QTg2 <- rbind(ESS13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
ESS13_QTft <- ftable(ESS13_QTg2$player1, ESS13_QTg2$player2)
ESS13_QTft2 <- as.matrix(ESS13_QTft)
numRows <- nrow(ESS13_QTft2)
numCols <- ncol(ESS13_QTft2)
ESS13_QTft3 <- ESS13_QTft2[c(2:numRows) , c(2:numCols)]
ESS13_QTTable <- graph.adjacency(ESS13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(ESS13_QTTable, vertex.label = V(ESS13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
ESS13_QT.clusterCoef <- transitivity(ESS13_QTTable, type="global") #cluster coefficient
ESS13_QT.degreeCent <- centralization.degree(ESS13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_QTftn <- as.network.matrix(ESS13_QTft)
ESS13_QT.netDensity <- network.density(ESS13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_QT.entropy <- entropy(ESS13_QTft) #entropy
ESS13_QT.netMx <- cbind(ESS13_QT.netMx, ESS13_QT.clusterCoef, ESS13_QT.degreeCent$centralization,
ESS13_QT.netDensity, ESS13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_QT.netMx) <- varnames
#############################################################################
#FREMANTLE
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
round = 13
teamName = "FRE"
KIoutcome = "Goal_F"
FRE13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
FRE13_Gg2 <- data.frame(FRE13_G)
FRE13_Gg2 <- FRE13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_Gg2$player1
player2vector <- FRE13_Gg2$player2
FRE13_Gg3 <- FRE13_Gg2
FRE13_Gg3$p1inp2vec <- is.element(FRE13_Gg3$player1, player2vector)
FRE13_Gg3$p2inp1vec <- is.element(FRE13_Gg3$player2, player1vector)
addPlayer1 <- FRE13_Gg3[ which(FRE13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_Gg3[ which(FRE13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_Gg2 <- rbind(FRE13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
FRE13_Gft <- ftable(FRE13_Gg2$player1, FRE13_Gg2$player2)
FRE13_Gft2 <- as.matrix(FRE13_Gft)
numRows <- nrow(FRE13_Gft2)
numCols <- ncol(FRE13_Gft2)
FRE13_Gft3 <- FRE13_Gft2[c(2:numRows) , c(2:numCols)]
FRE13_GTable <- graph.adjacency(FRE13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(FRE13_GTable, vertex.label = V(FRE13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
FRE13_G.clusterCoef <- transitivity(FRE13_GTable, type="global") #cluster coefficient
FRE13_G.degreeCent <- centralization.degree(FRE13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_Gftn <- as.network.matrix(FRE13_Gft)
FRE13_G.netDensity <- network.density(FRE13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_G.entropy <- entropy(FRE13_Gft) #entropy
FRE13_G.netMx <- cbind(FRE13_G.netMx, FRE13_G.clusterCoef, FRE13_G.degreeCent$centralization,
FRE13_G.netDensity, FRE13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Behind_F"
FRE13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
FRE13_Bg2 <- data.frame(FRE13_B)
FRE13_Bg2 <- FRE13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_Bg2$player1
player2vector <- FRE13_Bg2$player2
FRE13_Bg3 <- FRE13_Bg2
FRE13_Bg3$p1inp2vec <- is.element(FRE13_Bg3$player1, player2vector)
FRE13_Bg3$p2inp1vec <- is.element(FRE13_Bg3$player2, player1vector)
addPlayer1 <- FRE13_Bg3[ which(FRE13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_Bg3[ which(FRE13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_Bg2 <- rbind(FRE13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
FRE13_Bft <- ftable(FRE13_Bg2$player1, FRE13_Bg2$player2)
FRE13_Bft2 <- as.matrix(FRE13_Bft)
numRows <- nrow(FRE13_Bft2)
numCols <- ncol(FRE13_Bft2)
FRE13_Bft3 <- FRE13_Bft2[c(2:numRows) , c(2:numCols)]
FRE13_BTable <- graph.adjacency(FRE13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(FRE13_BTable, vertex.label = V(FRE13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
FRE13_B.clusterCoef <- transitivity(FRE13_BTable, type="global") #cluster coefficient
FRE13_B.degreeCent <- centralization.degree(FRE13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_Bftn <- as.network.matrix(FRE13_Bft)
FRE13_B.netDensity <- network.density(FRE13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_B.entropy <- entropy(FRE13_Bft) #entropy
FRE13_B.netMx <- cbind(FRE13_B.netMx, FRE13_B.clusterCoef, FRE13_B.degreeCent$centralization,
FRE13_B.netDensity, FRE13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Stoppage_F"
FRE13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
FRE13_SFg2 <- data.frame(FRE13_SF)
FRE13_SFg2 <- FRE13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_SFg2$player1
player2vector <- FRE13_SFg2$player2
FRE13_SFg3 <- FRE13_SFg2
FRE13_SFg3$p1inp2vec <- is.element(FRE13_SFg3$player1, player2vector)
FRE13_SFg3$p2inp1vec <- is.element(FRE13_SFg3$player2, player1vector)
addPlayer1 <- FRE13_SFg3[ which(FRE13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_SFg3[ which(FRE13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_SFg2 <- rbind(FRE13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
FRE13_SFft <- ftable(FRE13_SFg2$player1, FRE13_SFg2$player2)
FRE13_SFft2 <- as.matrix(FRE13_SFft)
numRows <- nrow(FRE13_SFft2)
numCols <- ncol(FRE13_SFft2)
FRE13_SFft3 <- FRE13_SFft2[c(2:numRows) , c(2:numCols)]
FRE13_SFTable <- graph.adjacency(FRE13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(FRE13_SFTable, vertex.label = V(FRE13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
FRE13_SF.clusterCoef <- transitivity(FRE13_SFTable, type="global") #cluster coefficient
FRE13_SF.degreeCent <- centralization.degree(FRE13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_SFftn <- as.network.matrix(FRE13_SFft)
FRE13_SF.netDensity <- network.density(FRE13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_SF.entropy <- entropy(FRE13_SFft) #entropy
FRE13_SF.netMx <- cbind(FRE13_SF.netMx, FRE13_SF.clusterCoef, FRE13_SF.degreeCent$centralization,
FRE13_SF.netDensity, FRE13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Turnover_F"
FRE13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
FRE13_TFg2 <- data.frame(FRE13_TF)
FRE13_TFg2 <- FRE13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_TFg2$player1
player2vector <- FRE13_TFg2$player2
FRE13_TFg3 <- FRE13_TFg2
FRE13_TFg3$p1inp2vec <- is.element(FRE13_TFg3$player1, player2vector)
FRE13_TFg3$p2inp1vec <- is.element(FRE13_TFg3$player2, player1vector)
addPlayer1 <- FRE13_TFg3[ which(FRE13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_TFg3[ which(FRE13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_TFg2 <- rbind(FRE13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
FRE13_TFft <- ftable(FRE13_TFg2$player1, FRE13_TFg2$player2)
FRE13_TFft2 <- as.matrix(FRE13_TFft)
numRows <- nrow(FRE13_TFft2)
numCols <- ncol(FRE13_TFft2)
FRE13_TFft3 <- FRE13_TFft2[c(2:numRows) , c(2:numCols)]
FRE13_TFTable <- graph.adjacency(FRE13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(FRE13_TFTable, vertex.label = V(FRE13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
FRE13_TF.clusterCoef <- transitivity(FRE13_TFTable, type="global") #cluster coefficient
FRE13_TF.degreeCent <- centralization.degree(FRE13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_TFftn <- as.network.matrix(FRE13_TFft)
FRE13_TF.netDensity <- network.density(FRE13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_TF.entropy <- entropy(FRE13_TFft) #entropy
FRE13_TF.netMx <- cbind(FRE13_TF.netMx, FRE13_TF.clusterCoef, FRE13_TF.degreeCent$centralization,
FRE13_TF.netDensity, FRE13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Stoppage_AM"
FRE13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
FRE13_SAMg2 <- data.frame(FRE13_SAM)
FRE13_SAMg2 <- FRE13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_SAMg2$player1
player2vector <- FRE13_SAMg2$player2
FRE13_SAMg3 <- FRE13_SAMg2
FRE13_SAMg3$p1inp2vec <- is.element(FRE13_SAMg3$player1, player2vector)
FRE13_SAMg3$p2inp1vec <- is.element(FRE13_SAMg3$player2, player1vector)
addPlayer1 <- FRE13_SAMg3[ which(FRE13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_SAMg3[ which(FRE13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_SAMg2 <- rbind(FRE13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
FRE13_SAMft <- ftable(FRE13_SAMg2$player1, FRE13_SAMg2$player2)
FRE13_SAMft2 <- as.matrix(FRE13_SAMft)
numRows <- nrow(FRE13_SAMft2)
numCols <- ncol(FRE13_SAMft2)
FRE13_SAMft3 <- FRE13_SAMft2[c(2:numRows) , c(2:numCols)]
FRE13_SAMTable <- graph.adjacency(FRE13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(FRE13_SAMTable, vertex.label = V(FRE13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
FRE13_SAM.clusterCoef <- transitivity(FRE13_SAMTable, type="global") #cluster coefficient
FRE13_SAM.degreeCent <- centralization.degree(FRE13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_SAMftn <- as.network.matrix(FRE13_SAMft)
FRE13_SAM.netDensity <- network.density(FRE13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_SAM.entropy <- entropy(FRE13_SAMft) #entropy
FRE13_SAM.netMx <- cbind(FRE13_SAM.netMx, FRE13_SAM.clusterCoef, FRE13_SAM.degreeCent$centralization,
FRE13_SAM.netDensity, FRE13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Turnover_AM"
FRE13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
FRE13_TAMg2 <- data.frame(FRE13_TAM)
FRE13_TAMg2 <- FRE13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_TAMg2$player1
player2vector <- FRE13_TAMg2$player2
FRE13_TAMg3 <- FRE13_TAMg2
FRE13_TAMg3$p1inp2vec <- is.element(FRE13_TAMg3$player1, player2vector)
FRE13_TAMg3$p2inp1vec <- is.element(FRE13_TAMg3$player2, player1vector)
addPlayer1 <- FRE13_TAMg3[ which(FRE13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_TAMg3[ which(FRE13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_TAMg2 <- rbind(FRE13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
FRE13_TAMft <- ftable(FRE13_TAMg2$player1, FRE13_TAMg2$player2)
FRE13_TAMft2 <- as.matrix(FRE13_TAMft)
numRows <- nrow(FRE13_TAMft2)
numCols <- ncol(FRE13_TAMft2)
FRE13_TAMft3 <- FRE13_TAMft2[c(2:numRows) , c(2:numCols)]
FRE13_TAMTable <- graph.adjacency(FRE13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(FRE13_TAMTable, vertex.label = V(FRE13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
FRE13_TAM.clusterCoef <- transitivity(FRE13_TAMTable, type="global") #cluster coefficient
FRE13_TAM.degreeCent <- centralization.degree(FRE13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_TAMftn <- as.network.matrix(FRE13_TAMft)
FRE13_TAM.netDensity <- network.density(FRE13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_TAM.entropy <- entropy(FRE13_TAMft) #entropy
FRE13_TAM.netMx <- cbind(FRE13_TAM.netMx, FRE13_TAM.clusterCoef, FRE13_TAM.degreeCent$centralization,
FRE13_TAM.netDensity, FRE13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "FRE"
KIoutcome = "Stoppage_DM"
FRE13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
FRE13_SDMg2 <- data.frame(FRE13_SDM)
FRE13_SDMg2 <- FRE13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_SDMg2$player1
player2vector <- FRE13_SDMg2$player2
FRE13_SDMg3 <- FRE13_SDMg2
FRE13_SDMg3$p1inp2vec <- is.element(FRE13_SDMg3$player1, player2vector)
FRE13_SDMg3$p2inp1vec <- is.element(FRE13_SDMg3$player2, player1vector)
addPlayer1 <- FRE13_SDMg3[ which(FRE13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_SDMg3[ which(FRE13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_SDMg2 <- rbind(FRE13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
FRE13_SDMft <- ftable(FRE13_SDMg2$player1, FRE13_SDMg2$player2)
FRE13_SDMft2 <- as.matrix(FRE13_SDMft)
numRows <- nrow(FRE13_SDMft2)
numCols <- ncol(FRE13_SDMft2)
FRE13_SDMft3 <- FRE13_SDMft2[c(2:numRows) , c(2:numCols)]
FRE13_SDMTable <- graph.adjacency(FRE13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(FRE13_SDMTable, vertex.label = V(FRE13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
FRE13_SDM.clusterCoef <- transitivity(FRE13_SDMTable, type="global") #cluster coefficient
FRE13_SDM.degreeCent <- centralization.degree(FRE13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_SDMftn <- as.network.matrix(FRE13_SDMft)
FRE13_SDM.netDensity <- network.density(FRE13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_SDM.entropy <- entropy(FRE13_SDMft) #entropy
FRE13_SDM.netMx <- cbind(FRE13_SDM.netMx, FRE13_SDM.clusterCoef, FRE13_SDM.degreeCent$centralization,
FRE13_SDM.netDensity, FRE13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Turnover_DM"
FRE13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
FRE13_TDMg2 <- data.frame(FRE13_TDM)
FRE13_TDMg2 <- FRE13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_TDMg2$player1
player2vector <- FRE13_TDMg2$player2
FRE13_TDMg3 <- FRE13_TDMg2
FRE13_TDMg3$p1inp2vec <- is.element(FRE13_TDMg3$player1, player2vector)
FRE13_TDMg3$p2inp1vec <- is.element(FRE13_TDMg3$player2, player1vector)
addPlayer1 <- FRE13_TDMg3[ which(FRE13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_TDMg3[ which(FRE13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_TDMg2 <- rbind(FRE13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
FRE13_TDMft <- ftable(FRE13_TDMg2$player1, FRE13_TDMg2$player2)
FRE13_TDMft2 <- as.matrix(FRE13_TDMft)
numRows <- nrow(FRE13_TDMft2)
numCols <- ncol(FRE13_TDMft2)
FRE13_TDMft3 <- FRE13_TDMft2[c(2:numRows) , c(2:numCols)]
FRE13_TDMTable <- graph.adjacency(FRE13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(FRE13_TDMTable, vertex.label = V(FRE13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
FRE13_TDM.clusterCoef <- transitivity(FRE13_TDMTable, type="global") #cluster coefficient
FRE13_TDM.degreeCent <- centralization.degree(FRE13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_TDMftn <- as.network.matrix(FRE13_TDMft)
FRE13_TDM.netDensity <- network.density(FRE13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_TDM.entropy <- entropy(FRE13_TDMft) #entropy
FRE13_TDM.netMx <- cbind(FRE13_TDM.netMx, FRE13_TDM.clusterCoef, FRE13_TDM.degreeCent$centralization,
FRE13_TDM.netDensity, FRE13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Stoppage_D"
FRE13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
FRE13_SDg2 <- data.frame(FRE13_SD)
FRE13_SDg2 <- FRE13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_SDg2$player1
player2vector <- FRE13_SDg2$player2
FRE13_SDg3 <- FRE13_SDg2
FRE13_SDg3$p1inp2vec <- is.element(FRE13_SDg3$player1, player2vector)
FRE13_SDg3$p2inp1vec <- is.element(FRE13_SDg3$player2, player1vector)
addPlayer1 <- FRE13_SDg3[ which(FRE13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_SDg3[ which(FRE13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_SDg2 <- rbind(FRE13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
FRE13_SDft <- ftable(FRE13_SDg2$player1, FRE13_SDg2$player2)
FRE13_SDft2 <- as.matrix(FRE13_SDft)
numRows <- nrow(FRE13_SDft2)
numCols <- ncol(FRE13_SDft2)
FRE13_SDft3 <- FRE13_SDft2[c(2:numRows) , c(2:numCols)]
FRE13_SDTable <- graph.adjacency(FRE13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(FRE13_SDTable, vertex.label = V(FRE13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
FRE13_SD.clusterCoef <- transitivity(FRE13_SDTable, type="global") #cluster coefficient
FRE13_SD.degreeCent <- centralization.degree(FRE13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_SDftn <- as.network.matrix(FRE13_SDft)
FRE13_SD.netDensity <- network.density(FRE13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_SD.entropy <- entropy(FRE13_SDft) #entropy
FRE13_SD.netMx <- cbind(FRE13_SD.netMx, FRE13_SD.clusterCoef, FRE13_SD.degreeCent$centralization,
FRE13_SD.netDensity, FRE13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Turnover_D"
FRE13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
FRE13_TDg2 <- data.frame(FRE13_TD)
FRE13_TDg2 <- FRE13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_TDg2$player1
player2vector <- FRE13_TDg2$player2
FRE13_TDg3 <- FRE13_TDg2
FRE13_TDg3$p1inp2vec <- is.element(FRE13_TDg3$player1, player2vector)
FRE13_TDg3$p2inp1vec <- is.element(FRE13_TDg3$player2, player1vector)
addPlayer1 <- FRE13_TDg3[ which(FRE13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_TDg3[ which(FRE13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_TDg2 <- rbind(FRE13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
FRE13_TDft <- ftable(FRE13_TDg2$player1, FRE13_TDg2$player2)
FRE13_TDft2 <- as.matrix(FRE13_TDft)
numRows <- nrow(FRE13_TDft2)
numCols <- ncol(FRE13_TDft2)
FRE13_TDft3 <- FRE13_TDft2[c(2:numRows) , c(2:numCols)]
FRE13_TDTable <- graph.adjacency(FRE13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(FRE13_TDTable, vertex.label = V(FRE13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
FRE13_TD.clusterCoef <- transitivity(FRE13_TDTable, type="global") #cluster coefficient
FRE13_TD.degreeCent <- centralization.degree(FRE13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_TDftn <- as.network.matrix(FRE13_TDft)
FRE13_TD.netDensity <- network.density(FRE13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_TD.entropy <- entropy(FRE13_TDft) #entropy
FRE13_TD.netMx <- cbind(FRE13_TD.netMx, FRE13_TD.clusterCoef, FRE13_TD.degreeCent$centralization,
FRE13_TD.netDensity, FRE13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "End of Qtr_DM"
FRE13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
FRE13_QTg2 <- data.frame(FRE13_QT)
FRE13_QTg2 <- FRE13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_QTg2$player1
player2vector <- FRE13_QTg2$player2
FRE13_QTg3 <- FRE13_QTg2
FRE13_QTg3$p1inp2vec <- is.element(FRE13_QTg3$player1, player2vector)
FRE13_QTg3$p2inp1vec <- is.element(FRE13_QTg3$player2, player1vector)
addPlayer1 <- FRE13_QTg3[ which(FRE13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_QTg3[ which(FRE13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_QTg2 <- rbind(FRE13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
FRE13_QTft <- ftable(FRE13_QTg2$player1, FRE13_QTg2$player2)
FRE13_QTft2 <- as.matrix(FRE13_QTft)
numRows <- nrow(FRE13_QTft2)
numCols <- ncol(FRE13_QTft2)
FRE13_QTft3 <- FRE13_QTft2[c(2:numRows) , c(2:numCols)]
FRE13_QTTable <- graph.adjacency(FRE13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(FRE13_QTTable, vertex.label = V(FRE13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
FRE13_QT.clusterCoef <- transitivity(FRE13_QTTable, type="global") #cluster coefficient
FRE13_QT.degreeCent <- centralization.degree(FRE13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_QTftn <- as.network.matrix(FRE13_QTft)
FRE13_QT.netDensity <- network.density(FRE13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_QT.entropy <- entropy(FRE13_QTft) #entropy
FRE13_QT.netMx <- cbind(FRE13_QT.netMx, FRE13_QT.clusterCoef, FRE13_QT.degreeCent$centralization,
FRE13_QT.netDensity, FRE13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_QT.netMx) <- varnames
#############################################################################
#GOLD COAST
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "GCFC"
KIoutcome = "Goal_F"
GCFC13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
GCFC13_Gg2 <- data.frame(GCFC13_G)
GCFC13_Gg2 <- GCFC13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_Gg2$player1
player2vector <- GCFC13_Gg2$player2
GCFC13_Gg3 <- GCFC13_Gg2
GCFC13_Gg3$p1inp2vec <- is.element(GCFC13_Gg3$player1, player2vector)
GCFC13_Gg3$p2inp1vec <- is.element(GCFC13_Gg3$player2, player1vector)
addPlayer1 <- GCFC13_Gg3[ which(GCFC13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_Gg3[ which(GCFC13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_Gg2 <- rbind(GCFC13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
GCFC13_Gft <- ftable(GCFC13_Gg2$player1, GCFC13_Gg2$player2)
GCFC13_Gft2 <- as.matrix(GCFC13_Gft)
numRows <- nrow(GCFC13_Gft2)
numCols <- ncol(GCFC13_Gft2)
GCFC13_Gft3 <- GCFC13_Gft2[c(2:numRows) , c(2:numCols)]
GCFC13_GTable <- graph.adjacency(GCFC13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(GCFC13_GTable, vertex.label = V(GCFC13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
GCFC13_G.clusterCoef <- transitivity(GCFC13_GTable, type="global") #cluster coefficient
GCFC13_G.degreeCent <- centralization.degree(GCFC13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_Gftn <- as.network.matrix(GCFC13_Gft)
GCFC13_G.netDensity <- network.density(GCFC13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_G.entropy <- entropy(GCFC13_Gft) #entropy
GCFC13_G.netMx <- cbind(GCFC13_G.netMx, GCFC13_G.clusterCoef, GCFC13_G.degreeCent$centralization,
GCFC13_G.netDensity, GCFC13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
round = 13
teamName = "GCFC"
KIoutcome = "Behind_F"
GCFC13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
GCFC13_Bg2 <- data.frame(GCFC13_B)
GCFC13_Bg2 <- GCFC13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_Bg2$player1
player2vector <- GCFC13_Bg2$player2
GCFC13_Bg3 <- GCFC13_Bg2
GCFC13_Bg3$p1inp2vec <- is.element(GCFC13_Bg3$player1, player2vector)
GCFC13_Bg3$p2inp1vec <- is.element(GCFC13_Bg3$player2, player1vector)
addPlayer1 <- GCFC13_Bg3[ which(GCFC13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_Bg3[ which(GCFC13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_Bg2 <- rbind(GCFC13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
GCFC13_Bft <- ftable(GCFC13_Bg2$player1, GCFC13_Bg2$player2)
GCFC13_Bft2 <- as.matrix(GCFC13_Bft)
numRows <- nrow(GCFC13_Bft2)
numCols <- ncol(GCFC13_Bft2)
GCFC13_Bft3 <- GCFC13_Bft2[c(2:numRows) , c(2:numCols)]
GCFC13_BTable <- graph.adjacency(GCFC13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(GCFC13_BTable, vertex.label = V(GCFC13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
GCFC13_B.clusterCoef <- transitivity(GCFC13_BTable, type="global") #cluster coefficient
GCFC13_B.degreeCent <- centralization.degree(GCFC13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_Bftn <- as.network.matrix(GCFC13_Bft)
GCFC13_B.netDensity <- network.density(GCFC13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_B.entropy <- entropy(GCFC13_Bft) #entropy
GCFC13_B.netMx <- cbind(GCFC13_B.netMx, GCFC13_B.clusterCoef, GCFC13_B.degreeCent$centralization,
GCFC13_B.netDensity, GCFC13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "GCFC"
KIoutcome = "Stoppage_F"
GCFC13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
GCFC13_SFg2 <- data.frame(GCFC13_SF)
GCFC13_SFg2 <- GCFC13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_SFg2$player1
player2vector <- GCFC13_SFg2$player2
GCFC13_SFg3 <- GCFC13_SFg2
GCFC13_SFg3$p1inp2vec <- is.element(GCFC13_SFg3$player1, player2vector)
GCFC13_SFg3$p2inp1vec <- is.element(GCFC13_SFg3$player2, player1vector)
addPlayer1 <- GCFC13_SFg3[ which(GCFC13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
varnames <- c("player1", "player2", "weight")
colnames(addPlayer1) <- varnames
GCFC13_SFg2 <- rbind(GCFC13_SFg2, addPlayer1)
#ROUND 13, FWD Stoppage graph using weighted edges
GCFC13_SFft <- ftable(GCFC13_SFg2$player1, GCFC13_SFg2$player2)
GCFC13_SFft2 <- as.matrix(GCFC13_SFft)
numRows <- nrow(GCFC13_SFft2)
numCols <- ncol(GCFC13_SFft2)
GCFC13_SFft3 <- GCFC13_SFft2[c(2:numRows) , c(1:numCols)]
GCFC13_SFTable <- graph.adjacency(GCFC13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(GCFC13_SFTable, vertex.label = V(GCFC13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
GCFC13_SF.clusterCoef <- transitivity(GCFC13_SFTable, type="global") #cluster coefficient
GCFC13_SF.degreeCent <- centralization.degree(GCFC13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_SFftn <- as.network.matrix(GCFC13_SFft)
GCFC13_SF.netDensity <- network.density(GCFC13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_SF.entropy <- entropy(GCFC13_SFft) #entropy
GCFC13_SF.netMx <- cbind(GCFC13_SF.netMx, GCFC13_SF.clusterCoef, GCFC13_SF.degreeCent$centralization,
GCFC13_SF.netDensity, GCFC13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "GCFC"
KIoutcome = "Turnover_F"
GCFC13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
GCFC13_TFg2 <- data.frame(GCFC13_TF)
GCFC13_TFg2 <- GCFC13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_TFg2$player1
player2vector <- GCFC13_TFg2$player2
GCFC13_TFg3 <- GCFC13_TFg2
GCFC13_TFg3$p1inp2vec <- is.element(GCFC13_TFg3$player1, player2vector)
GCFC13_TFg3$p2inp1vec <- is.element(GCFC13_TFg3$player2, player1vector)
addPlayer1 <- GCFC13_TFg3[ which(GCFC13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_TFg3[ which(GCFC13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_TFg2 <- rbind(GCFC13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
GCFC13_TFft <- ftable(GCFC13_TFg2$player1, GCFC13_TFg2$player2)
GCFC13_TFft2 <- as.matrix(GCFC13_TFft)
numRows <- nrow(GCFC13_TFft2)
numCols <- ncol(GCFC13_TFft2)
GCFC13_TFft3 <- GCFC13_TFft2[c(2:numRows) , c(2:numCols)]
GCFC13_TFTable <- graph.adjacency(GCFC13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(GCFC13_TFTable, vertex.label = V(GCFC13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
GCFC13_TF.clusterCoef <- transitivity(GCFC13_TFTable, type="global") #cluster coefficient
GCFC13_TF.degreeCent <- centralization.degree(GCFC13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_TFftn <- as.network.matrix(GCFC13_TFft)
GCFC13_TF.netDensity <- network.density(GCFC13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_TF.entropy <- entropy(GCFC13_TFft) #entropy
GCFC13_TF.netMx <- cbind(GCFC13_TF.netMx, GCFC13_TF.clusterCoef, GCFC13_TF.degreeCent$centralization,
GCFC13_TF.netDensity, GCFC13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
#NA
round = 13
teamName = "GCFC"
KIoutcome = "Stoppage_AM"
GCFC13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
GCFC13_SAMg2 <- data.frame(GCFC13_SAM)
GCFC13_SAMg2 <- GCFC13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_SAMg2$player1
player2vector <- GCFC13_SAMg2$player2
GCFC13_SAMg3 <- GCFC13_SAMg2
GCFC13_SAMg3$p1inp2vec <- is.element(GCFC13_SAMg3$player1, player2vector)
GCFC13_SAMg3$p2inp1vec <- is.element(GCFC13_SAMg3$player2, player1vector)
addPlayer1 <- GCFC13_SAMg3[ which(GCFC13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_SAMg3[ which(GCFC13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_SAMg2 <- rbind(GCFC13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
GCFC13_SAMft <- ftable(GCFC13_SAMg2$player1, GCFC13_SAMg2$player2)
GCFC13_SAMft2 <- as.matrix(GCFC13_SAMft)
numRows <- nrow(GCFC13_SAMft2)
numCols <- ncol(GCFC13_SAMft2)
GCFC13_SAMft3 <- GCFC13_SAMft2[c(2:numRows) , c(2:numCols)]
GCFC13_SAMTable <- graph.adjacency(GCFC13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(GCFC13_SAMTable, vertex.label = V(GCFC13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
GCFC13_SAM.clusterCoef <- transitivity(GCFC13_SAMTable, type="global") #cluster coefficient
GCFC13_SAM.degreeCent <- centralization.degree(GCFC13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_SAMftn <- as.network.matrix(GCFC13_SAMft)
GCFC13_SAM.netDensity <- network.density(GCFC13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_SAM.entropy <- entropy(GCFC13_SAMft) #entropy
GCFC13_SAM.netMx <- cbind(GCFC13_SAM.netMx, GCFC13_SAM.clusterCoef, GCFC13_SAM.degreeCent$centralization,
GCFC13_SAM.netDensity, GCFC13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "GCFC"
KIoutcome = "Turnover_AM"
GCFC13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
GCFC13_TAMg2 <- data.frame(GCFC13_TAM)
GCFC13_TAMg2 <- GCFC13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_TAMg2$player1
player2vector <- GCFC13_TAMg2$player2
GCFC13_TAMg3 <- GCFC13_TAMg2
GCFC13_TAMg3$p1inp2vec <- is.element(GCFC13_TAMg3$player1, player2vector)
GCFC13_TAMg3$p2inp1vec <- is.element(GCFC13_TAMg3$player2, player1vector)
addPlayer1 <- GCFC13_TAMg3[ which(GCFC13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_TAMg3[ which(GCFC13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_TAMg2 <- rbind(GCFC13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
GCFC13_TAMft <- ftable(GCFC13_TAMg2$player1, GCFC13_TAMg2$player2)
GCFC13_TAMft2 <- as.matrix(GCFC13_TAMft)
numRows <- nrow(GCFC13_TAMft2)
numCols <- ncol(GCFC13_TAMft2)
GCFC13_TAMft3 <- GCFC13_TAMft2[c(2:numRows) , c(2:numCols)]
GCFC13_TAMTable <- graph.adjacency(GCFC13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(GCFC13_TAMTable, vertex.label = V(GCFC13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
GCFC13_TAM.clusterCoef <- transitivity(GCFC13_TAMTable, type="global") #cluster coefficient
GCFC13_TAM.degreeCent <- centralization.degree(GCFC13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_TAMftn <- as.network.matrix(GCFC13_TAMft)
GCFC13_TAM.netDensity <- network.density(GCFC13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_TAM.entropy <- entropy(GCFC13_TAMft) #entropy
GCFC13_TAM.netMx <- cbind(GCFC13_TAM.netMx, GCFC13_TAM.clusterCoef, GCFC13_TAM.degreeCent$centralization,
GCFC13_TAM.netDensity, GCFC13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "GCFC"
KIoutcome = "Stoppage_DM"
GCFC13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
GCFC13_SDMg2 <- data.frame(GCFC13_SDM)
GCFC13_SDMg2 <- GCFC13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_SDMg2$player1
player2vector <- GCFC13_SDMg2$player2
GCFC13_SDMg3 <- GCFC13_SDMg2
GCFC13_SDMg3$p1inp2vec <- is.element(GCFC13_SDMg3$player1, player2vector)
GCFC13_SDMg3$p2inp1vec <- is.element(GCFC13_SDMg3$player2, player1vector)
addPlayer1 <- GCFC13_SDMg3[ which(GCFC13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_SDMg3[ which(GCFC13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_SDMg2 <- rbind(GCFC13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
GCFC13_SDMft <- ftable(GCFC13_SDMg2$player1, GCFC13_SDMg2$player2)
GCFC13_SDMft2 <- as.matrix(GCFC13_SDMft)
numRows <- nrow(GCFC13_SDMft2)
numCols <- ncol(GCFC13_SDMft2)
GCFC13_SDMft3 <- GCFC13_SDMft2[c(2:numRows) , c(2:numCols)]
GCFC13_SDMTable <- graph.adjacency(GCFC13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(GCFC13_SDMTable, vertex.label = V(GCFC13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
GCFC13_SDM.clusterCoef <- transitivity(GCFC13_SDMTable, type="global") #cluster coefficient
GCFC13_SDM.degreeCent <- centralization.degree(GCFC13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_SDMftn <- as.network.matrix(GCFC13_SDMft)
GCFC13_SDM.netDensity <- network.density(GCFC13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_SDM.entropy <- entropy(GCFC13_SDMft) #entropy
GCFC13_SDM.netMx <- cbind(GCFC13_SDM.netMx, GCFC13_SDM.clusterCoef, GCFC13_SDM.degreeCent$centralization,
GCFC13_SDM.netDensity, GCFC13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "GCFC"
KIoutcome = "Turnover_DM"
GCFC13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
GCFC13_TDMg2 <- data.frame(GCFC13_TDM)
GCFC13_TDMg2 <- GCFC13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_TDMg2$player1
player2vector <- GCFC13_TDMg2$player2
GCFC13_TDMg3 <- GCFC13_TDMg2
GCFC13_TDMg3$p1inp2vec <- is.element(GCFC13_TDMg3$player1, player2vector)
GCFC13_TDMg3$p2inp1vec <- is.element(GCFC13_TDMg3$player2, player1vector)
addPlayer1 <- GCFC13_TDMg3[ which(GCFC13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_TDMg3[ which(GCFC13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_TDMg2 <- rbind(GCFC13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
GCFC13_TDMft <- ftable(GCFC13_TDMg2$player1, GCFC13_TDMg2$player2)
GCFC13_TDMft2 <- as.matrix(GCFC13_TDMft)
numRows <- nrow(GCFC13_TDMft2)
numCols <- ncol(GCFC13_TDMft2)
GCFC13_TDMft3 <- GCFC13_TDMft2[c(2:numRows) , c(2:numCols)]
GCFC13_TDMTable <- graph.adjacency(GCFC13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(GCFC13_TDMTable, vertex.label = V(GCFC13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
GCFC13_TDM.clusterCoef <- transitivity(GCFC13_TDMTable, type="global") #cluster coefficient
GCFC13_TDM.degreeCent <- centralization.degree(GCFC13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_TDMftn <- as.network.matrix(GCFC13_TDMft)
GCFC13_TDM.netDensity <- network.density(GCFC13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_TDM.entropy <- entropy(GCFC13_TDMft) #entropy
GCFC13_TDM.netMx <- cbind(GCFC13_TDM.netMx, GCFC13_TDM.clusterCoef, GCFC13_TDM.degreeCent$centralization,
GCFC13_TDM.netDensity, GCFC13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "GCFC"
KIoutcome = "Stoppage_D"
GCFC13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
GCFC13_SDg2 <- data.frame(GCFC13_SD)
GCFC13_SDg2 <- GCFC13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_SDg2$player1
player2vector <- GCFC13_SDg2$player2
GCFC13_SDg3 <- GCFC13_SDg2
GCFC13_SDg3$p1inp2vec <- is.element(GCFC13_SDg3$player1, player2vector)
GCFC13_SDg3$p2inp1vec <- is.element(GCFC13_SDg3$player2, player1vector)
addPlayer1 <- GCFC13_SDg3[ which(GCFC13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_SDg3[ which(GCFC13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_SDg2 <- rbind(GCFC13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
GCFC13_SDft <- ftable(GCFC13_SDg2$player1, GCFC13_SDg2$player2)
GCFC13_SDft2 <- as.matrix(GCFC13_SDft)
numRows <- nrow(GCFC13_SDft2)
numCols <- ncol(GCFC13_SDft2)
GCFC13_SDft3 <- GCFC13_SDft2[c(2:numRows) , c(2:numCols)]
GCFC13_SDTable <- graph.adjacency(GCFC13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(GCFC13_SDTable, vertex.label = V(GCFC13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
GCFC13_SD.clusterCoef <- transitivity(GCFC13_SDTable, type="global") #cluster coefficient
GCFC13_SD.degreeCent <- centralization.degree(GCFC13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_SDftn <- as.network.matrix(GCFC13_SDft)
GCFC13_SD.netDensity <- network.density(GCFC13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_SD.entropy <- entropy(GCFC13_SDft) #entropy
GCFC13_SD.netMx <- cbind(GCFC13_SD.netMx, GCFC13_SD.clusterCoef, GCFC13_SD.degreeCent$centralization,
GCFC13_SD.netDensity, GCFC13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "GCFC"
KIoutcome = "Turnover_D"
GCFC13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
GCFC13_TDg2 <- data.frame(GCFC13_TD)
GCFC13_TDg2 <- GCFC13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_TDg2$player1
player2vector <- GCFC13_TDg2$player2
GCFC13_TDg3 <- GCFC13_TDg2
GCFC13_TDg3$p1inp2vec <- is.element(GCFC13_TDg3$player1, player2vector)
GCFC13_TDg3$p2inp1vec <- is.element(GCFC13_TDg3$player2, player1vector)
addPlayer1 <- GCFC13_TDg3[ which(GCFC13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_TDg3[ which(GCFC13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_TDg2 <- rbind(GCFC13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
GCFC13_TDft <- ftable(GCFC13_TDg2$player1, GCFC13_TDg2$player2)
GCFC13_TDft2 <- as.matrix(GCFC13_TDft)
numRows <- nrow(GCFC13_TDft2)
numCols <- ncol(GCFC13_TDft2)
GCFC13_TDft3 <- GCFC13_TDft2[c(2:numRows) , c(2:numCols)]
GCFC13_TDTable <- graph.adjacency(GCFC13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(GCFC13_TDTable, vertex.label = V(GCFC13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
GCFC13_TD.clusterCoef <- transitivity(GCFC13_TDTable, type="global") #cluster coefficient
GCFC13_TD.degreeCent <- centralization.degree(GCFC13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_TDftn <- as.network.matrix(GCFC13_TDft)
GCFC13_TD.netDensity <- network.density(GCFC13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_TD.entropy <- entropy(GCFC13_TDft) #entropy
GCFC13_TD.netMx <- cbind(GCFC13_TD.netMx, GCFC13_TD.clusterCoef, GCFC13_TD.degreeCent$centralization,
GCFC13_TD.netDensity, GCFC13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "GCFC"
KIoutcome = "End of Qtr_DM"
GCFC13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
GCFC13_QTg2 <- data.frame(GCFC13_QT)
GCFC13_QTg2 <- GCFC13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_QTg2$player1
player2vector <- GCFC13_QTg2$player2
GCFC13_QTg3 <- GCFC13_QTg2
GCFC13_QTg3$p1inp2vec <- is.element(GCFC13_QTg3$player1, player2vector)
GCFC13_QTg3$p2inp1vec <- is.element(GCFC13_QTg3$player2, player1vector)
addPlayer1 <- GCFC13_QTg3[ which(GCFC13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_QTg3[ which(GCFC13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_QTg2 <- rbind(GCFC13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
GCFC13_QTft <- ftable(GCFC13_QTg2$player1, GCFC13_QTg2$player2)
GCFC13_QTft2 <- as.matrix(GCFC13_QTft)
numRows <- nrow(GCFC13_QTft2)
numCols <- ncol(GCFC13_QTft2)
GCFC13_QTft3 <- GCFC13_QTft2[c(2:numRows) , c(2:numCols)]
GCFC13_QTTable <- graph.adjacency(GCFC13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(GCFC13_QTTable, vertex.label = V(GCFC13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
GCFC13_QT.clusterCoef <- transitivity(GCFC13_QTTable, type="global") #cluster coefficient
GCFC13_QT.degreeCent <- centralization.degree(GCFC13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_QTftn <- as.network.matrix(GCFC13_QTft)
GCFC13_QT.netDensity <- network.density(GCFC13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_QT.entropy <- entropy(GCFC13_QTft) #entropy
GCFC13_QT.netMx <- cbind(GCFC13_QT.netMx, GCFC13_QT.clusterCoef, GCFC13_QT.degreeCent$centralization,
GCFC13_QT.netDensity, GCFC13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_QT.netMx) <- varnames
#############################################################################
#HAWTHORN
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
round = 13
teamName = "HAW"
KIoutcome = "Goal_F"
HAW13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
HAW13_Gg2 <- data.frame(HAW13_G)
HAW13_Gg2 <- HAW13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_Gg2$player1
player2vector <- HAW13_Gg2$player2
HAW13_Gg3 <- HAW13_Gg2
HAW13_Gg3$p1inp2vec <- is.element(HAW13_Gg3$player1, player2vector)
HAW13_Gg3$p2inp1vec <- is.element(HAW13_Gg3$player2, player1vector)
addPlayer1 <- HAW13_Gg3[ which(HAW13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_Gg3[ which(HAW13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_Gg2 <- rbind(HAW13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
HAW13_Gft <- ftable(HAW13_Gg2$player1, HAW13_Gg2$player2)
HAW13_Gft2 <- as.matrix(HAW13_Gft)
numRows <- nrow(HAW13_Gft2)
numCols <- ncol(HAW13_Gft2)
HAW13_Gft3 <- HAW13_Gft2[c(2:numRows) , c(2:numCols)]
HAW13_GTable <- graph.adjacency(HAW13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(HAW13_GTable, vertex.label = V(HAW13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
HAW13_G.clusterCoef <- transitivity(HAW13_GTable, type="global") #cluster coefficient
HAW13_G.degreeCent <- centralization.degree(HAW13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_Gftn <- as.network.matrix(HAW13_Gft)
HAW13_G.netDensity <- network.density(HAW13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_G.entropy <- entropy(HAW13_Gft) #entropy
HAW13_G.netMx <- cbind(HAW13_G.netMx, HAW13_G.clusterCoef, HAW13_G.degreeCent$centralization,
HAW13_G.netDensity, HAW13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
#NA
round = 13
teamName = "HAW"
KIoutcome = "Behind_F"
HAW13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
HAW13_Bg2 <- data.frame(HAW13_B)
HAW13_Bg2 <- HAW13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_Bg2$player1
player2vector <- HAW13_Bg2$player2
HAW13_Bg3 <- HAW13_Bg2
HAW13_Bg3$p1inp2vec <- is.element(HAW13_Bg3$player1, player2vector)
HAW13_Bg3$p2inp1vec <- is.element(HAW13_Bg3$player2, player1vector)
addPlayer1 <- HAW13_Bg3[ which(HAW13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
varnames <- c("player1", "player2", "weight")
colnames(addPlayer1) <- varnames
HAW13_Bg2 <- rbind(HAW13_Bg2, addPlayer1)
#ROUND 13, Behind graph using weighted edges
HAW13_Bft <- ftable(HAW13_Bg2$player1, HAW13_Bg2$player2)
HAW13_Bft2 <- as.matrix(HAW13_Bft)
numRows <- nrow(HAW13_Bft2)
numCols <- ncol(HAW13_Bft2)
HAW13_Bft3 <- HAW13_Bft2[c(2:numRows) , c(1:numCols)]
HAW13_BTable <- graph.adjacency(HAW13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(HAW13_BTable, vertex.label = V(HAW13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
HAW13_B.clusterCoef <- transitivity(HAW13_BTable, type="global") #cluster coefficient
HAW13_B.degreeCent <- centralization.degree(HAW13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_Bftn <- as.network.matrix(HAW13_Bft)
HAW13_B.netDensity <- network.density(HAW13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_B.entropy <- entropy(HAW13_Bft) #entropy
HAW13_B.netMx <- cbind(HAW13_B.netMx, HAW13_B.clusterCoef, HAW13_B.degreeCent$centralization,
HAW13_B.netDensity, HAW13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "HAW"
KIoutcome = "Stoppage_F"
HAW13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
HAW13_SFg2 <- data.frame(HAW13_SF)
HAW13_SFg2 <- HAW13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_SFg2$player1
player2vector <- HAW13_SFg2$player2
HAW13_SFg3 <- HAW13_SFg2
HAW13_SFg3$p1inp2vec <- is.element(HAW13_SFg3$player1, player2vector)
HAW13_SFg3$p2inp1vec <- is.element(HAW13_SFg3$player2, player1vector)
addPlayer1 <- HAW13_SFg3[ which(HAW13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_SFg3[ which(HAW13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_SFg2 <- rbind(HAW13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
HAW13_SFft <- ftable(HAW13_SFg2$player1, HAW13_SFg2$player2)
HAW13_SFft2 <- as.matrix(HAW13_SFft)
numRows <- nrow(HAW13_SFft2)
numCols <- ncol(HAW13_SFft2)
HAW13_SFft3 <- HAW13_SFft2[c(2:numRows) , c(2:numCols)]
HAW13_SFTable <- graph.adjacency(HAW13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(HAW13_SFTable, vertex.label = V(HAW13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
HAW13_SF.clusterCoef <- transitivity(HAW13_SFTable, type="global") #cluster coefficient
HAW13_SF.degreeCent <- centralization.degree(HAW13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_SFftn <- as.network.matrix(HAW13_SFft)
HAW13_SF.netDensity <- network.density(HAW13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_SF.entropy <- entropy(HAW13_SFft) #entropy
HAW13_SF.netMx <- cbind(HAW13_SF.netMx, HAW13_SF.clusterCoef, HAW13_SF.degreeCent$centralization,
HAW13_SF.netDensity, HAW13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "HAW"
KIoutcome = "Turnover_F"
HAW13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
HAW13_TFg2 <- data.frame(HAW13_TF)
HAW13_TFg2 <- HAW13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_TFg2$player1
player2vector <- HAW13_TFg2$player2
HAW13_TFg3 <- HAW13_TFg2
HAW13_TFg3$p1inp2vec <- is.element(HAW13_TFg3$player1, player2vector)
HAW13_TFg3$p2inp1vec <- is.element(HAW13_TFg3$player2, player1vector)
addPlayer1 <- HAW13_TFg3[ which(HAW13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_TFg3[ which(HAW13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_TFg2 <- rbind(HAW13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
HAW13_TFft <- ftable(HAW13_TFg2$player1, HAW13_TFg2$player2)
HAW13_TFft2 <- as.matrix(HAW13_TFft)
numRows <- nrow(HAW13_TFft2)
numCols <- ncol(HAW13_TFft2)
HAW13_TFft3 <- HAW13_TFft2[c(2:numRows) , c(2:numCols)]
HAW13_TFTable <- graph.adjacency(HAW13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(HAW13_TFTable, vertex.label = V(HAW13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
HAW13_TF.clusterCoef <- transitivity(HAW13_TFTable, type="global") #cluster coefficient
HAW13_TF.degreeCent <- centralization.degree(HAW13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_TFftn <- as.network.matrix(HAW13_TFft)
HAW13_TF.netDensity <- network.density(HAW13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_TF.entropy <- entropy(HAW13_TFft) #entropy
HAW13_TF.netMx <- cbind(HAW13_TF.netMx, HAW13_TF.clusterCoef, HAW13_TF.degreeCent$centralization,
HAW13_TF.netDensity, HAW13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
round = 13
teamName = "HAW"
KIoutcome = "Stoppage_AM"
HAW13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
HAW13_SAMg2 <- data.frame(HAW13_SAM)
HAW13_SAMg2 <- HAW13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_SAMg2$player1
player2vector <- HAW13_SAMg2$player2
HAW13_SAMg3 <- HAW13_SAMg2
HAW13_SAMg3$p1inp2vec <- is.element(HAW13_SAMg3$player1, player2vector)
HAW13_SAMg3$p2inp1vec <- is.element(HAW13_SAMg3$player2, player1vector)
addPlayer1 <- HAW13_SAMg3[ which(HAW13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_SAMg3[ which(HAW13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_SAMg2 <- rbind(HAW13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
HAW13_SAMft <- ftable(HAW13_SAMg2$player1, HAW13_SAMg2$player2)
HAW13_SAMft2 <- as.matrix(HAW13_SAMft)
numRows <- nrow(HAW13_SAMft2)
numCols <- ncol(HAW13_SAMft2)
HAW13_SAMft3 <- HAW13_SAMft2[c(2:numRows) , c(2:numCols)]
HAW13_SAMTable <- graph.adjacency(HAW13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(HAW13_SAMTable, vertex.label = V(HAW13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
HAW13_SAM.clusterCoef <- transitivity(HAW13_SAMTable, type="global") #cluster coefficient
HAW13_SAM.degreeCent <- centralization.degree(HAW13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_SAMftn <- as.network.matrix(HAW13_SAMft)
HAW13_SAM.netDensity <- network.density(HAW13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_SAM.entropy <- entropy(HAW13_SAMft) #entropy
HAW13_SAM.netMx <- cbind(HAW13_SAM.netMx, HAW13_SAM.clusterCoef, HAW13_SAM.degreeCent$centralization,
HAW13_SAM.netDensity, HAW13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
#NA
round = 13
teamName = "HAW"
KIoutcome = "Turnover_AM"
HAW13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
HAW13_TAMg2 <- data.frame(HAW13_TAM)
HAW13_TAMg2 <- HAW13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_TAMg2$player1
player2vector <- HAW13_TAMg2$player2
HAW13_TAMg3 <- HAW13_TAMg2
HAW13_TAMg3$p1inp2vec <- is.element(HAW13_TAMg3$player1, player2vector)
HAW13_TAMg3$p2inp1vec <- is.element(HAW13_TAMg3$player2, player1vector)
addPlayer1 <- HAW13_TAMg3[ which(HAW13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_TAMg3[ which(HAW13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_TAMg2 <- rbind(HAW13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
HAW13_TAMft <- ftable(HAW13_TAMg2$player1, HAW13_TAMg2$player2)
HAW13_TAMft2 <- as.matrix(HAW13_TAMft)
numRows <- nrow(HAW13_TAMft2)
numCols <- ncol(HAW13_TAMft2)
HAW13_TAMft3 <- HAW13_TAMft2[c(2:numRows) , c(2:numCols)]
HAW13_TAMTable <- graph.adjacency(HAW13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(HAW13_TAMTable, vertex.label = V(HAW13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
HAW13_TAM.clusterCoef <- transitivity(HAW13_TAMTable, type="global") #cluster coefficient
HAW13_TAM.degreeCent <- centralization.degree(HAW13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_TAMftn <- as.network.matrix(HAW13_TAMft)
HAW13_TAM.netDensity <- network.density(HAW13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_TAM.entropy <- entropy(HAW13_TAMft) #entropy
HAW13_TAM.netMx <- cbind(HAW13_TAM.netMx, HAW13_TAM.clusterCoef, HAW13_TAM.degreeCent$centralization,
HAW13_TAM.netDensity, HAW13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
#NA
round = 13
teamName = "HAW"
KIoutcome = "Stoppage_DM"
HAW13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
HAW13_SDMg2 <- data.frame(HAW13_SDM)
HAW13_SDMg2 <- HAW13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_SDMg2$player1
player2vector <- HAW13_SDMg2$player2
HAW13_SDMg3 <- HAW13_SDMg2
HAW13_SDMg3$p1inp2vec <- is.element(HAW13_SDMg3$player1, player2vector)
HAW13_SDMg3$p2inp1vec <- is.element(HAW13_SDMg3$player2, player1vector)
addPlayer1 <- HAW13_SDMg3[ which(HAW13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_SDMg3[ which(HAW13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_SDMg2 <- rbind(HAW13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
HAW13_SDMft <- ftable(HAW13_SDMg2$player1, HAW13_SDMg2$player2)
HAW13_SDMft2 <- as.matrix(HAW13_SDMft)
numRows <- nrow(HAW13_SDMft2)
numCols <- ncol(HAW13_SDMft2)
HAW13_SDMft3 <- HAW13_SDMft2[c(2:numRows) , c(2:numCols)]
HAW13_SDMTable <- graph.adjacency(HAW13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(HAW13_SDMTable, vertex.label = V(HAW13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
HAW13_SDM.clusterCoef <- transitivity(HAW13_SDMTable, type="global") #cluster coefficient
HAW13_SDM.degreeCent <- centralization.degree(HAW13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_SDMftn <- as.network.matrix(HAW13_SDMft)
HAW13_SDM.netDensity <- network.density(HAW13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_SDM.entropy <- entropy(HAW13_SDMft) #entropy
HAW13_SDM.netMx <- cbind(HAW13_SDM.netMx, HAW13_SDM.clusterCoef, HAW13_SDM.degreeCent$centralization,
HAW13_SDM.netDensity, HAW13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "HAW"
KIoutcome = "Turnover_DM"
HAW13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
HAW13_TDMg2 <- data.frame(HAW13_TDM)
HAW13_TDMg2 <- HAW13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_TDMg2$player1
player2vector <- HAW13_TDMg2$player2
HAW13_TDMg3 <- HAW13_TDMg2
HAW13_TDMg3$p1inp2vec <- is.element(HAW13_TDMg3$player1, player2vector)
HAW13_TDMg3$p2inp1vec <- is.element(HAW13_TDMg3$player2, player1vector)
addPlayer1 <- HAW13_TDMg3[ which(HAW13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_TDMg3[ which(HAW13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_TDMg2 <- rbind(HAW13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
HAW13_TDMft <- ftable(HAW13_TDMg2$player1, HAW13_TDMg2$player2)
HAW13_TDMft2 <- as.matrix(HAW13_TDMft)
numRows <- nrow(HAW13_TDMft2)
numCols <- ncol(HAW13_TDMft2)
HAW13_TDMft3 <- HAW13_TDMft2[c(2:numRows) , c(2:numCols)]
HAW13_TDMTable <- graph.adjacency(HAW13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(HAW13_TDMTable, vertex.label = V(HAW13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
HAW13_TDM.clusterCoef <- transitivity(HAW13_TDMTable, type="global") #cluster coefficient
HAW13_TDM.degreeCent <- centralization.degree(HAW13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_TDMftn <- as.network.matrix(HAW13_TDMft)
HAW13_TDM.netDensity <- network.density(HAW13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_TDM.entropy <- entropy(HAW13_TDMft) #entropy
HAW13_TDM.netMx <- cbind(HAW13_TDM.netMx, HAW13_TDM.clusterCoef, HAW13_TDM.degreeCent$centralization,
HAW13_TDM.netDensity, HAW13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "HAW"
KIoutcome = "Stoppage_D"
HAW13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
HAW13_SDg2 <- data.frame(HAW13_SD)
HAW13_SDg2 <- HAW13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_SDg2$player1
player2vector <- HAW13_SDg2$player2
HAW13_SDg3 <- HAW13_SDg2
HAW13_SDg3$p1inp2vec <- is.element(HAW13_SDg3$player1, player2vector)
HAW13_SDg3$p2inp1vec <- is.element(HAW13_SDg3$player2, player1vector)
addPlayer1 <- HAW13_SDg3[ which(HAW13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_SDg3[ which(HAW13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_SDg2 <- rbind(HAW13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
HAW13_SDft <- ftable(HAW13_SDg2$player1, HAW13_SDg2$player2)
HAW13_SDft2 <- as.matrix(HAW13_SDft)
numRows <- nrow(HAW13_SDft2)
numCols <- ncol(HAW13_SDft2)
HAW13_SDft3 <- HAW13_SDft2[c(2:numRows) , c(2:numCols)]
HAW13_SDTable <- graph.adjacency(HAW13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(HAW13_SDTable, vertex.label = V(HAW13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
HAW13_SD.clusterCoef <- transitivity(HAW13_SDTable, type="global") #cluster coefficient
HAW13_SD.degreeCent <- centralization.degree(HAW13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_SDftn <- as.network.matrix(HAW13_SDft)
HAW13_SD.netDensity <- network.density(HAW13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_SD.entropy <- entropy(HAW13_SDft) #entropy
HAW13_SD.netMx <- cbind(HAW13_SD.netMx, HAW13_SD.clusterCoef, HAW13_SD.degreeCent$centralization,
HAW13_SD.netDensity, HAW13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "HAW"
KIoutcome = "Turnover_D"
HAW13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
HAW13_TDg2 <- data.frame(HAW13_TD)
HAW13_TDg2 <- HAW13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_TDg2$player1
player2vector <- HAW13_TDg2$player2
HAW13_TDg3 <- HAW13_TDg2
HAW13_TDg3$p1inp2vec <- is.element(HAW13_TDg3$player1, player2vector)
HAW13_TDg3$p2inp1vec <- is.element(HAW13_TDg3$player2, player1vector)
addPlayer1 <- HAW13_TDg3[ which(HAW13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_TDg3[ which(HAW13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_TDg2 <- rbind(HAW13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
HAW13_TDft <- ftable(HAW13_TDg2$player1, HAW13_TDg2$player2)
HAW13_TDft2 <- as.matrix(HAW13_TDft)
numRows <- nrow(HAW13_TDft2)
numCols <- ncol(HAW13_TDft2)
HAW13_TDft3 <- HAW13_TDft2[c(2:numRows) , c(2:numCols)]
HAW13_TDTable <- graph.adjacency(HAW13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(HAW13_TDTable, vertex.label = V(HAW13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
HAW13_TD.clusterCoef <- transitivity(HAW13_TDTable, type="global") #cluster coefficient
HAW13_TD.degreeCent <- centralization.degree(HAW13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_TDftn <- as.network.matrix(HAW13_TDft)
HAW13_TD.netDensity <- network.density(HAW13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_TD.entropy <- entropy(HAW13_TDft) #entropy
HAW13_TD.netMx <- cbind(HAW13_TD.netMx, HAW13_TD.clusterCoef, HAW13_TD.degreeCent$centralization,
HAW13_TD.netDensity, HAW13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "HAW"
KIoutcome = "End of Qtr_DM"
HAW13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
HAW13_QTg2 <- data.frame(HAW13_QT)
HAW13_QTg2 <- HAW13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_QTg2$player1
player2vector <- HAW13_QTg2$player2
HAW13_QTg3 <- HAW13_QTg2
HAW13_QTg3$p1inp2vec <- is.element(HAW13_QTg3$player1, player2vector)
HAW13_QTg3$p2inp1vec <- is.element(HAW13_QTg3$player2, player1vector)
addPlayer1 <- HAW13_QTg3[ which(HAW13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_QTg3[ which(HAW13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_QTg2 <- rbind(HAW13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
HAW13_QTft <- ftable(HAW13_QTg2$player1, HAW13_QTg2$player2)
HAW13_QTft2 <- as.matrix(HAW13_QTft)
numRows <- nrow(HAW13_QTft2)
numCols <- ncol(HAW13_QTft2)
HAW13_QTft3 <- HAW13_QTft2[c(2:numRows) , c(2:numCols)]
HAW13_QTTable <- graph.adjacency(HAW13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(HAW13_QTTable, vertex.label = V(HAW13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
HAW13_QT.clusterCoef <- transitivity(HAW13_QTTable, type="global") #cluster coefficient
HAW13_QT.degreeCent <- centralization.degree(HAW13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_QTftn <- as.network.matrix(HAW13_QTft)
HAW13_QT.netDensity <- network.density(HAW13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_QT.entropy <- entropy(HAW13_QTft) #entropy
HAW13_QT.netMx <- cbind(HAW13_QT.netMx, HAW13_QT.clusterCoef, HAW13_QT.degreeCent$centralization,
HAW13_QT.netDensity, HAW13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_QT.netMx) <- varnames
#############################################################################
#RICHMOND
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "RICH"
KIoutcome = "Goal_F"
RICH13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
RICH13_Gg2 <- data.frame(RICH13_G)
RICH13_Gg2 <- RICH13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_Gg2$player1
player2vector <- RICH13_Gg2$player2
RICH13_Gg3 <- RICH13_Gg2
RICH13_Gg3$p1inp2vec <- is.element(RICH13_Gg3$player1, player2vector)
RICH13_Gg3$p2inp1vec <- is.element(RICH13_Gg3$player2, player1vector)
addPlayer1 <- RICH13_Gg3[ which(RICH13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_Gg3[ which(RICH13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_Gg2 <- rbind(RICH13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
RICH13_Gft <- ftable(RICH13_Gg2$player1, RICH13_Gg2$player2)
RICH13_Gft2 <- as.matrix(RICH13_Gft)
numRows <- nrow(RICH13_Gft2)
numCols <- ncol(RICH13_Gft2)
RICH13_Gft3 <- RICH13_Gft2[c(2:numRows) , c(2:numCols)]
RICH13_GTable <- graph.adjacency(RICH13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(RICH13_GTable, vertex.label = V(RICH13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
RICH13_G.clusterCoef <- transitivity(RICH13_GTable, type="global") #cluster coefficient
RICH13_G.degreeCent <- centralization.degree(RICH13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_Gftn <- as.network.matrix(RICH13_Gft)
RICH13_G.netDensity <- network.density(RICH13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_G.entropy <- entropy(RICH13_Gft) #entropy
RICH13_G.netMx <- cbind(RICH13_G.netMx, RICH13_G.clusterCoef, RICH13_G.degreeCent$centralization,
RICH13_G.netDensity, RICH13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
round = 13
teamName = "RICH"
KIoutcome = "Behind_F"
RICH13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
RICH13_Bg2 <- data.frame(RICH13_B)
RICH13_Bg2 <- RICH13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_Bg2$player1
player2vector <- RICH13_Bg2$player2
RICH13_Bg3 <- RICH13_Bg2
RICH13_Bg3$p1inp2vec <- is.element(RICH13_Bg3$player1, player2vector)
RICH13_Bg3$p2inp1vec <- is.element(RICH13_Bg3$player2, player1vector)
addPlayer1 <- RICH13_Bg3[ which(RICH13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_Bg3[ which(RICH13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_Bg2 <- rbind(RICH13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
RICH13_Bft <- ftable(RICH13_Bg2$player1, RICH13_Bg2$player2)
RICH13_Bft2 <- as.matrix(RICH13_Bft)
numRows <- nrow(RICH13_Bft2)
numCols <- ncol(RICH13_Bft2)
RICH13_Bft3 <- RICH13_Bft2[c(2:numRows) , c(2:numCols)]
RICH13_BTable <- graph.adjacency(RICH13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(RICH13_BTable, vertex.label = V(RICH13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
RICH13_B.clusterCoef <- transitivity(RICH13_BTable, type="global") #cluster coefficient
RICH13_B.degreeCent <- centralization.degree(RICH13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_Bftn <- as.network.matrix(RICH13_Bft)
RICH13_B.netDensity <- network.density(RICH13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_B.entropy <- entropy(RICH13_Bft) #entropy
RICH13_B.netMx <- cbind(RICH13_B.netMx, RICH13_B.clusterCoef, RICH13_B.degreeCent$centralization,
RICH13_B.netDensity, RICH13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "RICH"
KIoutcome = "Stoppage_F"
RICH13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
RICH13_SFg2 <- data.frame(RICH13_SF)
RICH13_SFg2 <- RICH13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_SFg2$player1
player2vector <- RICH13_SFg2$player2
RICH13_SFg3 <- RICH13_SFg2
RICH13_SFg3$p1inp2vec <- is.element(RICH13_SFg3$player1, player2vector)
RICH13_SFg3$p2inp1vec <- is.element(RICH13_SFg3$player2, player1vector)
addPlayer1 <- RICH13_SFg3[ which(RICH13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_SFg3[ which(RICH13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_SFg2 <- rbind(RICH13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
RICH13_SFft <- ftable(RICH13_SFg2$player1, RICH13_SFg2$player2)
RICH13_SFft2 <- as.matrix(RICH13_SFft)
numRows <- nrow(RICH13_SFft2)
numCols <- ncol(RICH13_SFft2)
RICH13_SFft3 <- RICH13_SFft2[c(2:numRows) , c(2:numCols)]
RICH13_SFTable <- graph.adjacency(RICH13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(RICH13_SFTable, vertex.label = V(RICH13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
RICH13_SF.clusterCoef <- transitivity(RICH13_SFTable, type="global") #cluster coefficient
RICH13_SF.degreeCent <- centralization.degree(RICH13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_SFftn <- as.network.matrix(RICH13_SFft)
RICH13_SF.netDensity <- network.density(RICH13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_SF.entropy <- entropy(RICH13_SFft) #entropy
RICH13_SF.netMx <- cbind(RICH13_SF.netMx, RICH13_SF.clusterCoef, RICH13_SF.degreeCent$centralization,
RICH13_SF.netDensity, RICH13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
#NA
round = 13
teamName = "RICH"
KIoutcome = "Turnover_F"
RICH13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
RICH13_TFg2 <- data.frame(RICH13_TF)
RICH13_TFg2 <- RICH13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_TFg2$player1
player2vector <- RICH13_TFg2$player2
RICH13_TFg3 <- RICH13_TFg2
RICH13_TFg3$p1inp2vec <- is.element(RICH13_TFg3$player1, player2vector)
RICH13_TFg3$p2inp1vec <- is.element(RICH13_TFg3$player2, player1vector)
addPlayer1 <- RICH13_TFg3[ which(RICH13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_TFg3[ which(RICH13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_TFg2 <- rbind(RICH13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
RICH13_TFft <- ftable(RICH13_TFg2$player1, RICH13_TFg2$player2)
RICH13_TFft2 <- as.matrix(RICH13_TFft)
numRows <- nrow(RICH13_TFft2)
numCols <- ncol(RICH13_TFft2)
RICH13_TFft3 <- RICH13_TFft2[c(2:numRows) , c(2:numCols)]
RICH13_TFTable <- graph.adjacency(RICH13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(RICH13_TFTable, vertex.label = V(RICH13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
RICH13_TF.clusterCoef <- transitivity(RICH13_TFTable, type="global") #cluster coefficient
RICH13_TF.degreeCent <- centralization.degree(RICH13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_TFftn <- as.network.matrix(RICH13_TFft)
RICH13_TF.netDensity <- network.density(RICH13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_TF.entropy <- entropy(RICH13_TFft) #entropy
RICH13_TF.netMx <- cbind(RICH13_TF.netMx, RICH13_TF.clusterCoef, RICH13_TF.degreeCent$centralization,
RICH13_TF.netDensity, RICH13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
round = 13
teamName = "RICH"
KIoutcome = "Stoppage_AM"
RICH13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
RICH13_SAMg2 <- data.frame(RICH13_SAM)
RICH13_SAMg2 <- RICH13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_SAMg2$player1
player2vector <- RICH13_SAMg2$player2
RICH13_SAMg3 <- RICH13_SAMg2
RICH13_SAMg3$p1inp2vec <- is.element(RICH13_SAMg3$player1, player2vector)
RICH13_SAMg3$p2inp1vec <- is.element(RICH13_SAMg3$player2, player1vector)
addPlayer1 <- RICH13_SAMg3[ which(RICH13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_SAMg3[ which(RICH13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(empty, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_SAMg2 <- rbind(RICH13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
RICH13_SAMft <- ftable(RICH13_SAMg2$player1, RICH13_SAMg2$player2)
RICH13_SAMft2 <- as.matrix(RICH13_SAMft)
numRows <- nrow(RICH13_SAMft2)
numCols <- ncol(RICH13_SAMft2)
RICH13_SAMft3 <- RICH13_SAMft2[c(2:numRows) , c(2:numCols)]
RICH13_SAMTable <- graph.adjacency(RICH13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(RICH13_SAMTable, vertex.label = V(RICH13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
RICH13_SAM.clusterCoef <- transitivity(RICH13_SAMTable, type="global") #cluster coefficient
RICH13_SAM.degreeCent <- centralization.degree(RICH13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_SAMftn <- as.network.matrix(RICH13_SAMft)
RICH13_SAM.netDensity <- network.density(RICH13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_SAM.entropy <- entropy(RICH13_SAMft) #entropy
RICH13_SAM.netMx <- cbind(RICH13_SAM.netMx, RICH13_SAM.clusterCoef, RICH13_SAM.degreeCent$centralization,
RICH13_SAM.netDensity, RICH13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "RICH"
KIoutcome = "Turnover_AM"
RICH13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
RICH13_TAMg2 <- data.frame(RICH13_TAM)
RICH13_TAMg2 <- RICH13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_TAMg2$player1
player2vector <- RICH13_TAMg2$player2
RICH13_TAMg3 <- RICH13_TAMg2
RICH13_TAMg3$p1inp2vec <- is.element(RICH13_TAMg3$player1, player2vector)
RICH13_TAMg3$p2inp1vec <- is.element(RICH13_TAMg3$player2, player1vector)
addPlayer1 <- RICH13_TAMg3[ which(RICH13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_TAMg3[ which(RICH13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_TAMg2 <- rbind(RICH13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
RICH13_TAMft <- ftable(RICH13_TAMg2$player1, RICH13_TAMg2$player2)
RICH13_TAMft2 <- as.matrix(RICH13_TAMft)
numRows <- nrow(RICH13_TAMft2)
numCols <- ncol(RICH13_TAMft2)
RICH13_TAMft3 <- RICH13_TAMft2[c(2:numRows) , c(2:numCols)]
RICH13_TAMTable <- graph.adjacency(RICH13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(RICH13_TAMTable, vertex.label = V(RICH13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
RICH13_TAM.clusterCoef <- transitivity(RICH13_TAMTable, type="global") #cluster coefficient
RICH13_TAM.degreeCent <- centralization.degree(RICH13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_TAMftn <- as.network.matrix(RICH13_TAMft)
RICH13_TAM.netDensity <- network.density(RICH13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_TAM.entropy <- entropy(RICH13_TAMft) #entropy
RICH13_TAM.netMx <- cbind(RICH13_TAM.netMx, RICH13_TAM.clusterCoef, RICH13_TAM.degreeCent$centralization,
RICH13_TAM.netDensity, RICH13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "RICH"
KIoutcome = "Stoppage_DM"
RICH13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
RICH13_SDMg2 <- data.frame(RICH13_SDM)
RICH13_SDMg2 <- RICH13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_SDMg2$player1
player2vector <- RICH13_SDMg2$player2
RICH13_SDMg3 <- RICH13_SDMg2
RICH13_SDMg3$p1inp2vec <- is.element(RICH13_SDMg3$player1, player2vector)
RICH13_SDMg3$p2inp1vec <- is.element(RICH13_SDMg3$player2, player1vector)
addPlayer1 <- RICH13_SDMg3[ which(RICH13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_SDMg3[ which(RICH13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_SDMg2 <- rbind(RICH13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
RICH13_SDMft <- ftable(RICH13_SDMg2$player1, RICH13_SDMg2$player2)
RICH13_SDMft2 <- as.matrix(RICH13_SDMft)
numRows <- nrow(RICH13_SDMft2)
numCols <- ncol(RICH13_SDMft2)
RICH13_SDMft3 <- RICH13_SDMft2[c(2:numRows) , c(2:numCols)]
RICH13_SDMTable <- graph.adjacency(RICH13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(RICH13_SDMTable, vertex.label = V(RICH13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
RICH13_SDM.clusterCoef <- transitivity(RICH13_SDMTable, type="global") #cluster coefficient
RICH13_SDM.degreeCent <- centralization.degree(RICH13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_SDMftn <- as.network.matrix(RICH13_SDMft)
RICH13_SDM.netDensity <- network.density(RICH13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_SDM.entropy <- entropy(RICH13_SDMft) #entropy
RICH13_SDM.netMx <- cbind(RICH13_SDM.netMx, RICH13_SDM.clusterCoef, RICH13_SDM.degreeCent$centralization,
RICH13_SDM.netDensity, RICH13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "RICH"
KIoutcome = "Turnover_DM"
RICH13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
RICH13_TDMg2 <- data.frame(RICH13_TDM)
RICH13_TDMg2 <- RICH13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_TDMg2$player1
player2vector <- RICH13_TDMg2$player2
RICH13_TDMg3 <- RICH13_TDMg2
RICH13_TDMg3$p1inp2vec <- is.element(RICH13_TDMg3$player1, player2vector)
RICH13_TDMg3$p2inp1vec <- is.element(RICH13_TDMg3$player2, player1vector)
addPlayer1 <- RICH13_TDMg3[ which(RICH13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_TDMg3[ which(RICH13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_TDMg2 <- rbind(RICH13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
RICH13_TDMft <- ftable(RICH13_TDMg2$player1, RICH13_TDMg2$player2)
RICH13_TDMft2 <- as.matrix(RICH13_TDMft)
numRows <- nrow(RICH13_TDMft2)
numCols <- ncol(RICH13_TDMft2)
RICH13_TDMft3 <- RICH13_TDMft2[c(2:numRows) , c(2:numCols)]
RICH13_TDMTable <- graph.adjacency(RICH13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(RICH13_TDMTable, vertex.label = V(RICH13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
RICH13_TDM.clusterCoef <- transitivity(RICH13_TDMTable, type="global") #cluster coefficient
RICH13_TDM.degreeCent <- centralization.degree(RICH13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_TDMftn <- as.network.matrix(RICH13_TDMft)
RICH13_TDM.netDensity <- network.density(RICH13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_TDM.entropy <- entropy(RICH13_TDMft) #entropy
RICH13_TDM.netMx <- cbind(RICH13_TDM.netMx, RICH13_TDM.clusterCoef, RICH13_TDM.degreeCent$centralization,
RICH13_TDM.netDensity, RICH13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "RICH"
KIoutcome = "Stoppage_D"
RICH13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
RICH13_SDg2 <- data.frame(RICH13_SD)
RICH13_SDg2 <- RICH13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_SDg2$player1
player2vector <- RICH13_SDg2$player2
RICH13_SDg3 <- RICH13_SDg2
RICH13_SDg3$p1inp2vec <- is.element(RICH13_SDg3$player1, player2vector)
RICH13_SDg3$p2inp1vec <- is.element(RICH13_SDg3$player2, player1vector)
addPlayer1 <- RICH13_SDg3[ which(RICH13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_SDg3[ which(RICH13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_SDg2 <- rbind(RICH13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
RICH13_SDft <- ftable(RICH13_SDg2$player1, RICH13_SDg2$player2)
RICH13_SDft2 <- as.matrix(RICH13_SDft)
numRows <- nrow(RICH13_SDft2)
numCols <- ncol(RICH13_SDft2)
RICH13_SDft3 <- RICH13_SDft2[c(2:numRows) , c(2:numCols)]
RICH13_SDTable <- graph.adjacency(RICH13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(RICH13_SDTable, vertex.label = V(RICH13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
RICH13_SD.clusterCoef <- transitivity(RICH13_SDTable, type="global") #cluster coefficient
RICH13_SD.degreeCent <- centralization.degree(RICH13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_SDftn <- as.network.matrix(RICH13_SDft)
RICH13_SD.netDensity <- network.density(RICH13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_SD.entropy <- entropy(RICH13_SDft) #entropy
RICH13_SD.netMx <- cbind(RICH13_SD.netMx, RICH13_SD.clusterCoef, RICH13_SD.degreeCent$centralization,
RICH13_SD.netDensity, RICH13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "RICH"
KIoutcome = "Turnover_D"
RICH13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
RICH13_TDg2 <- data.frame(RICH13_TD)
RICH13_TDg2 <- RICH13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_TDg2$player1
player2vector <- RICH13_TDg2$player2
RICH13_TDg3 <- RICH13_TDg2
RICH13_TDg3$p1inp2vec <- is.element(RICH13_TDg3$player1, player2vector)
RICH13_TDg3$p2inp1vec <- is.element(RICH13_TDg3$player2, player1vector)
addPlayer1 <- RICH13_TDg3[ which(RICH13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_TDg3[ which(RICH13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_TDg2 <- rbind(RICH13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
RICH13_TDft <- ftable(RICH13_TDg2$player1, RICH13_TDg2$player2)
RICH13_TDft2 <- as.matrix(RICH13_TDft)
numRows <- nrow(RICH13_TDft2)
numCols <- ncol(RICH13_TDft2)
RICH13_TDft3 <- RICH13_TDft2[c(2:numRows) , c(2:numCols)]
RICH13_TDTable <- graph.adjacency(RICH13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(RICH13_TDTable, vertex.label = V(RICH13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
RICH13_TD.clusterCoef <- transitivity(RICH13_TDTable, type="global") #cluster coefficient
RICH13_TD.degreeCent <- centralization.degree(RICH13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_TDftn <- as.network.matrix(RICH13_TDft)
RICH13_TD.netDensity <- network.density(RICH13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_TD.entropy <- entropy(RICH13_TDft) #entropy
RICH13_TD.netMx <- cbind(RICH13_TD.netMx, RICH13_TD.clusterCoef, RICH13_TD.degreeCent$centralization,
RICH13_TD.netDensity, RICH13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "RICH"
KIoutcome = "End of Qtr_DM"
RICH13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
RICH13_QTg2 <- data.frame(RICH13_QT)
RICH13_QTg2 <- RICH13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_QTg2$player1
player2vector <- RICH13_QTg2$player2
RICH13_QTg3 <- RICH13_QTg2
RICH13_QTg3$p1inp2vec <- is.element(RICH13_QTg3$player1, player2vector)
RICH13_QTg3$p2inp1vec <- is.element(RICH13_QTg3$player2, player1vector)
addPlayer1 <- RICH13_QTg3[ which(RICH13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_QTg3[ which(RICH13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_QTg2 <- rbind(RICH13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
RICH13_QTft <- ftable(RICH13_QTg2$player1, RICH13_QTg2$player2)
RICH13_QTft2 <- as.matrix(RICH13_QTft)
numRows <- nrow(RICH13_QTft2)
numCols <- ncol(RICH13_QTft2)
RICH13_QTft3 <- RICH13_QTft2[c(2:numRows) , c(2:numCols)]
RICH13_QTTable <- graph.adjacency(RICH13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(RICH13_QTTable, vertex.label = V(RICH13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
RICH13_QT.clusterCoef <- transitivity(RICH13_QTTable, type="global") #cluster coefficient
RICH13_QT.degreeCent <- centralization.degree(RICH13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_QTftn <- as.network.matrix(RICH13_QTft)
RICH13_QT.netDensity <- network.density(RICH13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_QT.entropy <- entropy(RICH13_QTft) #entropy
RICH13_QT.netMx <- cbind(RICH13_QT.netMx, RICH13_QT.clusterCoef, RICH13_QT.degreeCent$centralization,
RICH13_QT.netDensity, RICH13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_QT.netMx) <- varnames
#############################################################################
#STKILDA
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "STK"
KIoutcome = "Goal_F"
STK13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
STK13_Gg2 <- data.frame(STK13_G)
STK13_Gg2 <- STK13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_Gg2$player1
player2vector <- STK13_Gg2$player2
STK13_Gg3 <- STK13_Gg2
STK13_Gg3$p1inp2vec <- is.element(STK13_Gg3$player1, player2vector)
STK13_Gg3$p2inp1vec <- is.element(STK13_Gg3$player2, player1vector)
addPlayer1 <- STK13_Gg3[ which(STK13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_Gg3[ which(STK13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_Gg2 <- rbind(STK13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
STK13_Gft <- ftable(STK13_Gg2$player1, STK13_Gg2$player2)
STK13_Gft2 <- as.matrix(STK13_Gft)
numRows <- nrow(STK13_Gft2)
numCols <- ncol(STK13_Gft2)
STK13_Gft3 <- STK13_Gft2[c(2:numRows) , c(2:numCols)]
STK13_GTable <- graph.adjacency(STK13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(STK13_GTable, vertex.label = V(STK13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
STK13_G.clusterCoef <- transitivity(STK13_GTable, type="global") #cluster coefficient
STK13_G.degreeCent <- centralization.degree(STK13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_Gftn <- as.network.matrix(STK13_Gft)
STK13_G.netDensity <- network.density(STK13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_G.entropy <- entropy(STK13_Gft) #entropy
STK13_G.netMx <- cbind(STK13_G.netMx, STK13_G.clusterCoef, STK13_G.degreeCent$centralization,
STK13_G.netDensity, STK13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
round = 13
teamName = "STK"
KIoutcome = "Behind_F"
STK13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
STK13_Bg2 <- data.frame(STK13_B)
STK13_Bg2 <- STK13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_Bg2$player1
player2vector <- STK13_Bg2$player2
STK13_Bg3 <- STK13_Bg2
STK13_Bg3$p1inp2vec <- is.element(STK13_Bg3$player1, player2vector)
STK13_Bg3$p2inp1vec <- is.element(STK13_Bg3$player2, player1vector)
addPlayer1 <- STK13_Bg3[ which(STK13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, empty, zero)
addPlayer2 <- STK13_Bg3[ which(STK13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_Bg2 <- rbind(STK13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
STK13_Bft <- ftable(STK13_Bg2$player1, STK13_Bg2$player2)
STK13_Bft2 <- as.matrix(STK13_Bft)
numRows <- nrow(STK13_Bft2)
numCols <- ncol(STK13_Bft2)
STK13_Bft3 <- STK13_Bft2[c(2:numRows) , c(2:numCols)]
STK13_BTable <- graph.adjacency(STK13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(STK13_BTable, vertex.label = V(STK13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
STK13_B.clusterCoef <- transitivity(STK13_BTable, type="global") #cluster coefficient
STK13_B.degreeCent <- centralization.degree(STK13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_Bftn <- as.network.matrix(STK13_Bft)
STK13_B.netDensity <- network.density(STK13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_B.entropy <- entropy(STK13_Bft) #entropy
STK13_B.netMx <- cbind(STK13_B.netMx, STK13_B.clusterCoef, STK13_B.degreeCent$centralization,
STK13_B.netDensity, STK13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "STK"
KIoutcome = "Stoppage_F"
STK13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
STK13_SFg2 <- data.frame(STK13_SF)
STK13_SFg2 <- STK13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_SFg2$player1
player2vector <- STK13_SFg2$player2
STK13_SFg3 <- STK13_SFg2
STK13_SFg3$p1inp2vec <- is.element(STK13_SFg3$player1, player2vector)
STK13_SFg3$p2inp1vec <- is.element(STK13_SFg3$player2, player1vector)
addPlayer1 <- STK13_SFg3[ which(STK13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_SFg3[ which(STK13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_SFg2 <- rbind(STK13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
STK13_SFft <- ftable(STK13_SFg2$player1, STK13_SFg2$player2)
STK13_SFft2 <- as.matrix(STK13_SFft)
numRows <- nrow(STK13_SFft2)
numCols <- ncol(STK13_SFft2)
STK13_SFft3 <- STK13_SFft2[c(2:numRows) , c(2:numCols)]
STK13_SFTable <- graph.adjacency(STK13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(STK13_SFTable, vertex.label = V(STK13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
STK13_SF.clusterCoef <- transitivity(STK13_SFTable, type="global") #cluster coefficient
STK13_SF.degreeCent <- centralization.degree(STK13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_SFftn <- as.network.matrix(STK13_SFft)
STK13_SF.netDensity <- network.density(STK13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_SF.entropy <- entropy(STK13_SFft) #entropy
STK13_SF.netMx <- cbind(STK13_SF.netMx, STK13_SF.clusterCoef, STK13_SF.degreeCent$centralization,
STK13_SF.netDensity, STK13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "STK"
KIoutcome = "Turnover_F"
STK13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
STK13_TFg2 <- data.frame(STK13_TF)
STK13_TFg2 <- STK13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_TFg2$player1
player2vector <- STK13_TFg2$player2
STK13_TFg3 <- STK13_TFg2
STK13_TFg3$p1inp2vec <- is.element(STK13_TFg3$player1, player2vector)
STK13_TFg3$p2inp1vec <- is.element(STK13_TFg3$player2, player1vector)
addPlayer1 <- STK13_TFg3[ which(STK13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_TFg3[ which(STK13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_TFg2 <- rbind(STK13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
STK13_TFft <- ftable(STK13_TFg2$player1, STK13_TFg2$player2)
STK13_TFft2 <- as.matrix(STK13_TFft)
numRows <- nrow(STK13_TFft2)
numCols <- ncol(STK13_TFft2)
STK13_TFft3 <- STK13_TFft2[c(2:numRows) , c(2:numCols)]
STK13_TFTable <- graph.adjacency(STK13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(STK13_TFTable, vertex.label = V(STK13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
STK13_TF.clusterCoef <- transitivity(STK13_TFTable, type="global") #cluster coefficient
STK13_TF.degreeCent <- centralization.degree(STK13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_TFftn <- as.network.matrix(STK13_TFft)
STK13_TF.netDensity <- network.density(STK13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_TF.entropy <- entropy(STK13_TFft) #entropy
STK13_TF.netMx <- cbind(STK13_TF.netMx, STK13_TF.clusterCoef, STK13_TF.degreeCent$centralization,
STK13_TF.netDensity, STK13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
round = 13
teamName = "STK"
KIoutcome = "Stoppage_AM"
STK13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
STK13_SAMg2 <- data.frame(STK13_SAM)
STK13_SAMg2 <- STK13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_SAMg2$player1
player2vector <- STK13_SAMg2$player2
STK13_SAMg3 <- STK13_SAMg2
STK13_SAMg3$p1inp2vec <- is.element(STK13_SAMg3$player1, player2vector)
STK13_SAMg3$p2inp1vec <- is.element(STK13_SAMg3$player2, player1vector)
addPlayer1 <- STK13_SAMg3[ which(STK13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_SAMg3[ which(STK13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_SAMg2 <- rbind(STK13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
STK13_SAMft <- ftable(STK13_SAMg2$player1, STK13_SAMg2$player2)
STK13_SAMft2 <- as.matrix(STK13_SAMft)
numRows <- nrow(STK13_SAMft2)
numCols <- ncol(STK13_SAMft2)
STK13_SAMft3 <- STK13_SAMft2[c(2:numRows) , c(2:numCols)]
STK13_SAMTable <- graph.adjacency(STK13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(STK13_SAMTable, vertex.label = V(STK13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
STK13_SAM.clusterCoef <- transitivity(STK13_SAMTable, type="global") #cluster coefficient
STK13_SAM.degreeCent <- centralization.degree(STK13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_SAMftn <- as.network.matrix(STK13_SAMft)
STK13_SAM.netDensity <- network.density(STK13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_SAM.entropy <- entropy(STK13_SAMft) #entropy
STK13_SAM.netMx <- cbind(STK13_SAM.netMx, STK13_SAM.clusterCoef, STK13_SAM.degreeCent$centralization,
STK13_SAM.netDensity, STK13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "STK"
KIoutcome = "Turnover_AM"
STK13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
STK13_TAMg2 <- data.frame(STK13_TAM)
STK13_TAMg2 <- STK13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_TAMg2$player1
player2vector <- STK13_TAMg2$player2
STK13_TAMg3 <- STK13_TAMg2
STK13_TAMg3$p1inp2vec <- is.element(STK13_TAMg3$player1, player2vector)
STK13_TAMg3$p2inp1vec <- is.element(STK13_TAMg3$player2, player1vector)
addPlayer1 <- STK13_TAMg3[ which(STK13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_TAMg3[ which(STK13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(empty, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_TAMg2 <- rbind(STK13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
STK13_TAMft <- ftable(STK13_TAMg2$player1, STK13_TAMg2$player2)
STK13_TAMft2 <- as.matrix(STK13_TAMft)
numRows <- nrow(STK13_TAMft2)
numCols <- ncol(STK13_TAMft2)
STK13_TAMft3 <- STK13_TAMft2[c(2:numRows) , c(2:numCols)]
STK13_TAMTable <- graph.adjacency(STK13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(STK13_TAMTable, vertex.label = V(STK13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
STK13_TAM.clusterCoef <- transitivity(STK13_TAMTable, type="global") #cluster coefficient
STK13_TAM.degreeCent <- centralization.degree(STK13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_TAMftn <- as.network.matrix(STK13_TAMft)
STK13_TAM.netDensity <- network.density(STK13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_TAM.entropy <- entropy(STK13_TAMft) #entropy
STK13_TAM.netMx <- cbind(STK13_TAM.netMx, STK13_TAM.clusterCoef, STK13_TAM.degreeCent$centralization,
STK13_TAM.netDensity, STK13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "STK"
KIoutcome = "Stoppage_DM"
STK13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
STK13_SDMg2 <- data.frame(STK13_SDM)
STK13_SDMg2 <- STK13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_SDMg2$player1
player2vector <- STK13_SDMg2$player2
STK13_SDMg3 <- STK13_SDMg2
STK13_SDMg3$p1inp2vec <- is.element(STK13_SDMg3$player1, player2vector)
STK13_SDMg3$p2inp1vec <- is.element(STK13_SDMg3$player2, player1vector)
addPlayer1 <- STK13_SDMg3[ which(STK13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_SDMg3[ which(STK13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(empty, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_SDMg2 <- rbind(STK13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
STK13_SDMft <- ftable(STK13_SDMg2$player1, STK13_SDMg2$player2)
STK13_SDMft2 <- as.matrix(STK13_SDMft)
numRows <- nrow(STK13_SDMft2)
numCols <- ncol(STK13_SDMft2)
STK13_SDMft3 <- STK13_SDMft2[c(2:numRows) , c(2:numCols)]
STK13_SDMTable <- graph.adjacency(STK13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(STK13_SDMTable, vertex.label = V(STK13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
STK13_SDM.clusterCoef <- transitivity(STK13_SDMTable, type="global") #cluster coefficient
STK13_SDM.degreeCent <- centralization.degree(STK13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_SDMftn <- as.network.matrix(STK13_SDMft)
STK13_SDM.netDensity <- network.density(STK13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_SDM.entropy <- entropy(STK13_SDMft) #entropy
STK13_SDM.netMx <- cbind(STK13_SDM.netMx, STK13_SDM.clusterCoef, STK13_SDM.degreeCent$centralization,
STK13_SDM.netDensity, STK13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "STK"
KIoutcome = "Turnover_DM"
STK13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
STK13_TDMg2 <- data.frame(STK13_TDM)
STK13_TDMg2 <- STK13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_TDMg2$player1
player2vector <- STK13_TDMg2$player2
STK13_TDMg3 <- STK13_TDMg2
STK13_TDMg3$p1inp2vec <- is.element(STK13_TDMg3$player1, player2vector)
STK13_TDMg3$p2inp1vec <- is.element(STK13_TDMg3$player2, player1vector)
addPlayer1 <- STK13_TDMg3[ which(STK13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_TDMg3[ which(STK13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_TDMg2 <- rbind(STK13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
STK13_TDMft <- ftable(STK13_TDMg2$player1, STK13_TDMg2$player2)
STK13_TDMft2 <- as.matrix(STK13_TDMft)
numRows <- nrow(STK13_TDMft2)
numCols <- ncol(STK13_TDMft2)
STK13_TDMft3 <- STK13_TDMft2[c(2:numRows) , c(2:numCols)]
STK13_TDMTable <- graph.adjacency(STK13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(STK13_TDMTable, vertex.label = V(STK13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
STK13_TDM.clusterCoef <- transitivity(STK13_TDMTable, type="global") #cluster coefficient
STK13_TDM.degreeCent <- centralization.degree(STK13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_TDMftn <- as.network.matrix(STK13_TDMft)
STK13_TDM.netDensity <- network.density(STK13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_TDM.entropy <- entropy(STK13_TDMft) #entropy
STK13_TDM.netMx <- cbind(STK13_TDM.netMx, STK13_TDM.clusterCoef, STK13_TDM.degreeCent$centralization,
STK13_TDM.netDensity, STK13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "STK"
KIoutcome = "Stoppage_D"
STK13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
STK13_SDg2 <- data.frame(STK13_SD)
STK13_SDg2 <- STK13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_SDg2$player1
player2vector <- STK13_SDg2$player2
STK13_SDg3 <- STK13_SDg2
STK13_SDg3$p1inp2vec <- is.element(STK13_SDg3$player1, player2vector)
STK13_SDg3$p2inp1vec <- is.element(STK13_SDg3$player2, player1vector)
addPlayer1 <- STK13_SDg3[ which(STK13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_SDg3[ which(STK13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_SDg2 <- rbind(STK13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
STK13_SDft <- ftable(STK13_SDg2$player1, STK13_SDg2$player2)
STK13_SDft2 <- as.matrix(STK13_SDft)
numRows <- nrow(STK13_SDft2)
numCols <- ncol(STK13_SDft2)
STK13_SDft3 <- STK13_SDft2[c(2:numRows) , c(2:numCols)]
STK13_SDTable <- graph.adjacency(STK13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(STK13_SDTable, vertex.label = V(STK13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
STK13_SD.clusterCoef <- transitivity(STK13_SDTable, type="global") #cluster coefficient
STK13_SD.degreeCent <- centralization.degree(STK13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_SDftn <- as.network.matrix(STK13_SDft)
STK13_SD.netDensity <- network.density(STK13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_SD.entropy <- entropy(STK13_SDft) #entropy
STK13_SD.netMx <- cbind(STK13_SD.netMx, STK13_SD.clusterCoef, STK13_SD.degreeCent$centralization,
STK13_SD.netDensity, STK13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "STK"
KIoutcome = "Turnover_D"
STK13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
STK13_TDg2 <- data.frame(STK13_TD)
STK13_TDg2 <- STK13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_TDg2$player1
player2vector <- STK13_TDg2$player2
STK13_TDg3 <- STK13_TDg2
STK13_TDg3$p1inp2vec <- is.element(STK13_TDg3$player1, player2vector)
STK13_TDg3$p2inp1vec <- is.element(STK13_TDg3$player2, player1vector)
addPlayer1 <- STK13_TDg3[ which(STK13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_TDg3[ which(STK13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_TDg2 <- rbind(STK13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
STK13_TDft <- ftable(STK13_TDg2$player1, STK13_TDg2$player2)
STK13_TDft2 <- as.matrix(STK13_TDft)
numRows <- nrow(STK13_TDft2)
numCols <- ncol(STK13_TDft2)
STK13_TDft3 <- STK13_TDft2[c(2:numRows) , c(2:numCols)]
STK13_TDTable <- graph.adjacency(STK13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(STK13_TDTable, vertex.label = V(STK13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
STK13_TD.clusterCoef <- transitivity(STK13_TDTable, type="global") #cluster coefficient
STK13_TD.degreeCent <- centralization.degree(STK13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_TDftn <- as.network.matrix(STK13_TDft)
STK13_TD.netDensity <- network.density(STK13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_TD.entropy <- entropy(STK13_TDft) #entropy
STK13_TD.netMx <- cbind(STK13_TD.netMx, STK13_TD.clusterCoef, STK13_TD.degreeCent$centralization,
STK13_TD.netDensity, STK13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "STK"
KIoutcome = "End of Qtr_DM"
STK13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
STK13_QTg2 <- data.frame(STK13_QT)
STK13_QTg2 <- STK13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_QTg2$player1
player2vector <- STK13_QTg2$player2
STK13_QTg3 <- STK13_QTg2
STK13_QTg3$p1inp2vec <- is.element(STK13_QTg3$player1, player2vector)
STK13_QTg3$p2inp1vec <- is.element(STK13_QTg3$player2, player1vector)
addPlayer1 <- STK13_QTg3[ which(STK13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_QTg3[ which(STK13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_QTg2 <- rbind(STK13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
STK13_QTft <- ftable(STK13_QTg2$player1, STK13_QTg2$player2)
STK13_QTft2 <- as.matrix(STK13_QTft)
numRows <- nrow(STK13_QTft2)
numCols <- ncol(STK13_QTft2)
STK13_QTft3 <- STK13_QTft2[c(2:numRows) , c(2:numCols)]
STK13_QTTable <- graph.adjacency(STK13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(STK13_QTTable, vertex.label = V(STK13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
STK13_QT.clusterCoef <- transitivity(STK13_QTTable, type="global") #cluster coefficient
STK13_QT.degreeCent <- centralization.degree(STK13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_QTftn <- as.network.matrix(STK13_QTft)
STK13_QT.netDensity <- network.density(STK13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_QT.entropy <- entropy(STK13_QTft) #entropy
STK13_QT.netMx <- cbind(STK13_QT.netMx, STK13_QT.clusterCoef, STK13_QT.degreeCent$centralization,
STK13_QT.netDensity, STK13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_QT.netMx) <- varnames
#############################################################################
#SYDNEY
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "SYD"
KIoutcome = "Goal_F"
SYD13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
SYD13_Gg2 <- data.frame(SYD13_G)
SYD13_Gg2 <- SYD13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_Gg2$player1
player2vector <- SYD13_Gg2$player2
SYD13_Gg3 <- SYD13_Gg2
SYD13_Gg3$p1inp2vec <- is.element(SYD13_Gg3$player1, player2vector)
SYD13_Gg3$p2inp1vec <- is.element(SYD13_Gg3$player2, player1vector)
addPlayer1 <- SYD13_Gg3[ which(SYD13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_Gg3[ which(SYD13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_Gg2 <- rbind(SYD13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
SYD13_Gft <- ftable(SYD13_Gg2$player1, SYD13_Gg2$player2)
SYD13_Gft2 <- as.matrix(SYD13_Gft)
numRows <- nrow(SYD13_Gft2)
numCols <- ncol(SYD13_Gft2)
SYD13_Gft3 <- SYD13_Gft2[c(2:numRows) , c(2:numCols)]
SYD13_GTable <- graph.adjacency(SYD13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(SYD13_GTable, vertex.label = V(SYD13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
SYD13_G.clusterCoef <- transitivity(SYD13_GTable, type="global") #cluster coefficient
SYD13_G.degreeCent <- centralization.degree(SYD13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_Gftn <- as.network.matrix(SYD13_Gft)
SYD13_G.netDensity <- network.density(SYD13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_G.entropy <- entropy(SYD13_Gft) #entropy
SYD13_G.netMx <- cbind(SYD13_G.netMx, SYD13_G.clusterCoef, SYD13_G.degreeCent$centralization,
SYD13_G.netDensity, SYD13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
#NA
round = 13
teamName = "SYD"
KIoutcome = "Behind_F"
SYD13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
SYD13_Bg2 <- data.frame(SYD13_B)
SYD13_Bg2 <- SYD13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_Bg2$player1
player2vector <- SYD13_Bg2$player2
SYD13_Bg3 <- SYD13_Bg2
SYD13_Bg3$p1inp2vec <- is.element(SYD13_Bg3$player1, player2vector)
SYD13_Bg3$p2inp1vec <- is.element(SYD13_Bg3$player2, player1vector)
addPlayer1 <- SYD13_Bg3[ which(SYD13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_Bg3[ which(SYD13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_Bg2 <- rbind(SYD13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
SYD13_Bft <- ftable(SYD13_Bg2$player1, SYD13_Bg2$player2)
SYD13_Bft2 <- as.matrix(SYD13_Bft)
numRows <- nrow(SYD13_Bft2)
numCols <- ncol(SYD13_Bft2)
SYD13_Bft3 <- SYD13_Bft2[c(2:numRows) , c(2:numCols)]
SYD13_BTable <- graph.adjacency(SYD13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(SYD13_BTable, vertex.label = V(SYD13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
SYD13_B.clusterCoef <- transitivity(SYD13_BTable, type="global") #cluster coefficient
SYD13_B.degreeCent <- centralization.degree(SYD13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_Bftn <- as.network.matrix(SYD13_Bft)
SYD13_B.netDensity <- network.density(SYD13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_B.entropy <- entropy(SYD13_Bft) #entropy
SYD13_B.netMx <- cbind(SYD13_B.netMx, SYD13_B.clusterCoef, SYD13_B.degreeCent$centralization,
SYD13_B.netDensity, SYD13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
round = 13
teamName = "SYD"
KIoutcome = "Stoppage_F"
SYD13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
SYD13_SFg2 <- data.frame(SYD13_SF)
SYD13_SFg2 <- SYD13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_SFg2$player1
player2vector <- SYD13_SFg2$player2
SYD13_SFg3 <- SYD13_SFg2
SYD13_SFg3$p1inp2vec <- is.element(SYD13_SFg3$player1, player2vector)
SYD13_SFg3$p2inp1vec <- is.element(SYD13_SFg3$player2, player1vector)
addPlayer1 <- SYD13_SFg3[ which(SYD13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_SFg3[ which(SYD13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_SFg2 <- rbind(SYD13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
SYD13_SFft <- ftable(SYD13_SFg2$player1, SYD13_SFg2$player2)
SYD13_SFft2 <- as.matrix(SYD13_SFft)
numRows <- nrow(SYD13_SFft2)
numCols <- ncol(SYD13_SFft2)
SYD13_SFft3 <- SYD13_SFft2[c(2:numRows) , c(2:numCols)]
SYD13_SFTable <- graph.adjacency(SYD13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(SYD13_SFTable, vertex.label = V(SYD13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
SYD13_SF.clusterCoef <- transitivity(SYD13_SFTable, type="global") #cluster coefficient
SYD13_SF.degreeCent <- centralization.degree(SYD13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_SFftn <- as.network.matrix(SYD13_SFft)
SYD13_SF.netDensity <- network.density(SYD13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_SF.entropy <- entropy(SYD13_SFft) #entropy
SYD13_SF.netMx <- cbind(SYD13_SF.netMx, SYD13_SF.clusterCoef, SYD13_SF.degreeCent$centralization,
SYD13_SF.netDensity, SYD13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "SYD"
KIoutcome = "Turnover_F"
SYD13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
SYD13_TFg2 <- data.frame(SYD13_TF)
SYD13_TFg2 <- SYD13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_TFg2$player1
player2vector <- SYD13_TFg2$player2
SYD13_TFg3 <- SYD13_TFg2
SYD13_TFg3$p1inp2vec <- is.element(SYD13_TFg3$player1, player2vector)
SYD13_TFg3$p2inp1vec <- is.element(SYD13_TFg3$player2, player1vector)
addPlayer1 <- SYD13_TFg3[ which(SYD13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_TFg3[ which(SYD13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_TFg2 <- rbind(SYD13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
SYD13_TFft <- ftable(SYD13_TFg2$player1, SYD13_TFg2$player2)
SYD13_TFft2 <- as.matrix(SYD13_TFft)
numRows <- nrow(SYD13_TFft2)
numCols <- ncol(SYD13_TFft2)
SYD13_TFft3 <- SYD13_TFft2[c(2:numRows) , c(2:numCols)]
SYD13_TFTable <- graph.adjacency(SYD13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(SYD13_TFTable, vertex.label = V(SYD13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
SYD13_TF.clusterCoef <- transitivity(SYD13_TFTable, type="global") #cluster coefficient
SYD13_TF.degreeCent <- centralization.degree(SYD13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_TFftn <- as.network.matrix(SYD13_TFft)
SYD13_TF.netDensity <- network.density(SYD13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_TF.entropy <- entropy(SYD13_TFft) #entropy
SYD13_TF.netMx <- cbind(SYD13_TF.netMx, SYD13_TF.clusterCoef, SYD13_TF.degreeCent$centralization,
SYD13_TF.netDensity, SYD13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
#NA
round = 13
teamName = "SYD"
KIoutcome = "Stoppage_AM"
SYD13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
SYD13_SAMg2 <- data.frame(SYD13_SAM)
SYD13_SAMg2 <- SYD13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_SAMg2$player1
player2vector <- SYD13_SAMg2$player2
SYD13_SAMg3 <- SYD13_SAMg2
SYD13_SAMg3$p1inp2vec <- is.element(SYD13_SAMg3$player1, player2vector)
SYD13_SAMg3$p2inp1vec <- is.element(SYD13_SAMg3$player2, player1vector)
addPlayer1 <- SYD13_SAMg3[ which(SYD13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_SAMg3[ which(SYD13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_SAMg2 <- rbind(SYD13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
SYD13_SAMft <- ftable(SYD13_SAMg2$player1, SYD13_SAMg2$player2)
SYD13_SAMft2 <- as.matrix(SYD13_SAMft)
numRows <- nrow(SYD13_SAMft2)
numCols <- ncol(SYD13_SAMft2)
SYD13_SAMft3 <- SYD13_SAMft2[c(2:numRows) , c(2:numCols)]
SYD13_SAMTable <- graph.adjacency(SYD13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(SYD13_SAMTable, vertex.label = V(SYD13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
SYD13_SAM.clusterCoef <- transitivity(SYD13_SAMTable, type="global") #cluster coefficient
SYD13_SAM.degreeCent <- centralization.degree(SYD13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_SAMftn <- as.network.matrix(SYD13_SAMft)
SYD13_SAM.netDensity <- network.density(SYD13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_SAM.entropy <- entropy(SYD13_SAMft) #entropy
SYD13_SAM.netMx <- cbind(SYD13_SAM.netMx, SYD13_SAM.clusterCoef, SYD13_SAM.degreeCent$centralization,
SYD13_SAM.netDensity, SYD13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "SYD"
KIoutcome = "Turnover_AM"
SYD13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
SYD13_TAMg2 <- data.frame(SYD13_TAM)
SYD13_TAMg2 <- SYD13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_TAMg2$player1
player2vector <- SYD13_TAMg2$player2
SYD13_TAMg3 <- SYD13_TAMg2
SYD13_TAMg3$p1inp2vec <- is.element(SYD13_TAMg3$player1, player2vector)
SYD13_TAMg3$p2inp1vec <- is.element(SYD13_TAMg3$player2, player1vector)
addPlayer1 <- SYD13_TAMg3[ which(SYD13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_TAMg3[ which(SYD13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_TAMg2 <- rbind(SYD13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
SYD13_TAMft <- ftable(SYD13_TAMg2$player1, SYD13_TAMg2$player2)
SYD13_TAMft2 <- as.matrix(SYD13_TAMft)
numRows <- nrow(SYD13_TAMft2)
numCols <- ncol(SYD13_TAMft2)
SYD13_TAMft3 <- SYD13_TAMft2[c(2:numRows) , c(2:numCols)]
SYD13_TAMTable <- graph.adjacency(SYD13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(SYD13_TAMTable, vertex.label = V(SYD13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
SYD13_TAM.clusterCoef <- transitivity(SYD13_TAMTable, type="global") #cluster coefficient
SYD13_TAM.degreeCent <- centralization.degree(SYD13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_TAMftn <- as.network.matrix(SYD13_TAMft)
SYD13_TAM.netDensity <- network.density(SYD13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_TAM.entropy <- entropy(SYD13_TAMft) #entropy
SYD13_TAM.netMx <- cbind(SYD13_TAM.netMx, SYD13_TAM.clusterCoef, SYD13_TAM.degreeCent$centralization,
SYD13_TAM.netDensity, SYD13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
#NA
round = 13
teamName = "SYD"
KIoutcome = "Stoppage_DM"
SYD13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
SYD13_SDMg2 <- data.frame(SYD13_SDM)
SYD13_SDMg2 <- SYD13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_SDMg2$player1
player2vector <- SYD13_SDMg2$player2
SYD13_SDMg3 <- SYD13_SDMg2
SYD13_SDMg3$p1inp2vec <- is.element(SYD13_SDMg3$player1, player2vector)
SYD13_SDMg3$p2inp1vec <- is.element(SYD13_SDMg3$player2, player1vector)
addPlayer1 <- SYD13_SDMg3[ which(SYD13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_SDMg3[ which(SYD13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_SDMg2 <- rbind(SYD13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
SYD13_SDMft <- ftable(SYD13_SDMg2$player1, SYD13_SDMg2$player2)
SYD13_SDMft2 <- as.matrix(SYD13_SDMft)
numRows <- nrow(SYD13_SDMft2)
numCols <- ncol(SYD13_SDMft2)
SYD13_SDMft3 <- SYD13_SDMft2[c(2:numRows) , c(2:numCols)]
SYD13_SDMTable <- graph.adjacency(SYD13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(SYD13_SDMTable, vertex.label = V(SYD13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
SYD13_SDM.clusterCoef <- transitivity(SYD13_SDMTable, type="global") #cluster coefficient
SYD13_SDM.degreeCent <- centralization.degree(SYD13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_SDMftn <- as.network.matrix(SYD13_SDMft)
SYD13_SDM.netDensity <- network.density(SYD13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_SDM.entropy <- entropy(SYD13_SDMft) #entropy
SYD13_SDM.netMx <- cbind(SYD13_SDM.netMx, SYD13_SDM.clusterCoef, SYD13_SDM.degreeCent$centralization,
SYD13_SDM.netDensity, SYD13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "SYD"
KIoutcome = "Turnover_DM"
SYD13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
SYD13_TDMg2 <- data.frame(SYD13_TDM)
SYD13_TDMg2 <- SYD13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_TDMg2$player1
player2vector <- SYD13_TDMg2$player2
SYD13_TDMg3 <- SYD13_TDMg2
SYD13_TDMg3$p1inp2vec <- is.element(SYD13_TDMg3$player1, player2vector)
SYD13_TDMg3$p2inp1vec <- is.element(SYD13_TDMg3$player2, player1vector)
addPlayer1 <- SYD13_TDMg3[ which(SYD13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_TDMg3[ which(SYD13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_TDMg2 <- rbind(SYD13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
SYD13_TDMft <- ftable(SYD13_TDMg2$player1, SYD13_TDMg2$player2)
SYD13_TDMft2 <- as.matrix(SYD13_TDMft)
numRows <- nrow(SYD13_TDMft2)
numCols <- ncol(SYD13_TDMft2)
SYD13_TDMft3 <- SYD13_TDMft2[c(2:numRows) , c(2:numCols)]
SYD13_TDMTable <- graph.adjacency(SYD13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(SYD13_TDMTable, vertex.label = V(SYD13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
SYD13_TDM.clusterCoef <- transitivity(SYD13_TDMTable, type="global") #cluster coefficient
SYD13_TDM.degreeCent <- centralization.degree(SYD13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_TDMftn <- as.network.matrix(SYD13_TDMft)
SYD13_TDM.netDensity <- network.density(SYD13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_TDM.entropy <- entropy(SYD13_TDMft) #entropy
SYD13_TDM.netMx <- cbind(SYD13_TDM.netMx, SYD13_TDM.clusterCoef, SYD13_TDM.degreeCent$centralization,
SYD13_TDM.netDensity, SYD13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "SYD"
KIoutcome = "Stoppage_D"
SYD13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
SYD13_SDg2 <- data.frame(SYD13_SD)
SYD13_SDg2 <- SYD13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_SDg2$player1
player2vector <- SYD13_SDg2$player2
SYD13_SDg3 <- SYD13_SDg2
SYD13_SDg3$p1inp2vec <- is.element(SYD13_SDg3$player1, player2vector)
SYD13_SDg3$p2inp1vec <- is.element(SYD13_SDg3$player2, player1vector)
addPlayer1 <- SYD13_SDg3[ which(SYD13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_SDg3[ which(SYD13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_SDg2 <- rbind(SYD13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
SYD13_SDft <- ftable(SYD13_SDg2$player1, SYD13_SDg2$player2)
SYD13_SDft2 <- as.matrix(SYD13_SDft)
numRows <- nrow(SYD13_SDft2)
numCols <- ncol(SYD13_SDft2)
SYD13_SDft3 <- SYD13_SDft2[c(2:numRows) , c(2:numCols)]
SYD13_SDTable <- graph.adjacency(SYD13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(SYD13_SDTable, vertex.label = V(SYD13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
SYD13_SD.clusterCoef <- transitivity(SYD13_SDTable, type="global") #cluster coefficient
SYD13_SD.degreeCent <- centralization.degree(SYD13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_SDftn <- as.network.matrix(SYD13_SDft)
SYD13_SD.netDensity <- network.density(SYD13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_SD.entropy <- entropy(SYD13_SDft) #entropy
SYD13_SD.netMx <- cbind(SYD13_SD.netMx, SYD13_SD.clusterCoef, SYD13_SD.degreeCent$centralization,
SYD13_SD.netDensity, SYD13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "SYD"
KIoutcome = "Turnover_D"
SYD13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
SYD13_TDg2 <- data.frame(SYD13_TD)
SYD13_TDg2 <- SYD13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_TDg2$player1
player2vector <- SYD13_TDg2$player2
SYD13_TDg3 <- SYD13_TDg2
SYD13_TDg3$p1inp2vec <- is.element(SYD13_TDg3$player1, player2vector)
SYD13_TDg3$p2inp1vec <- is.element(SYD13_TDg3$player2, player1vector)
addPlayer1 <- SYD13_TDg3[ which(SYD13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_TDg3[ which(SYD13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_TDg2 <- rbind(SYD13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
SYD13_TDft <- ftable(SYD13_TDg2$player1, SYD13_TDg2$player2)
SYD13_TDft2 <- as.matrix(SYD13_TDft)
numRows <- nrow(SYD13_TDft2)
numCols <- ncol(SYD13_TDft2)
SYD13_TDft3 <- SYD13_TDft2[c(2:numRows) , c(2:numCols)]
SYD13_TDTable <- graph.adjacency(SYD13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(SYD13_TDTable, vertex.label = V(SYD13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
SYD13_TD.clusterCoef <- transitivity(SYD13_TDTable, type="global") #cluster coefficient
SYD13_TD.degreeCent <- centralization.degree(SYD13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_TDftn <- as.network.matrix(SYD13_TDft)
SYD13_TD.netDensity <- network.density(SYD13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_TD.entropy <- entropy(SYD13_TDft) #entropy
SYD13_TD.netMx <- cbind(SYD13_TD.netMx, SYD13_TD.clusterCoef, SYD13_TD.degreeCent$centralization,
SYD13_TD.netDensity, SYD13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "SYD"
KIoutcome = "End of Qtr_DM"
SYD13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
SYD13_QTg2 <- data.frame(SYD13_QT)
SYD13_QTg2 <- SYD13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_QTg2$player1
player2vector <- SYD13_QTg2$player2
SYD13_QTg3 <- SYD13_QTg2
SYD13_QTg3$p1inp2vec <- is.element(SYD13_QTg3$player1, player2vector)
SYD13_QTg3$p2inp1vec <- is.element(SYD13_QTg3$player2, player1vector)
addPlayer1 <- SYD13_QTg3[ which(SYD13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_QTg3[ which(SYD13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_QTg2 <- rbind(SYD13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
SYD13_QTft <- ftable(SYD13_QTg2$player1, SYD13_QTg2$player2)
SYD13_QTft2 <- as.matrix(SYD13_QTft)
numRows <- nrow(SYD13_QTft2)
numCols <- ncol(SYD13_QTft2)
SYD13_QTft3 <- SYD13_QTft2[c(2:numRows) , c(2:numCols)]
SYD13_QTTable <- graph.adjacency(SYD13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(SYD13_QTTable, vertex.label = V(SYD13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
SYD13_QT.clusterCoef <- transitivity(SYD13_QTTable, type="global") #cluster coefficient
SYD13_QT.degreeCent <- centralization.degree(SYD13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_QTftn <- as.network.matrix(SYD13_QTft)
SYD13_QT.netDensity <- network.density(SYD13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_QT.entropy <- entropy(SYD13_QTft) #entropy
SYD13_QT.netMx <- cbind(SYD13_QT.netMx, SYD13_QT.clusterCoef, SYD13_QT.degreeCent$centralization,
SYD13_QT.netDensity, SYD13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_QT.netMx) <- varnames
#############################################################################
#WESTERN BULLDOGS
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "WB"
KIoutcome = "Goal_F"
WB13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
WB13_Gg2 <- data.frame(WB13_G)
WB13_Gg2 <- WB13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_Gg2$player1
player2vector <- WB13_Gg2$player2
WB13_Gg3 <- WB13_Gg2
WB13_Gg3$p1inp2vec <- is.element(WB13_Gg3$player1, player2vector)
WB13_Gg3$p2inp1vec <- is.element(WB13_Gg3$player2, player1vector)
addPlayer1 <- WB13_Gg3[ which(WB13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_Gg3[ which(WB13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_Gg2 <- rbind(WB13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
WB13_Gft <- ftable(WB13_Gg2$player1, WB13_Gg2$player2)
WB13_Gft2 <- as.matrix(WB13_Gft)
numRows <- nrow(WB13_Gft2)
numCols <- ncol(WB13_Gft2)
WB13_Gft3 <- WB13_Gft2[c(2:numRows) , c(2:numCols)]
WB13_GTable <- graph.adjacency(WB13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(WB13_GTable, vertex.label = V(WB13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
WB13_G.clusterCoef <- transitivity(WB13_GTable, type="global") #cluster coefficient
WB13_G.degreeCent <- centralization.degree(WB13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_Gftn <- as.network.matrix(WB13_Gft)
WB13_G.netDensity <- network.density(WB13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_G.entropy <- entropy(WB13_Gft) #entropy
WB13_G.netMx <- cbind(WB13_G.netMx, WB13_G.clusterCoef, WB13_G.degreeCent$centralization,
WB13_G.netDensity, WB13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
#NA
round = 13
teamName = "WB"
KIoutcome = "Behind_F"
WB13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
WB13_Bg2 <- data.frame(WB13_B)
WB13_Bg2 <- WB13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_Bg2$player1
player2vector <- WB13_Bg2$player2
WB13_Bg3 <- WB13_Bg2
WB13_Bg3$p1inp2vec <- is.element(WB13_Bg3$player1, player2vector)
WB13_Bg3$p2inp1vec <- is.element(WB13_Bg3$player2, player1vector)
addPlayer1 <- WB13_Bg3[ which(WB13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_Bg3[ which(WB13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_Bg2 <- rbind(WB13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
WB13_Bft <- ftable(WB13_Bg2$player1, WB13_Bg2$player2)
WB13_Bft2 <- as.matrix(WB13_Bft)
numRows <- nrow(WB13_Bft2)
numCols <- ncol(WB13_Bft2)
WB13_Bft3 <- WB13_Bft2[c(2:numRows) , c(2:numCols)]
WB13_BTable <- graph.adjacency(WB13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(WB13_BTable, vertex.label = V(WB13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
WB13_B.clusterCoef <- transitivity(WB13_BTable, type="global") #cluster coefficient
WB13_B.degreeCent <- centralization.degree(WB13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_Bftn <- as.network.matrix(WB13_Bft)
WB13_B.netDensity <- network.density(WB13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_B.entropy <- entropy(WB13_Bft) #entropy
WB13_B.netMx <- cbind(WB13_B.netMx, WB13_B.clusterCoef, WB13_B.degreeCent$centralization,
WB13_B.netDensity, WB13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
round = 13
teamName = "WB"
KIoutcome = "Stoppage_F"
WB13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
WB13_SFg2 <- data.frame(WB13_SF)
WB13_SFg2 <- WB13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_SFg2$player1
player2vector <- WB13_SFg2$player2
WB13_SFg3 <- WB13_SFg2
WB13_SFg3$p1inp2vec <- is.element(WB13_SFg3$player1, player2vector)
WB13_SFg3$p2inp1vec <- is.element(WB13_SFg3$player2, player1vector)
addPlayer1 <- WB13_SFg3[ which(WB13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_SFg3[ which(WB13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_SFg2 <- rbind(WB13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
WB13_SFft <- ftable(WB13_SFg2$player1, WB13_SFg2$player2)
WB13_SFft2 <- as.matrix(WB13_SFft)
numRows <- nrow(WB13_SFft2)
numCols <- ncol(WB13_SFft2)
WB13_SFft3 <- WB13_SFft2[c(2:numRows) , c(2:numCols)]
WB13_SFTable <- graph.adjacency(WB13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(WB13_SFTable, vertex.label = V(WB13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
WB13_SF.clusterCoef <- transitivity(WB13_SFTable, type="global") #cluster coefficient
WB13_SF.degreeCent <- centralization.degree(WB13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_SFftn <- as.network.matrix(WB13_SFft)
WB13_SF.netDensity <- network.density(WB13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_SF.entropy <- entropy(WB13_SFft) #entropy
WB13_SF.netMx <- cbind(WB13_SF.netMx, WB13_SF.clusterCoef, WB13_SF.degreeCent$centralization,
WB13_SF.netDensity, WB13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "WB"
KIoutcome = "Turnover_F"
WB13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
WB13_TFg2 <- data.frame(WB13_TF)
WB13_TFg2 <- WB13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_TFg2$player1
player2vector <- WB13_TFg2$player2
WB13_TFg3 <- WB13_TFg2
WB13_TFg3$p1inp2vec <- is.element(WB13_TFg3$player1, player2vector)
WB13_TFg3$p2inp1vec <- is.element(WB13_TFg3$player2, player1vector)
addPlayer1 <- WB13_TFg3[ which(WB13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_TFg3[ which(WB13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_TFg2 <- rbind(WB13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
WB13_TFft <- ftable(WB13_TFg2$player1, WB13_TFg2$player2)
WB13_TFft2 <- as.matrix(WB13_TFft)
numRows <- nrow(WB13_TFft2)
numCols <- ncol(WB13_TFft2)
WB13_TFft3 <- WB13_TFft2[c(2:numRows) , c(2:numCols)]
WB13_TFTable <- graph.adjacency(WB13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(WB13_TFTable, vertex.label = V(WB13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
WB13_TF.clusterCoef <- transitivity(WB13_TFTable, type="global") #cluster coefficient
WB13_TF.degreeCent <- centralization.degree(WB13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_TFftn <- as.network.matrix(WB13_TFft)
WB13_TF.netDensity <- network.density(WB13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_TF.entropy <- entropy(WB13_TFft) #entropy
WB13_TF.netMx <- cbind(WB13_TF.netMx, WB13_TF.clusterCoef, WB13_TF.degreeCent$centralization,
WB13_TF.netDensity, WB13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
#NA
round = 13
teamName = "WB"
KIoutcome = "Stoppage_AM"
WB13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
WB13_SAMg2 <- data.frame(WB13_SAM)
WB13_SAMg2 <- WB13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_SAMg2$player1
player2vector <- WB13_SAMg2$player2
WB13_SAMg3 <- WB13_SAMg2
WB13_SAMg3$p1inp2vec <- is.element(WB13_SAMg3$player1, player2vector)
WB13_SAMg3$p2inp1vec <- is.element(WB13_SAMg3$player2, player1vector)
addPlayer1 <- WB13_SAMg3[ which(WB13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_SAMg3[ which(WB13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_SAMg2 <- rbind(WB13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
WB13_SAMft <- ftable(WB13_SAMg2$player1, WB13_SAMg2$player2)
WB13_SAMft2 <- as.matrix(WB13_SAMft)
numRows <- nrow(WB13_SAMft2)
numCols <- ncol(WB13_SAMft2)
WB13_SAMft3 <- WB13_SAMft2[c(2:numRows) , c(2:numCols)]
WB13_SAMTable <- graph.adjacency(WB13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(WB13_SAMTable, vertex.label = V(WB13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
WB13_SAM.clusterCoef <- transitivity(WB13_SAMTable, type="global") #cluster coefficient
WB13_SAM.degreeCent <- centralization.degree(WB13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_SAMftn <- as.network.matrix(WB13_SAMft)
WB13_SAM.netDensity <- network.density(WB13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_SAM.entropy <- entropy(WB13_SAMft) #entropy
WB13_SAM.netMx <- cbind(WB13_SAM.netMx, WB13_SAM.clusterCoef, WB13_SAM.degreeCent$centralization,
WB13_SAM.netDensity, WB13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "WB"
KIoutcome = "Turnover_AM"
WB13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
WB13_TAMg2 <- data.frame(WB13_TAM)
WB13_TAMg2 <- WB13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_TAMg2$player1
player2vector <- WB13_TAMg2$player2
WB13_TAMg3 <- WB13_TAMg2
WB13_TAMg3$p1inp2vec <- is.element(WB13_TAMg3$player1, player2vector)
WB13_TAMg3$p2inp1vec <- is.element(WB13_TAMg3$player2, player1vector)
addPlayer1 <- WB13_TAMg3[ which(WB13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_TAMg3[ which(WB13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_TAMg2 <- rbind(WB13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
WB13_TAMft <- ftable(WB13_TAMg2$player1, WB13_TAMg2$player2)
WB13_TAMft2 <- as.matrix(WB13_TAMft)
numRows <- nrow(WB13_TAMft2)
numCols <- ncol(WB13_TAMft2)
WB13_TAMft3 <- WB13_TAMft2[c(2:numRows) , c(2:numCols)]
WB13_TAMTable <- graph.adjacency(WB13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(WB13_TAMTable, vertex.label = V(WB13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
WB13_TAM.clusterCoef <- transitivity(WB13_TAMTable, type="global") #cluster coefficient
WB13_TAM.degreeCent <- centralization.degree(WB13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_TAMftn <- as.network.matrix(WB13_TAMft)
WB13_TAM.netDensity <- network.density(WB13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_TAM.entropy <- entropy(WB13_TAMft) #entropy
WB13_TAM.netMx <- cbind(WB13_TAM.netMx, WB13_TAM.clusterCoef, WB13_TAM.degreeCent$centralization,
WB13_TAM.netDensity, WB13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "WB"
KIoutcome = "Stoppage_DM"
WB13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
WB13_SDMg2 <- data.frame(WB13_SDM)
WB13_SDMg2 <- WB13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_SDMg2$player1
player2vector <- WB13_SDMg2$player2
WB13_SDMg3 <- WB13_SDMg2
WB13_SDMg3$p1inp2vec <- is.element(WB13_SDMg3$player1, player2vector)
WB13_SDMg3$p2inp1vec <- is.element(WB13_SDMg3$player2, player1vector)
addPlayer1 <- WB13_SDMg3[ which(WB13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_SDMg3[ which(WB13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_SDMg2 <- rbind(WB13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
WB13_SDMft <- ftable(WB13_SDMg2$player1, WB13_SDMg2$player2)
WB13_SDMft2 <- as.matrix(WB13_SDMft)
numRows <- nrow(WB13_SDMft2)
numCols <- ncol(WB13_SDMft2)
WB13_SDMft3 <- WB13_SDMft2[c(2:numRows) , c(2:numCols)]
WB13_SDMTable <- graph.adjacency(WB13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(WB13_SDMTable, vertex.label = V(WB13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
WB13_SDM.clusterCoef <- transitivity(WB13_SDMTable, type="global") #cluster coefficient
WB13_SDM.degreeCent <- centralization.degree(WB13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_SDMftn <- as.network.matrix(WB13_SDMft)
WB13_SDM.netDensity <- network.density(WB13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_SDM.entropy <- entropy(WB13_SDMft) #entropy
WB13_SDM.netMx <- cbind(WB13_SDM.netMx, WB13_SDM.clusterCoef, WB13_SDM.degreeCent$centralization,
WB13_SDM.netDensity, WB13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "WB"
KIoutcome = "Turnover_DM"
WB13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
WB13_TDMg2 <- data.frame(WB13_TDM)
WB13_TDMg2 <- WB13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_TDMg2$player1
player2vector <- WB13_TDMg2$player2
WB13_TDMg3 <- WB13_TDMg2
WB13_TDMg3$p1inp2vec <- is.element(WB13_TDMg3$player1, player2vector)
WB13_TDMg3$p2inp1vec <- is.element(WB13_TDMg3$player2, player1vector)
addPlayer1 <- WB13_TDMg3[ which(WB13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_TDMg3[ which(WB13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_TDMg2 <- rbind(WB13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
WB13_TDMft <- ftable(WB13_TDMg2$player1, WB13_TDMg2$player2)
WB13_TDMft2 <- as.matrix(WB13_TDMft)
numRows <- nrow(WB13_TDMft2)
numCols <- ncol(WB13_TDMft2)
WB13_TDMft3 <- WB13_TDMft2[c(2:numRows) , c(2:numCols)]
WB13_TDMTable <- graph.adjacency(WB13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(WB13_TDMTable, vertex.label = V(WB13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
WB13_TDM.clusterCoef <- transitivity(WB13_TDMTable, type="global") #cluster coefficient
WB13_TDM.degreeCent <- centralization.degree(WB13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_TDMftn <- as.network.matrix(WB13_TDMft)
WB13_TDM.netDensity <- network.density(WB13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_TDM.entropy <- entropy(WB13_TDMft) #entropy
WB13_TDM.netMx <- cbind(WB13_TDM.netMx, WB13_TDM.clusterCoef, WB13_TDM.degreeCent$centralization,
WB13_TDM.netDensity, WB13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "WB"
KIoutcome = "Stoppage_D"
WB13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
WB13_SDg2 <- data.frame(WB13_SD)
WB13_SDg2 <- WB13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_SDg2$player1
player2vector <- WB13_SDg2$player2
WB13_SDg3 <- WB13_SDg2
WB13_SDg3$p1inp2vec <- is.element(WB13_SDg3$player1, player2vector)
WB13_SDg3$p2inp1vec <- is.element(WB13_SDg3$player2, player1vector)
addPlayer1 <- WB13_SDg3[ which(WB13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_SDg3[ which(WB13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_SDg2 <- rbind(WB13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
WB13_SDft <- ftable(WB13_SDg2$player1, WB13_SDg2$player2)
WB13_SDft2 <- as.matrix(WB13_SDft)
numRows <- nrow(WB13_SDft2)
numCols <- ncol(WB13_SDft2)
WB13_SDft3 <- WB13_SDft2[c(2:numRows) , c(2:numCols)]
WB13_SDTable <- graph.adjacency(WB13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(WB13_SDTable, vertex.label = V(WB13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
WB13_SD.clusterCoef <- transitivity(WB13_SDTable, type="global") #cluster coefficient
WB13_SD.degreeCent <- centralization.degree(WB13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_SDftn <- as.network.matrix(WB13_SDft)
WB13_SD.netDensity <- network.density(WB13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_SD.entropy <- entropy(WB13_SDft) #entropy
WB13_SD.netMx <- cbind(WB13_SD.netMx, WB13_SD.clusterCoef, WB13_SD.degreeCent$centralization,
WB13_SD.netDensity, WB13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "WB"
KIoutcome = "Turnover_D"
WB13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
WB13_TDg2 <- data.frame(WB13_TD)
WB13_TDg2 <- WB13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_TDg2$player1
player2vector <- WB13_TDg2$player2
WB13_TDg3 <- WB13_TDg2
WB13_TDg3$p1inp2vec <- is.element(WB13_TDg3$player1, player2vector)
WB13_TDg3$p2inp1vec <- is.element(WB13_TDg3$player2, player1vector)
addPlayer1 <- WB13_TDg3[ which(WB13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_TDg3[ which(WB13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_TDg2 <- rbind(WB13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
WB13_TDft <- ftable(WB13_TDg2$player1, WB13_TDg2$player2)
WB13_TDft2 <- as.matrix(WB13_TDft)
numRows <- nrow(WB13_TDft2)
numCols <- ncol(WB13_TDft2)
WB13_TDft3 <- WB13_TDft2[c(2:numRows) , c(2:numCols)]
WB13_TDTable <- graph.adjacency(WB13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(WB13_TDTable, vertex.label = V(WB13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
WB13_TD.clusterCoef <- transitivity(WB13_TDTable, type="global") #cluster coefficient
WB13_TD.degreeCent <- centralization.degree(WB13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_TDftn <- as.network.matrix(WB13_TDft)
WB13_TD.netDensity <- network.density(WB13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_TD.entropy <- entropy(WB13_TDft) #entropy
WB13_TD.netMx <- cbind(WB13_TD.netMx, WB13_TD.clusterCoef, WB13_TD.degreeCent$centralization,
WB13_TD.netDensity, WB13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "WB"
KIoutcome = "End of Qtr_DM"
WB13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
WB13_QTg2 <- data.frame(WB13_QT)
WB13_QTg2 <- WB13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_QTg2$player1
player2vector <- WB13_QTg2$player2
WB13_QTg3 <- WB13_QTg2
WB13_QTg3$p1inp2vec <- is.element(WB13_QTg3$player1, player2vector)
WB13_QTg3$p2inp1vec <- is.element(WB13_QTg3$player2, player1vector)
addPlayer1 <- WB13_QTg3[ which(WB13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_QTg3[ which(WB13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_QTg2 <- rbind(WB13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
WB13_QTft <- ftable(WB13_QTg2$player1, WB13_QTg2$player2)
WB13_QTft2 <- as.matrix(WB13_QTft)
numRows <- nrow(WB13_QTft2)
numCols <- ncol(WB13_QTft2)
WB13_QTft3 <- WB13_QTft2[c(2:numRows) , c(2:numCols)]
WB13_QTTable <- graph.adjacency(WB13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(WB13_QTTable, vertex.label = V(WB13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
WB13_QT.clusterCoef <- transitivity(WB13_QTTable, type="global") #cluster coefficient
WB13_QT.degreeCent <- centralization.degree(WB13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_QTftn <- as.network.matrix(WB13_QTft)
WB13_QT.netDensity <- network.density(WB13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_QT.entropy <- entropy(WB13_QTft) #entropy
WB13_QT.netMx <- cbind(WB13_QT.netMx, WB13_QT.clusterCoef, WB13_QT.degreeCent$centralization,
WB13_QT.netDensity, WB13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_QT.netMx) <- varnames
| /09_29_16 Real Data 01-NA-Round13.R | no_license | nonitay/Honours16 | R | false | false | 355,754 | r | #####
#09-29-16- Real data 13
#Network Analysis
####
library(igraph)
library(network)
library(entropy)
#############################################################################
#ADELAIDE
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "ADEL"
KIoutcome = "Goal_F"
ADEL13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
ADEL13_Gg2 <- data.frame(ADEL13_G)
ADEL13_Gg2 <- ADEL13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_Gg2$player1
player2vector <- ADEL13_Gg2$player2
ADEL13_Gg3 <- ADEL13_Gg2
ADEL13_Gg3$p1inp2vec <- is.element(ADEL13_Gg3$player1, player2vector)
ADEL13_Gg3$p2inp1vec <- is.element(ADEL13_Gg3$player2, player1vector)
addPlayer1 <- ADEL13_Gg3[ which(ADEL13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_Gg3[ which(ADEL13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_Gg2 <- rbind(ADEL13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
ADEL13_Gft <- ftable(ADEL13_Gg2$player1, ADEL13_Gg2$player2)
ADEL13_Gft2 <- as.matrix(ADEL13_Gft)
numRows <- nrow(ADEL13_Gft2)
numCols <- ncol(ADEL13_Gft2)
ADEL13_Gft3 <- ADEL13_Gft2[c(2:numRows) , c(2:numCols)]
ADEL13_GTable <- graph.adjacency(ADEL13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(ADEL13_GTable, vertex.label = V(ADEL13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
ADEL13_G.clusterCoef <- transitivity(ADEL13_GTable, type="global") #cluster coefficient
ADEL13_G.degreeCent <- centralization.degree(ADEL13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_Gftn <- as.network.matrix(ADEL13_Gft)
ADEL13_G.netDensity <- network.density(ADEL13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_G.entropy <- entropy(ADEL13_Gft) #entropy
ADEL13_G.netMx <- cbind(ADEL13_G.netMx, ADEL13_G.clusterCoef, ADEL13_G.degreeCent$centralization,
ADEL13_G.netDensity, ADEL13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
#NA
round = 13
teamName = "ADEL"
KIoutcome = "Behind_F"
ADEL13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
ADEL13_Bg2 <- data.frame(ADEL13_B)
ADEL13_Bg2 <- ADEL13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_Bg2$player1
player2vector <- ADEL13_Bg2$player2
ADEL13_Bg3 <- ADEL13_Bg2
ADEL13_Bg3$p1inp2vec <- is.element(ADEL13_Bg3$player1, player2vector)
ADEL13_Bg3$p2inp1vec <- is.element(ADEL13_Bg3$player2, player1vector)
addPlayer1 <- ADEL13_Bg3[ which(ADEL13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_Bg3[ which(ADEL13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_Bg2 <- rbind(ADEL13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
ADEL13_Bft <- ftable(ADEL13_Bg2$player1, ADEL13_Bg2$player2)
ADEL13_Bft2 <- as.matrix(ADEL13_Bft)
numRows <- nrow(ADEL13_Bft2)
numCols <- ncol(ADEL13_Bft2)
ADEL13_Bft3 <- ADEL13_Bft2[c(2:numRows) , c(2:numCols)]
ADEL13_BTable <- graph.adjacency(ADEL13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(ADEL13_BTable, vertex.label = V(ADEL13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
ADEL13_B.clusterCoef <- transitivity(ADEL13_BTable, type="global") #cluster coefficient
ADEL13_B.degreeCent <- centralization.degree(ADEL13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_Bftn <- as.network.matrix(ADEL13_Bft)
ADEL13_B.netDensity <- network.density(ADEL13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_B.entropy <- entropy(ADEL13_Bft) #entropy
ADEL13_B.netMx <- cbind(ADEL13_B.netMx, ADEL13_B.clusterCoef, ADEL13_B.degreeCent$centralization,
ADEL13_B.netDensity, ADEL13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "ADEL"
KIoutcome = "Stoppage_F"
ADEL13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
ADEL13_SFg2 <- data.frame(ADEL13_SF)
ADEL13_SFg2 <- ADEL13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_SFg2$player1
player2vector <- ADEL13_SFg2$player2
ADEL13_SFg3 <- ADEL13_SFg2
ADEL13_SFg3$p1inp2vec <- is.element(ADEL13_SFg3$player1, player2vector)
ADEL13_SFg3$p2inp1vec <- is.element(ADEL13_SFg3$player2, player1vector)
addPlayer1 <- ADEL13_SFg3[ which(ADEL13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_SFg3[ which(ADEL13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_SFg2 <- rbind(ADEL13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
ADEL13_SFft <- ftable(ADEL13_SFg2$player1, ADEL13_SFg2$player2)
ADEL13_SFft2 <- as.matrix(ADEL13_SFft)
numRows <- nrow(ADEL13_SFft2)
numCols <- ncol(ADEL13_SFft2)
ADEL13_SFft3 <- ADEL13_SFft2[c(2:numRows) , c(2:numCols)]
ADEL13_SFTable <- graph.adjacency(ADEL13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(ADEL13_SFTable, vertex.label = V(ADEL13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
ADEL13_SF.clusterCoef <- transitivity(ADEL13_SFTable, type="global") #cluster coefficient
ADEL13_SF.degreeCent <- centralization.degree(ADEL13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_SFftn <- as.network.matrix(ADEL13_SFft)
ADEL13_SF.netDensity <- network.density(ADEL13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_SF.entropy <- entropy(ADEL13_SFft) #entropy
ADEL13_SF.netMx <- cbind(ADEL13_SF.netMx, ADEL13_SF.clusterCoef, ADEL13_SF.degreeCent$centralization,
ADEL13_SF.netDensity, ADEL13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "ADEL"
KIoutcome = "Turnover_F"
ADEL13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
ADEL13_TFg2 <- data.frame(ADEL13_TF)
ADEL13_TFg2 <- ADEL13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_TFg2$player1
player2vector <- ADEL13_TFg2$player2
ADEL13_TFg3 <- ADEL13_TFg2
ADEL13_TFg3$p1inp2vec <- is.element(ADEL13_TFg3$player1, player2vector)
ADEL13_TFg3$p2inp1vec <- is.element(ADEL13_TFg3$player2, player1vector)
addPlayer1 <- ADEL13_TFg3[ which(ADEL13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_TFg3[ which(ADEL13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_TFg2 <- rbind(ADEL13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
ADEL13_TFft <- ftable(ADEL13_TFg2$player1, ADEL13_TFg2$player2)
ADEL13_TFft2 <- as.matrix(ADEL13_TFft)
numRows <- nrow(ADEL13_TFft2)
numCols <- ncol(ADEL13_TFft2)
ADEL13_TFft3 <- ADEL13_TFft2[c(2:numRows) , c(2:numCols)]
ADEL13_TFTable <- graph.adjacency(ADEL13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(ADEL13_TFTable, vertex.label = V(ADEL13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
ADEL13_TF.clusterCoef <- transitivity(ADEL13_TFTable, type="global") #cluster coefficient
ADEL13_TF.degreeCent <- centralization.degree(ADEL13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_TFftn <- as.network.matrix(ADEL13_TFft)
ADEL13_TF.netDensity <- network.density(ADEL13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_TF.entropy <- entropy(ADEL13_TFft) #entropy
ADEL13_TF.netMx <- cbind(ADEL13_TF.netMx, ADEL13_TF.clusterCoef, ADEL13_TF.degreeCent$centralization,
ADEL13_TF.netDensity, ADEL13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
round = 13
teamName = "ADEL"
KIoutcome = "Stoppage_AM"
ADEL13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
ADEL13_SAMg2 <- data.frame(ADEL13_SAM)
ADEL13_SAMg2 <- ADEL13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_SAMg2$player1
player2vector <- ADEL13_SAMg2$player2
ADEL13_SAMg3 <- ADEL13_SAMg2
ADEL13_SAMg3$p1inp2vec <- is.element(ADEL13_SAMg3$player1, player2vector)
ADEL13_SAMg3$p2inp1vec <- is.element(ADEL13_SAMg3$player2, player1vector)
addPlayer1 <- ADEL13_SAMg3[ which(ADEL13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_SAMg3[ which(ADEL13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_SAMg2 <- rbind(ADEL13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
ADEL13_SAMft <- ftable(ADEL13_SAMg2$player1, ADEL13_SAMg2$player2)
ADEL13_SAMft2 <- as.matrix(ADEL13_SAMft)
numRows <- nrow(ADEL13_SAMft2)
numCols <- ncol(ADEL13_SAMft2)
ADEL13_SAMft3 <- ADEL13_SAMft2[c(2:numRows) , c(2:numCols)]
ADEL13_SAMTable <- graph.adjacency(ADEL13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(ADEL13_SAMTable, vertex.label = V(ADEL13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
ADEL13_SAM.clusterCoef <- transitivity(ADEL13_SAMTable, type="global") #cluster coefficient
ADEL13_SAM.degreeCent <- centralization.degree(ADEL13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_SAMftn <- as.network.matrix(ADEL13_SAMft)
ADEL13_SAM.netDensity <- network.density(ADEL13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_SAM.entropy <- entropy(ADEL13_SAMft) #entropy
ADEL13_SAM.netMx <- cbind(ADEL13_SAM.netMx, ADEL13_SAM.clusterCoef, ADEL13_SAM.degreeCent$centralization,
ADEL13_SAM.netDensity, ADEL13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "ADEL"
KIoutcome = "Turnover_AM"
ADEL13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
ADEL13_TAMg2 <- data.frame(ADEL13_TAM)
ADEL13_TAMg2 <- ADEL13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_TAMg2$player1
player2vector <- ADEL13_TAMg2$player2
ADEL13_TAMg3 <- ADEL13_TAMg2
ADEL13_TAMg3$p1inp2vec <- is.element(ADEL13_TAMg3$player1, player2vector)
ADEL13_TAMg3$p2inp1vec <- is.element(ADEL13_TAMg3$player2, player1vector)
addPlayer1 <- ADEL13_TAMg3[ which(ADEL13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_TAMg3[ which(ADEL13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_TAMg2 <- rbind(ADEL13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
ADEL13_TAMft <- ftable(ADEL13_TAMg2$player1, ADEL13_TAMg2$player2)
ADEL13_TAMft2 <- as.matrix(ADEL13_TAMft)
numRows <- nrow(ADEL13_TAMft2)
numCols <- ncol(ADEL13_TAMft2)
ADEL13_TAMft3 <- ADEL13_TAMft2[c(2:numRows) , c(2:numCols)]
ADEL13_TAMTable <- graph.adjacency(ADEL13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(ADEL13_TAMTable, vertex.label = V(ADEL13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
ADEL13_TAM.clusterCoef <- transitivity(ADEL13_TAMTable, type="global") #cluster coefficient
ADEL13_TAM.degreeCent <- centralization.degree(ADEL13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_TAMftn <- as.network.matrix(ADEL13_TAMft)
ADEL13_TAM.netDensity <- network.density(ADEL13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_TAM.entropy <- entropy(ADEL13_TAMft) #entropy
ADEL13_TAM.netMx <- cbind(ADEL13_TAM.netMx, ADEL13_TAM.clusterCoef, ADEL13_TAM.degreeCent$centralization,
ADEL13_TAM.netDensity, ADEL13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
#NA
round = 13
teamName = "ADEL"
KIoutcome = "Stoppage_DM"
ADEL13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
ADEL13_SDMg2 <- data.frame(ADEL13_SDM)
ADEL13_SDMg2 <- ADEL13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_SDMg2$player1
player2vector <- ADEL13_SDMg2$player2
ADEL13_SDMg3 <- ADEL13_SDMg2
ADEL13_SDMg3$p1inp2vec <- is.element(ADEL13_SDMg3$player1, player2vector)
ADEL13_SDMg3$p2inp1vec <- is.element(ADEL13_SDMg3$player2, player1vector)
addPlayer1 <- ADEL13_SDMg3[ which(ADEL13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_SDMg3[ which(ADEL13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_SDMg2 <- rbind(ADEL13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
ADEL13_SDMft <- ftable(ADEL13_SDMg2$player1, ADEL13_SDMg2$player2)
ADEL13_SDMft2 <- as.matrix(ADEL13_SDMft)
numRows <- nrow(ADEL13_SDMft2)
numCols <- ncol(ADEL13_SDMft2)
ADEL13_SDMft3 <- ADEL13_SDMft2[c(2:numRows) , c(2:numCols)]
ADEL13_SDMTable <- graph.adjacency(ADEL13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(ADEL13_SDMTable, vertex.label = V(ADEL13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
ADEL13_SDM.clusterCoef <- transitivity(ADEL13_SDMTable, type="global") #cluster coefficient
ADEL13_SDM.degreeCent <- centralization.degree(ADEL13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_SDMftn <- as.network.matrix(ADEL13_SDMft)
ADEL13_SDM.netDensity <- network.density(ADEL13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_SDM.entropy <- entropy(ADEL13_SDMft) #entropy
ADEL13_SDM.netMx <- cbind(ADEL13_SDM.netMx, ADEL13_SDM.clusterCoef, ADEL13_SDM.degreeCent$centralization,
ADEL13_SDM.netDensity, ADEL13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "ADEL"
KIoutcome = "Turnover_DM"
ADEL13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
ADEL13_TDMg2 <- data.frame(ADEL13_TDM)
ADEL13_TDMg2 <- ADEL13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_TDMg2$player1
player2vector <- ADEL13_TDMg2$player2
ADEL13_TDMg3 <- ADEL13_TDMg2
ADEL13_TDMg3$p1inp2vec <- is.element(ADEL13_TDMg3$player1, player2vector)
ADEL13_TDMg3$p2inp1vec <- is.element(ADEL13_TDMg3$player2, player1vector)
addPlayer1 <- ADEL13_TDMg3[ which(ADEL13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, empty, zero)
addPlayer2 <- ADEL13_TDMg3[ which(ADEL13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_TDMg2 <- rbind(ADEL13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
ADEL13_TDMft <- ftable(ADEL13_TDMg2$player1, ADEL13_TDMg2$player2)
ADEL13_TDMft2 <- as.matrix(ADEL13_TDMft)
numRows <- nrow(ADEL13_TDMft2)
numCols <- ncol(ADEL13_TDMft2)
ADEL13_TDMft3 <- ADEL13_TDMft2[c(2:numRows) , c(2:numCols)]
ADEL13_TDMTable <- graph.adjacency(ADEL13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(ADEL13_TDMTable, vertex.label = V(ADEL13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
ADEL13_TDM.clusterCoef <- transitivity(ADEL13_TDMTable, type="global") #cluster coefficient
ADEL13_TDM.degreeCent <- centralization.degree(ADEL13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_TDMftn <- as.network.matrix(ADEL13_TDMft)
ADEL13_TDM.netDensity <- network.density(ADEL13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_TDM.entropy <- entropy(ADEL13_TDMft) #entropy
ADEL13_TDM.netMx <- cbind(ADEL13_TDM.netMx, ADEL13_TDM.clusterCoef, ADEL13_TDM.degreeCent$centralization,
ADEL13_TDM.netDensity, ADEL13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "ADEL"
KIoutcome = "Stoppage_D"
ADEL13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
ADEL13_SDg2 <- data.frame(ADEL13_SD)
ADEL13_SDg2 <- ADEL13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_SDg2$player1
player2vector <- ADEL13_SDg2$player2
ADEL13_SDg3 <- ADEL13_SDg2
ADEL13_SDg3$p1inp2vec <- is.element(ADEL13_SDg3$player1, player2vector)
ADEL13_SDg3$p2inp1vec <- is.element(ADEL13_SDg3$player2, player1vector)
addPlayer1 <- ADEL13_SDg3[ which(ADEL13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_SDg3[ which(ADEL13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_SDg2 <- rbind(ADEL13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
ADEL13_SDft <- ftable(ADEL13_SDg2$player1, ADEL13_SDg2$player2)
ADEL13_SDft2 <- as.matrix(ADEL13_SDft)
numRows <- nrow(ADEL13_SDft2)
numCols <- ncol(ADEL13_SDft2)
ADEL13_SDft3 <- ADEL13_SDft2[c(2:numRows) , c(2:numCols)]
ADEL13_SDTable <- graph.adjacency(ADEL13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(ADEL13_SDTable, vertex.label = V(ADEL13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
ADEL13_SD.clusterCoef <- transitivity(ADEL13_SDTable, type="global") #cluster coefficient
ADEL13_SD.degreeCent <- centralization.degree(ADEL13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_SDftn <- as.network.matrix(ADEL13_SDft)
ADEL13_SD.netDensity <- network.density(ADEL13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_SD.entropy <- entropy(ADEL13_SDft) #entropy
ADEL13_SD.netMx <- cbind(ADEL13_SD.netMx, ADEL13_SD.clusterCoef, ADEL13_SD.degreeCent$centralization,
ADEL13_SD.netDensity, ADEL13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "ADEL"
KIoutcome = "Turnover_D"
ADEL13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
ADEL13_TDg2 <- data.frame(ADEL13_TD)
ADEL13_TDg2 <- ADEL13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_TDg2$player1
player2vector <- ADEL13_TDg2$player2
ADEL13_TDg3 <- ADEL13_TDg2
ADEL13_TDg3$p1inp2vec <- is.element(ADEL13_TDg3$player1, player2vector)
ADEL13_TDg3$p2inp1vec <- is.element(ADEL13_TDg3$player2, player1vector)
addPlayer1 <- ADEL13_TDg3[ which(ADEL13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_TDg3[ which(ADEL13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_TDg2 <- rbind(ADEL13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
ADEL13_TDft <- ftable(ADEL13_TDg2$player1, ADEL13_TDg2$player2)
ADEL13_TDft2 <- as.matrix(ADEL13_TDft)
numRows <- nrow(ADEL13_TDft2)
numCols <- ncol(ADEL13_TDft2)
ADEL13_TDft3 <- ADEL13_TDft2[c(2:numRows) , c(2:numCols)]
ADEL13_TDTable <- graph.adjacency(ADEL13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(ADEL13_TDTable, vertex.label = V(ADEL13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
ADEL13_TD.clusterCoef <- transitivity(ADEL13_TDTable, type="global") #cluster coefficient
ADEL13_TD.degreeCent <- centralization.degree(ADEL13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_TDftn <- as.network.matrix(ADEL13_TDft)
ADEL13_TD.netDensity <- network.density(ADEL13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_TD.entropy <- entropy(ADEL13_TDft) #entropy
ADEL13_TD.netMx <- cbind(ADEL13_TD.netMx, ADEL13_TD.clusterCoef, ADEL13_TD.degreeCent$centralization,
ADEL13_TD.netDensity, ADEL13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "ADEL"
KIoutcome = "End of Qtr_DM"
ADEL13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
ADEL13_QTg2 <- data.frame(ADEL13_QT)
ADEL13_QTg2 <- ADEL13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ADEL13_QTg2$player1
player2vector <- ADEL13_QTg2$player2
ADEL13_QTg3 <- ADEL13_QTg2
ADEL13_QTg3$p1inp2vec <- is.element(ADEL13_QTg3$player1, player2vector)
ADEL13_QTg3$p2inp1vec <- is.element(ADEL13_QTg3$player2, player1vector)
addPlayer1 <- ADEL13_QTg3[ which(ADEL13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ADEL13_QTg3[ which(ADEL13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ADEL13_QTg2 <- rbind(ADEL13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
ADEL13_QTft <- ftable(ADEL13_QTg2$player1, ADEL13_QTg2$player2)
ADEL13_QTft2 <- as.matrix(ADEL13_QTft)
numRows <- nrow(ADEL13_QTft2)
numCols <- ncol(ADEL13_QTft2)
ADEL13_QTft3 <- ADEL13_QTft2[c(2:numRows) , c(2:numCols)]
ADEL13_QTTable <- graph.adjacency(ADEL13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(ADEL13_QTTable, vertex.label = V(ADEL13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ADEL13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
ADEL13_QT.clusterCoef <- transitivity(ADEL13_QTTable, type="global") #cluster coefficient
ADEL13_QT.degreeCent <- centralization.degree(ADEL13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ADEL13_QTftn <- as.network.matrix(ADEL13_QTft)
ADEL13_QT.netDensity <- network.density(ADEL13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ADEL13_QT.entropy <- entropy(ADEL13_QTft) #entropy
ADEL13_QT.netMx <- cbind(ADEL13_QT.netMx, ADEL13_QT.clusterCoef, ADEL13_QT.degreeCent$centralization,
ADEL13_QT.netDensity, ADEL13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ADEL13_QT.netMx) <- varnames
#############################################################################
#BRISBANE
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "BL"
KIoutcome = "Goal_F"
BL13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
BL13_Gg2 <- data.frame(BL13_G)
BL13_Gg2 <- BL13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_Gg2$player1
player2vector <- BL13_Gg2$player2
BL13_Gg3 <- BL13_Gg2
BL13_Gg3$p1inp2vec <- is.element(BL13_Gg3$player1, player2vector)
BL13_Gg3$p2inp1vec <- is.element(BL13_Gg3$player2, player1vector)
addPlayer1 <- BL13_Gg3[ which(BL13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_Gg3[ which(BL13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_Gg2 <- rbind(BL13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
BL13_Gft <- ftable(BL13_Gg2$player1, BL13_Gg2$player2)
BL13_Gft2 <- as.matrix(BL13_Gft)
numRows <- nrow(BL13_Gft2)
numCols <- ncol(BL13_Gft2)
BL13_Gft3 <- BL13_Gft2[c(2:numRows) , c(2:numCols)]
BL13_GTable <- graph.adjacency(BL13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(BL13_GTable, vertex.label = V(BL13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
BL13_G.clusterCoef <- transitivity(BL13_GTable, type="global") #cluster coefficient
BL13_G.degreeCent <- centralization.degree(BL13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_Gftn <- as.network.matrix(BL13_Gft)
BL13_G.netDensity <- network.density(BL13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_G.entropy <- entropy(BL13_Gft) #entropy
BL13_G.netMx <- cbind(BL13_G.netMx, BL13_G.clusterCoef, BL13_G.degreeCent$centralization,
BL13_G.netDensity, BL13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
#NA
round = 13
teamName = "BL"
KIoutcome = "Behind_F"
BL13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
BL13_Bg2 <- data.frame(BL13_B)
BL13_Bg2 <- BL13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_Bg2$player1
player2vector <- BL13_Bg2$player2
BL13_Bg3 <- BL13_Bg2
BL13_Bg3$p1inp2vec <- is.element(BL13_Bg3$player1, player2vector)
BL13_Bg3$p2inp1vec <- is.element(BL13_Bg3$player2, player1vector)
addPlayer1 <- BL13_Bg3[ which(BL13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_Bg3[ which(BL13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_Bg2 <- rbind(BL13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
BL13_Bft <- ftable(BL13_Bg2$player1, BL13_Bg2$player2)
BL13_Bft2 <- as.matrix(BL13_Bft)
numRows <- nrow(BL13_Bft2)
numCols <- ncol(BL13_Bft2)
BL13_Bft3 <- BL13_Bft2[c(2:numRows) , c(2:numCols)]
BL13_BTable <- graph.adjacency(BL13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(BL13_BTable, vertex.label = V(BL13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
BL13_B.clusterCoef <- transitivity(BL13_BTable, type="global") #cluster coefficient
BL13_B.degreeCent <- centralization.degree(BL13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_Bftn <- as.network.matrix(BL13_Bft)
BL13_B.netDensity <- network.density(BL13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_B.entropy <- entropy(BL13_Bft) #entropy
BL13_B.netMx <- cbind(BL13_B.netMx, BL13_B.clusterCoef, BL13_B.degreeCent$centralization,
BL13_B.netDensity, BL13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "BL"
KIoutcome = "Stoppage_F"
BL13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
BL13_SFg2 <- data.frame(BL13_SF)
BL13_SFg2 <- BL13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_SFg2$player1
player2vector <- BL13_SFg2$player2
BL13_SFg3 <- BL13_SFg2
BL13_SFg3$p1inp2vec <- is.element(BL13_SFg3$player1, player2vector)
BL13_SFg3$p2inp1vec <- is.element(BL13_SFg3$player2, player1vector)
addPlayer1 <- BL13_SFg3[ which(BL13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_SFg3[ which(BL13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_SFg2 <- rbind(BL13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
BL13_SFft <- ftable(BL13_SFg2$player1, BL13_SFg2$player2)
BL13_SFft2 <- as.matrix(BL13_SFft)
numRows <- nrow(BL13_SFft2)
numCols <- ncol(BL13_SFft2)
BL13_SFft3 <- BL13_SFft2[c(2:numRows) , c(2:numCols)]
BL13_SFTable <- graph.adjacency(BL13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(BL13_SFTable, vertex.label = V(BL13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
BL13_SF.clusterCoef <- transitivity(BL13_SFTable, type="global") #cluster coefficient
BL13_SF.degreeCent <- centralization.degree(BL13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_SFftn <- as.network.matrix(BL13_SFft)
BL13_SF.netDensity <- network.density(BL13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_SF.entropy <- entropy(BL13_SFft) #entropy
BL13_SF.netMx <- cbind(BL13_SF.netMx, BL13_SF.clusterCoef, BL13_SF.degreeCent$centralization,
BL13_SF.netDensity, BL13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "BL"
KIoutcome = "Turnover_F"
BL13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
BL13_TFg2 <- data.frame(BL13_TF)
BL13_TFg2 <- BL13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_TFg2$player1
player2vector <- BL13_TFg2$player2
BL13_TFg3 <- BL13_TFg2
BL13_TFg3$p1inp2vec <- is.element(BL13_TFg3$player1, player2vector)
BL13_TFg3$p2inp1vec <- is.element(BL13_TFg3$player2, player1vector)
addPlayer1 <- BL13_TFg3[ which(BL13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_TFg3[ which(BL13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_TFg2 <- rbind(BL13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
BL13_TFft <- ftable(BL13_TFg2$player1, BL13_TFg2$player2)
BL13_TFft2 <- as.matrix(BL13_TFft)
numRows <- nrow(BL13_TFft2)
numCols <- ncol(BL13_TFft2)
BL13_TFft3 <- BL13_TFft2[c(2:numRows) , c(2:numCols)]
BL13_TFTable <- graph.adjacency(BL13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(BL13_TFTable, vertex.label = V(BL13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
BL13_TF.clusterCoef <- transitivity(BL13_TFTable, type="global") #cluster coefficient
BL13_TF.degreeCent <- centralization.degree(BL13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_TFftn <- as.network.matrix(BL13_TFft)
BL13_TF.netDensity <- network.density(BL13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_TF.entropy <- entropy(BL13_TFft) #entropy
BL13_TF.netMx <- cbind(BL13_TF.netMx, BL13_TF.clusterCoef, BL13_TF.degreeCent$centralization,
BL13_TF.netDensity, BL13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
round = 13
teamName = "BL"
KIoutcome = "Stoppage_AM"
BL13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
BL13_SAMg2 <- data.frame(BL13_SAM)
BL13_SAMg2 <- BL13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_SAMg2$player1
player2vector <- BL13_SAMg2$player2
BL13_SAMg3 <- BL13_SAMg2
BL13_SAMg3$p1inp2vec <- is.element(BL13_SAMg3$player1, player2vector)
BL13_SAMg3$p2inp1vec <- is.element(BL13_SAMg3$player2, player1vector)
addPlayer1 <- BL13_SAMg3[ which(BL13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_SAMg3[ which(BL13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_SAMg2 <- rbind(BL13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
BL13_SAMft <- ftable(BL13_SAMg2$player1, BL13_SAMg2$player2)
BL13_SAMft2 <- as.matrix(BL13_SAMft)
numRows <- nrow(BL13_SAMft2)
numCols <- ncol(BL13_SAMft2)
BL13_SAMft3 <- BL13_SAMft2[c(2:numRows) , c(2:numCols)]
BL13_SAMTable <- graph.adjacency(BL13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(BL13_SAMTable, vertex.label = V(BL13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
BL13_SAM.clusterCoef <- transitivity(BL13_SAMTable, type="global") #cluster coefficient
BL13_SAM.degreeCent <- centralization.degree(BL13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_SAMftn <- as.network.matrix(BL13_SAMft)
BL13_SAM.netDensity <- network.density(BL13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_SAM.entropy <- entropy(BL13_SAMft) #entropy
BL13_SAM.netMx <- cbind(BL13_SAM.netMx, BL13_SAM.clusterCoef, BL13_SAM.degreeCent$centralization,
BL13_SAM.netDensity, BL13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "BL"
KIoutcome = "Turnover_AM"
BL13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
BL13_TAMg2 <- data.frame(BL13_TAM)
BL13_TAMg2 <- BL13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_TAMg2$player1
player2vector <- BL13_TAMg2$player2
BL13_TAMg3 <- BL13_TAMg2
BL13_TAMg3$p1inp2vec <- is.element(BL13_TAMg3$player1, player2vector)
BL13_TAMg3$p2inp1vec <- is.element(BL13_TAMg3$player2, player1vector)
addPlayer1 <- BL13_TAMg3[ which(BL13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_TAMg3[ which(BL13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_TAMg2 <- rbind(BL13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
BL13_TAMft <- ftable(BL13_TAMg2$player1, BL13_TAMg2$player2)
BL13_TAMft2 <- as.matrix(BL13_TAMft)
numRows <- nrow(BL13_TAMft2)
numCols <- ncol(BL13_TAMft2)
BL13_TAMft3 <- BL13_TAMft2[c(2:numRows) , c(2:numCols)]
BL13_TAMTable <- graph.adjacency(BL13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(BL13_TAMTable, vertex.label = V(BL13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
BL13_TAM.clusterCoef <- transitivity(BL13_TAMTable, type="global") #cluster coefficient
BL13_TAM.degreeCent <- centralization.degree(BL13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_TAMftn <- as.network.matrix(BL13_TAMft)
BL13_TAM.netDensity <- network.density(BL13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_TAM.entropy <- entropy(BL13_TAMft) #entropy
BL13_TAM.netMx <- cbind(BL13_TAM.netMx, BL13_TAM.clusterCoef, BL13_TAM.degreeCent$centralization,
BL13_TAM.netDensity, BL13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "BL"
KIoutcome = "Stoppage_DM"
BL13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
BL13_SDMg2 <- data.frame(BL13_SDM)
BL13_SDMg2 <- BL13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_SDMg2$player1
player2vector <- BL13_SDMg2$player2
BL13_SDMg3 <- BL13_SDMg2
BL13_SDMg3$p1inp2vec <- is.element(BL13_SDMg3$player1, player2vector)
BL13_SDMg3$p2inp1vec <- is.element(BL13_SDMg3$player2, player1vector)
addPlayer1 <- BL13_SDMg3[ which(BL13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_SDMg3[ which(BL13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_SDMg2 <- rbind(BL13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
BL13_SDMft <- ftable(BL13_SDMg2$player1, BL13_SDMg2$player2)
BL13_SDMft2 <- as.matrix(BL13_SDMft)
numRows <- nrow(BL13_SDMft2)
numCols <- ncol(BL13_SDMft2)
BL13_SDMft3 <- BL13_SDMft2[c(2:numRows) , c(2:numCols)]
BL13_SDMTable <- graph.adjacency(BL13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(BL13_SDMTable, vertex.label = V(BL13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
BL13_SDM.clusterCoef <- transitivity(BL13_SDMTable, type="global") #cluster coefficient
BL13_SDM.degreeCent <- centralization.degree(BL13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_SDMftn <- as.network.matrix(BL13_SDMft)
BL13_SDM.netDensity <- network.density(BL13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_SDM.entropy <- entropy(BL13_SDMft) #entropy
BL13_SDM.netMx <- cbind(BL13_SDM.netMx, BL13_SDM.clusterCoef, BL13_SDM.degreeCent$centralization,
BL13_SDM.netDensity, BL13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "BL"
KIoutcome = "Turnover_DM"
BL13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
BL13_TDMg2 <- data.frame(BL13_TDM)
BL13_TDMg2 <- BL13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_TDMg2$player1
player2vector <- BL13_TDMg2$player2
BL13_TDMg3 <- BL13_TDMg2
BL13_TDMg3$p1inp2vec <- is.element(BL13_TDMg3$player1, player2vector)
BL13_TDMg3$p2inp1vec <- is.element(BL13_TDMg3$player2, player1vector)
addPlayer1 <- BL13_TDMg3[ which(BL13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_TDMg3[ which(BL13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_TDMg2 <- rbind(BL13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
BL13_TDMft <- ftable(BL13_TDMg2$player1, BL13_TDMg2$player2)
BL13_TDMft2 <- as.matrix(BL13_TDMft)
numRows <- nrow(BL13_TDMft2)
numCols <- ncol(BL13_TDMft2)
BL13_TDMft3 <- BL13_TDMft2[c(2:numRows) , c(2:numCols)]
BL13_TDMTable <- graph.adjacency(BL13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(BL13_TDMTable, vertex.label = V(BL13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
BL13_TDM.clusterCoef <- transitivity(BL13_TDMTable, type="global") #cluster coefficient
BL13_TDM.degreeCent <- centralization.degree(BL13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_TDMftn <- as.network.matrix(BL13_TDMft)
BL13_TDM.netDensity <- network.density(BL13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_TDM.entropy <- entropy(BL13_TDMft) #entropy
BL13_TDM.netMx <- cbind(BL13_TDM.netMx, BL13_TDM.clusterCoef, BL13_TDM.degreeCent$centralization,
BL13_TDM.netDensity, BL13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "BL"
KIoutcome = "Stoppage_D"
BL13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
BL13_SDg2 <- data.frame(BL13_SD)
BL13_SDg2 <- BL13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_SDg2$player1
player2vector <- BL13_SDg2$player2
BL13_SDg3 <- BL13_SDg2
BL13_SDg3$p1inp2vec <- is.element(BL13_SDg3$player1, player2vector)
BL13_SDg3$p2inp1vec <- is.element(BL13_SDg3$player2, player1vector)
addPlayer1 <- BL13_SDg3[ which(BL13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_SDg3[ which(BL13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_SDg2 <- rbind(BL13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
BL13_SDft <- ftable(BL13_SDg2$player1, BL13_SDg2$player2)
BL13_SDft2 <- as.matrix(BL13_SDft)
numRows <- nrow(BL13_SDft2)
numCols <- ncol(BL13_SDft2)
BL13_SDft3 <- BL13_SDft2[c(2:numRows) , c(2:numCols)]
BL13_SDTable <- graph.adjacency(BL13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(BL13_SDTable, vertex.label = V(BL13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
BL13_SD.clusterCoef <- transitivity(BL13_SDTable, type="global") #cluster coefficient
BL13_SD.degreeCent <- centralization.degree(BL13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_SDftn <- as.network.matrix(BL13_SDft)
BL13_SD.netDensity <- network.density(BL13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_SD.entropy <- entropy(BL13_SDft) #entropy
BL13_SD.netMx <- cbind(BL13_SD.netMx, BL13_SD.clusterCoef, BL13_SD.degreeCent$centralization,
BL13_SD.netDensity, BL13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "BL"
KIoutcome = "Turnover_D"
BL13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
BL13_TDg2 <- data.frame(BL13_TD)
BL13_TDg2 <- BL13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_TDg2$player1
player2vector <- BL13_TDg2$player2
BL13_TDg3 <- BL13_TDg2
BL13_TDg3$p1inp2vec <- is.element(BL13_TDg3$player1, player2vector)
BL13_TDg3$p2inp1vec <- is.element(BL13_TDg3$player2, player1vector)
addPlayer1 <- BL13_TDg3[ which(BL13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_TDg3[ which(BL13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_TDg2 <- rbind(BL13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
BL13_TDft <- ftable(BL13_TDg2$player1, BL13_TDg2$player2)
BL13_TDft2 <- as.matrix(BL13_TDft)
numRows <- nrow(BL13_TDft2)
numCols <- ncol(BL13_TDft2)
BL13_TDft3 <- BL13_TDft2[c(2:numRows) , c(2:numCols)]
BL13_TDTable <- graph.adjacency(BL13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(BL13_TDTable, vertex.label = V(BL13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
BL13_TD.clusterCoef <- transitivity(BL13_TDTable, type="global") #cluster coefficient
BL13_TD.degreeCent <- centralization.degree(BL13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_TDftn <- as.network.matrix(BL13_TDft)
BL13_TD.netDensity <- network.density(BL13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_TD.entropy <- entropy(BL13_TDft) #entropy
BL13_TD.netMx <- cbind(BL13_TD.netMx, BL13_TD.clusterCoef, BL13_TD.degreeCent$centralization,
BL13_TD.netDensity, BL13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "BL"
KIoutcome = "End of Qtr_DM"
BL13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
BL13_QTg2 <- data.frame(BL13_QT)
BL13_QTg2 <- BL13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- BL13_QTg2$player1
player2vector <- BL13_QTg2$player2
BL13_QTg3 <- BL13_QTg2
BL13_QTg3$p1inp2vec <- is.element(BL13_QTg3$player1, player2vector)
BL13_QTg3$p2inp1vec <- is.element(BL13_QTg3$player2, player1vector)
addPlayer1 <- BL13_QTg3[ which(BL13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- BL13_QTg3[ which(BL13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
BL13_QTg2 <- rbind(BL13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
BL13_QTft <- ftable(BL13_QTg2$player1, BL13_QTg2$player2)
BL13_QTft2 <- as.matrix(BL13_QTft)
numRows <- nrow(BL13_QTft2)
numCols <- ncol(BL13_QTft2)
BL13_QTft3 <- BL13_QTft2[c(2:numRows) , c(2:numCols)]
BL13_QTTable <- graph.adjacency(BL13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(BL13_QTTable, vertex.label = V(BL13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(BL13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
BL13_QT.clusterCoef <- transitivity(BL13_QTTable, type="global") #cluster coefficient
BL13_QT.degreeCent <- centralization.degree(BL13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
BL13_QTftn <- as.network.matrix(BL13_QTft)
BL13_QT.netDensity <- network.density(BL13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
BL13_QT.entropy <- entropy(BL13_QTft) #entropy
BL13_QT.netMx <- cbind(BL13_QT.netMx, BL13_QT.clusterCoef, BL13_QT.degreeCent$centralization,
BL13_QT.netDensity, BL13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(BL13_QT.netMx) <- varnames
#############################################################################
#CARLTON
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
round = 13
teamName = "CARL"
KIoutcome = "Goal_F"
CARL13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
CARL13_Gg2 <- data.frame(CARL13_G)
CARL13_Gg2 <- CARL13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_Gg2$player1
player2vector <- CARL13_Gg2$player2
CARL13_Gg3 <- CARL13_Gg2
CARL13_Gg3$p1inp2vec <- is.element(CARL13_Gg3$player1, player2vector)
CARL13_Gg3$p2inp1vec <- is.element(CARL13_Gg3$player2, player1vector)
addPlayer1 <- CARL13_Gg3[ which(CARL13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_Gg3[ which(CARL13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_Gg2 <- rbind(CARL13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
CARL13_Gft <- ftable(CARL13_Gg2$player1, CARL13_Gg2$player2)
CARL13_Gft2 <- as.matrix(CARL13_Gft)
numRows <- nrow(CARL13_Gft2)
numCols <- ncol(CARL13_Gft2)
CARL13_Gft3 <- CARL13_Gft2[c(2:numRows) , c(2:numCols)]
CARL13_GTable <- graph.adjacency(CARL13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(CARL13_GTable, vertex.label = V(CARL13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
CARL13_G.clusterCoef <- transitivity(CARL13_GTable, type="global") #cluster coefficient
CARL13_G.degreeCent <- centralization.degree(CARL13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_Gftn <- as.network.matrix(CARL13_Gft)
CARL13_G.netDensity <- network.density(CARL13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_G.entropy <- entropy(CARL13_Gft) #entropy
CARL13_G.netMx <- cbind(CARL13_G.netMx, CARL13_G.clusterCoef, CARL13_G.degreeCent$centralization,
CARL13_G.netDensity, CARL13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
round = 13
teamName = "CARL"
KIoutcome = "Behind_F"
CARL13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
CARL13_Bg2 <- data.frame(CARL13_B)
CARL13_Bg2 <- CARL13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_Bg2$player1
player2vector <- CARL13_Bg2$player2
CARL13_Bg3 <- CARL13_Bg2
CARL13_Bg3$p1inp2vec <- is.element(CARL13_Bg3$player1, player2vector)
CARL13_Bg3$p2inp1vec <- is.element(CARL13_Bg3$player2, player1vector)
addPlayer1 <- CARL13_Bg3[ which(CARL13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, empty, zero)
addPlayer2 <- CARL13_Bg3[ which(CARL13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_Bg2 <- rbind(CARL13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
CARL13_Bft <- ftable(CARL13_Bg2$player1, CARL13_Bg2$player2)
CARL13_Bft2 <- as.matrix(CARL13_Bft)
numRows <- nrow(CARL13_Bft2)
numCols <- ncol(CARL13_Bft2)
CARL13_Bft3 <- CARL13_Bft2[c(2:numRows) , c(2:numCols)]
CARL13_BTable <- graph.adjacency(CARL13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(CARL13_BTable, vertex.label = V(CARL13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
CARL13_B.clusterCoef <- transitivity(CARL13_BTable, type="global") #cluster coefficient
CARL13_B.degreeCent <- centralization.degree(CARL13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_Bftn <- as.network.matrix(CARL13_Bft)
CARL13_B.netDensity <- network.density(CARL13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_B.entropy <- entropy(CARL13_Bft) #entropy
CARL13_B.netMx <- cbind(CARL13_B.netMx, CARL13_B.clusterCoef, CARL13_B.degreeCent$centralization,
CARL13_B.netDensity, CARL13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
round = 13
teamName = "CARL"
KIoutcome = "Stoppage_F"
CARL13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
CARL13_SFg2 <- data.frame(CARL13_SF)
CARL13_SFg2 <- CARL13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_SFg2$player1
player2vector <- CARL13_SFg2$player2
CARL13_SFg3 <- CARL13_SFg2
CARL13_SFg3$p1inp2vec <- is.element(CARL13_SFg3$player1, player2vector)
CARL13_SFg3$p2inp1vec <- is.element(CARL13_SFg3$player2, player1vector)
addPlayer1 <- CARL13_SFg3[ which(CARL13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_SFg3[ which(CARL13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_SFg2 <- rbind(CARL13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
CARL13_SFft <- ftable(CARL13_SFg2$player1, CARL13_SFg2$player2)
CARL13_SFft2 <- as.matrix(CARL13_SFft)
numRows <- nrow(CARL13_SFft2)
numCols <- ncol(CARL13_SFft2)
CARL13_SFft3 <- CARL13_SFft2[c(2:numRows) , c(2:numCols)]
CARL13_SFTable <- graph.adjacency(CARL13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(CARL13_SFTable, vertex.label = V(CARL13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
CARL13_SF.clusterCoef <- transitivity(CARL13_SFTable, type="global") #cluster coefficient
CARL13_SF.degreeCent <- centralization.degree(CARL13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_SFftn <- as.network.matrix(CARL13_SFft)
CARL13_SF.netDensity <- network.density(CARL13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_SF.entropy <- entropy(CARL13_SFft) #entropy
CARL13_SF.netMx <- cbind(CARL13_SF.netMx, CARL13_SF.clusterCoef, CARL13_SF.degreeCent$centralization,
CARL13_SF.netDensity, CARL13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
#NA
round = 13
teamName = "CARL"
KIoutcome = "Turnover_F"
CARL13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
CARL13_TFg2 <- data.frame(CARL13_TF)
CARL13_TFg2 <- CARL13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_TFg2$player1
player2vector <- CARL13_TFg2$player2
CARL13_TFg3 <- CARL13_TFg2
CARL13_TFg3$p1inp2vec <- is.element(CARL13_TFg3$player1, player2vector)
CARL13_TFg3$p2inp1vec <- is.element(CARL13_TFg3$player2, player1vector)
addPlayer1 <- CARL13_TFg3[ which(CARL13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_TFg3[ which(CARL13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_TFg2 <- rbind(CARL13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
CARL13_TFft <- ftable(CARL13_TFg2$player1, CARL13_TFg2$player2)
CARL13_TFft2 <- as.matrix(CARL13_TFft)
numRows <- nrow(CARL13_TFft2)
numCols <- ncol(CARL13_TFft2)
CARL13_TFft3 <- CARL13_TFft2[c(2:numRows) , c(2:numCols)]
CARL13_TFTable <- graph.adjacency(CARL13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(CARL13_TFTable, vertex.label = V(CARL13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
CARL13_TF.clusterCoef <- transitivity(CARL13_TFTable, type="global") #cluster coefficient
CARL13_TF.degreeCent <- centralization.degree(CARL13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_TFftn <- as.network.matrix(CARL13_TFft)
CARL13_TF.netDensity <- network.density(CARL13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_TF.entropy <- entropy(CARL13_TFft) #entropy
CARL13_TF.netMx <- cbind(CARL13_TF.netMx, CARL13_TF.clusterCoef, CARL13_TF.degreeCent$centralization,
CARL13_TF.netDensity, CARL13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
round = 13
teamName = "CARL"
KIoutcome = "Stoppage_AM"
CARL13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
CARL13_SAMg2 <- data.frame(CARL13_SAM)
CARL13_SAMg2 <- CARL13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_SAMg2$player1
player2vector <- CARL13_SAMg2$player2
CARL13_SAMg3 <- CARL13_SAMg2
CARL13_SAMg3$p1inp2vec <- is.element(CARL13_SAMg3$player1, player2vector)
CARL13_SAMg3$p2inp1vec <- is.element(CARL13_SAMg3$player2, player1vector)
addPlayer1 <- CARL13_SAMg3[ which(CARL13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_SAMg3[ which(CARL13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_SAMg2 <- rbind(CARL13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
CARL13_SAMft <- ftable(CARL13_SAMg2$player1, CARL13_SAMg2$player2)
CARL13_SAMft2 <- as.matrix(CARL13_SAMft)
numRows <- nrow(CARL13_SAMft2)
numCols <- ncol(CARL13_SAMft2)
CARL13_SAMft3 <- CARL13_SAMft2[c(2:numRows) , c(2:numCols)]
CARL13_SAMTable <- graph.adjacency(CARL13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(CARL13_SAMTable, vertex.label = V(CARL13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
CARL13_SAM.clusterCoef <- transitivity(CARL13_SAMTable, type="global") #cluster coefficient
CARL13_SAM.degreeCent <- centralization.degree(CARL13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_SAMftn <- as.network.matrix(CARL13_SAMft)
CARL13_SAM.netDensity <- network.density(CARL13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_SAM.entropy <- entropy(CARL13_SAMft) #entropy
CARL13_SAM.netMx <- cbind(CARL13_SAM.netMx, CARL13_SAM.clusterCoef, CARL13_SAM.degreeCent$centralization,
CARL13_SAM.netDensity, CARL13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "CARL"
KIoutcome = "Turnover_AM"
CARL13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
CARL13_TAMg2 <- data.frame(CARL13_TAM)
CARL13_TAMg2 <- CARL13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_TAMg2$player1
player2vector <- CARL13_TAMg2$player2
CARL13_TAMg3 <- CARL13_TAMg2
CARL13_TAMg3$p1inp2vec <- is.element(CARL13_TAMg3$player1, player2vector)
CARL13_TAMg3$p2inp1vec <- is.element(CARL13_TAMg3$player2, player1vector)
addPlayer1 <- CARL13_TAMg3[ which(CARL13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_TAMg3[ which(CARL13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(empty, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_TAMg2 <- rbind(CARL13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
CARL13_TAMft <- ftable(CARL13_TAMg2$player1, CARL13_TAMg2$player2)
CARL13_TAMft2 <- as.matrix(CARL13_TAMft)
numRows <- nrow(CARL13_TAMft2)
numCols <- ncol(CARL13_TAMft2)
CARL13_TAMft3 <- CARL13_TAMft2[c(2:numRows) , c(2:numCols)]
CARL13_TAMTable <- graph.adjacency(CARL13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(CARL13_TAMTable, vertex.label = V(CARL13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
CARL13_TAM.clusterCoef <- transitivity(CARL13_TAMTable, type="global") #cluster coefficient
CARL13_TAM.degreeCent <- centralization.degree(CARL13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_TAMftn <- as.network.matrix(CARL13_TAMft)
CARL13_TAM.netDensity <- network.density(CARL13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_TAM.entropy <- entropy(CARL13_TAMft) #entropy
CARL13_TAM.netMx <- cbind(CARL13_TAM.netMx, CARL13_TAM.clusterCoef, CARL13_TAM.degreeCent$centralization,
CARL13_TAM.netDensity, CARL13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "CARL"
KIoutcome = "Stoppage_DM"
CARL13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
CARL13_SDMg2 <- data.frame(CARL13_SDM)
CARL13_SDMg2 <- CARL13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_SDMg2$player1
player2vector <- CARL13_SDMg2$player2
CARL13_SDMg3 <- CARL13_SDMg2
CARL13_SDMg3$p1inp2vec <- is.element(CARL13_SDMg3$player1, player2vector)
CARL13_SDMg3$p2inp1vec <- is.element(CARL13_SDMg3$player2, player1vector)
addPlayer1 <- CARL13_SDMg3[ which(CARL13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_SDMg3[ which(CARL13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_SDMg2 <- rbind(CARL13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
CARL13_SDMft <- ftable(CARL13_SDMg2$player1, CARL13_SDMg2$player2)
CARL13_SDMft2 <- as.matrix(CARL13_SDMft)
numRows <- nrow(CARL13_SDMft2)
numCols <- ncol(CARL13_SDMft2)
CARL13_SDMft3 <- CARL13_SDMft2[c(2:numRows) , c(2:numCols)]
CARL13_SDMTable <- graph.adjacency(CARL13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(CARL13_SDMTable, vertex.label = V(CARL13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
CARL13_SDM.clusterCoef <- transitivity(CARL13_SDMTable, type="global") #cluster coefficient
CARL13_SDM.degreeCent <- centralization.degree(CARL13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_SDMftn <- as.network.matrix(CARL13_SDMft)
CARL13_SDM.netDensity <- network.density(CARL13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_SDM.entropy <- entropy(CARL13_SDMft) #entropy
CARL13_SDM.netMx <- cbind(CARL13_SDM.netMx, CARL13_SDM.clusterCoef, CARL13_SDM.degreeCent$centralization,
CARL13_SDM.netDensity, CARL13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "CARL"
KIoutcome = "Turnover_DM"
CARL13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
CARL13_TDMg2 <- data.frame(CARL13_TDM)
CARL13_TDMg2 <- CARL13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_TDMg2$player1
player2vector <- CARL13_TDMg2$player2
CARL13_TDMg3 <- CARL13_TDMg2
CARL13_TDMg3$p1inp2vec <- is.element(CARL13_TDMg3$player1, player2vector)
CARL13_TDMg3$p2inp1vec <- is.element(CARL13_TDMg3$player2, player1vector)
addPlayer1 <- CARL13_TDMg3[ which(CARL13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_TDMg3[ which(CARL13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_TDMg2 <- rbind(CARL13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
CARL13_TDMft <- ftable(CARL13_TDMg2$player1, CARL13_TDMg2$player2)
CARL13_TDMft2 <- as.matrix(CARL13_TDMft)
numRows <- nrow(CARL13_TDMft2)
numCols <- ncol(CARL13_TDMft2)
CARL13_TDMft3 <- CARL13_TDMft2[c(2:numRows) , c(2:numCols)]
CARL13_TDMTable <- graph.adjacency(CARL13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(CARL13_TDMTable, vertex.label = V(CARL13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
CARL13_TDM.clusterCoef <- transitivity(CARL13_TDMTable, type="global") #cluster coefficient
CARL13_TDM.degreeCent <- centralization.degree(CARL13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_TDMftn <- as.network.matrix(CARL13_TDMft)
CARL13_TDM.netDensity <- network.density(CARL13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_TDM.entropy <- entropy(CARL13_TDMft) #entropy
CARL13_TDM.netMx <- cbind(CARL13_TDM.netMx, CARL13_TDM.clusterCoef, CARL13_TDM.degreeCent$centralization,
CARL13_TDM.netDensity, CARL13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "CARL"
KIoutcome = "Stoppage_D"
CARL13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
CARL13_SDg2 <- data.frame(CARL13_SD)
CARL13_SDg2 <- CARL13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_SDg2$player1
player2vector <- CARL13_SDg2$player2
CARL13_SDg3 <- CARL13_SDg2
CARL13_SDg3$p1inp2vec <- is.element(CARL13_SDg3$player1, player2vector)
CARL13_SDg3$p2inp1vec <- is.element(CARL13_SDg3$player2, player1vector)
addPlayer1 <- CARL13_SDg3[ which(CARL13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_SDg3[ which(CARL13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_SDg2 <- rbind(CARL13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
CARL13_SDft <- ftable(CARL13_SDg2$player1, CARL13_SDg2$player2)
CARL13_SDft2 <- as.matrix(CARL13_SDft)
numRows <- nrow(CARL13_SDft2)
numCols <- ncol(CARL13_SDft2)
CARL13_SDft3 <- CARL13_SDft2[c(2:numRows) , c(2:numCols)]
CARL13_SDTable <- graph.adjacency(CARL13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(CARL13_SDTable, vertex.label = V(CARL13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
CARL13_SD.clusterCoef <- transitivity(CARL13_SDTable, type="global") #cluster coefficient
CARL13_SD.degreeCent <- centralization.degree(CARL13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_SDftn <- as.network.matrix(CARL13_SDft)
CARL13_SD.netDensity <- network.density(CARL13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_SD.entropy <- entropy(CARL13_SDft) #entropy
CARL13_SD.netMx <- cbind(CARL13_SD.netMx, CARL13_SD.clusterCoef, CARL13_SD.degreeCent$centralization,
CARL13_SD.netDensity, CARL13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "CARL"
KIoutcome = "Turnover_D"
CARL13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
CARL13_TDg2 <- data.frame(CARL13_TD)
CARL13_TDg2 <- CARL13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_TDg2$player1
player2vector <- CARL13_TDg2$player2
CARL13_TDg3 <- CARL13_TDg2
CARL13_TDg3$p1inp2vec <- is.element(CARL13_TDg3$player1, player2vector)
CARL13_TDg3$p2inp1vec <- is.element(CARL13_TDg3$player2, player1vector)
addPlayer1 <- CARL13_TDg3[ which(CARL13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_TDg3[ which(CARL13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_TDg2 <- rbind(CARL13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
CARL13_TDft <- ftable(CARL13_TDg2$player1, CARL13_TDg2$player2)
CARL13_TDft2 <- as.matrix(CARL13_TDft)
numRows <- nrow(CARL13_TDft2)
numCols <- ncol(CARL13_TDft2)
CARL13_TDft3 <- CARL13_TDft2[c(2:numRows) , c(2:numCols)]
CARL13_TDTable <- graph.adjacency(CARL13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(CARL13_TDTable, vertex.label = V(CARL13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
CARL13_TD.clusterCoef <- transitivity(CARL13_TDTable, type="global") #cluster coefficient
CARL13_TD.degreeCent <- centralization.degree(CARL13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_TDftn <- as.network.matrix(CARL13_TDft)
CARL13_TD.netDensity <- network.density(CARL13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_TD.entropy <- entropy(CARL13_TDft) #entropy
CARL13_TD.netMx <- cbind(CARL13_TD.netMx, CARL13_TD.clusterCoef, CARL13_TD.degreeCent$centralization,
CARL13_TD.netDensity, CARL13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
round = 13
teamName = "CARL"
KIoutcome = "End of Qtr_DM"
CARL13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
CARL13_QTg2 <- data.frame(CARL13_QT)
CARL13_QTg2 <- CARL13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- CARL13_QTg2$player1
player2vector <- CARL13_QTg2$player2
CARL13_QTg3 <- CARL13_QTg2
CARL13_QTg3$p1inp2vec <- is.element(CARL13_QTg3$player1, player2vector)
CARL13_QTg3$p2inp1vec <- is.element(CARL13_QTg3$player2, player1vector)
addPlayer1 <- CARL13_QTg3[ which(CARL13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- CARL13_QTg3[ which(CARL13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
CARL13_QTg2 <- rbind(CARL13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
CARL13_QTft <- ftable(CARL13_QTg2$player1, CARL13_QTg2$player2)
CARL13_QTft2 <- as.matrix(CARL13_QTft)
numRows <- nrow(CARL13_QTft2)
numCols <- ncol(CARL13_QTft2)
CARL13_QTft3 <- CARL13_QTft2[c(2:numRows) , c(2:numCols)]
CARL13_QTTable <- graph.adjacency(CARL13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(CARL13_QTTable, vertex.label = V(CARL13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(CARL13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
CARL13_QT.clusterCoef <- transitivity(CARL13_QTTable, type="global") #cluster coefficient
CARL13_QT.degreeCent <- centralization.degree(CARL13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
CARL13_QTftn <- as.network.matrix(CARL13_QTft)
CARL13_QT.netDensity <- network.density(CARL13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
CARL13_QT.entropy <- entropy(CARL13_QTft) #entropy
CARL13_QT.netMx <- cbind(CARL13_QT.netMx, CARL13_QT.clusterCoef, CARL13_QT.degreeCent$centralization,
CARL13_QT.netDensity, CARL13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(CARL13_QT.netMx) <- varnames
#############################################################################
#COLLINGWOOD
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "COLL"
KIoutcome = "Goal_F"
COLL13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
COLL13_Gg2 <- data.frame(COLL13_G)
COLL13_Gg2 <- COLL13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_Gg2$player1
player2vector <- COLL13_Gg2$player2
COLL13_Gg3 <- COLL13_Gg2
COLL13_Gg3$p1inp2vec <- is.element(COLL13_Gg3$player1, player2vector)
COLL13_Gg3$p2inp1vec <- is.element(COLL13_Gg3$player2, player1vector)
addPlayer1 <- COLL13_Gg3[ which(COLL13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_Gg3[ which(COLL13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_Gg2 <- rbind(COLL13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
COLL13_Gft <- ftable(COLL13_Gg2$player1, COLL13_Gg2$player2)
COLL13_Gft2 <- as.matrix(COLL13_Gft)
numRows <- nrow(COLL13_Gft2)
numCols <- ncol(COLL13_Gft2)
COLL13_Gft3 <- COLL13_Gft2[c(2:numRows) , c(2:numCols)]
COLL13_GTable <- graph.adjacency(COLL13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(COLL13_GTable, vertex.label = V(COLL13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
COLL13_G.clusterCoef <- transitivity(COLL13_GTable, type="global") #cluster coefficient
COLL13_G.degreeCent <- centralization.degree(COLL13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_Gftn <- as.network.matrix(COLL13_Gft)
COLL13_G.netDensity <- network.density(COLL13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_G.entropy <- entropy(COLL13_Gft) #entropy
COLL13_G.netMx <- cbind(COLL13_G.netMx, COLL13_G.clusterCoef, COLL13_G.degreeCent$centralization,
COLL13_G.netDensity, COLL13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
#NA
round = 13
teamName = "COLL"
KIoutcome = "Behind_F"
COLL13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
COLL13_Bg2 <- data.frame(COLL13_B)
COLL13_Bg2 <- COLL13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_Bg2$player1
player2vector <- COLL13_Bg2$player2
COLL13_Bg3 <- COLL13_Bg2
COLL13_Bg3$p1inp2vec <- is.element(COLL13_Bg3$player1, player2vector)
COLL13_Bg3$p2inp1vec <- is.element(COLL13_Bg3$player2, player1vector)
addPlayer1 <- COLL13_Bg3[ which(COLL13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_Bg3[ which(COLL13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_Bg2 <- rbind(COLL13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
COLL13_Bft <- ftable(COLL13_Bg2$player1, COLL13_Bg2$player2)
COLL13_Bft2 <- as.matrix(COLL13_Bft)
numRows <- nrow(COLL13_Bft2)
numCols <- ncol(COLL13_Bft2)
COLL13_Bft3 <- COLL13_Bft2[c(2:numRows) , c(2:numCols)]
COLL13_BTable <- graph.adjacency(COLL13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(COLL13_BTable, vertex.label = V(COLL13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
COLL13_B.clusterCoef <- transitivity(COLL13_BTable, type="global") #cluster coefficient
COLL13_B.degreeCent <- centralization.degree(COLL13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_Bftn <- as.network.matrix(COLL13_Bft)
COLL13_B.netDensity <- network.density(COLL13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_B.entropy <- entropy(COLL13_Bft) #entropy
COLL13_B.netMx <- cbind(COLL13_B.netMx, COLL13_B.clusterCoef, COLL13_B.degreeCent$centralization,
COLL13_B.netDensity, COLL13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
round = 13
teamName = "COLL"
KIoutcome = "Stoppage_F"
COLL13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
COLL13_SFg2 <- data.frame(COLL13_SF)
COLL13_SFg2 <- COLL13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_SFg2$player1
player2vector <- COLL13_SFg2$player2
COLL13_SFg3 <- COLL13_SFg2
COLL13_SFg3$p1inp2vec <- is.element(COLL13_SFg3$player1, player2vector)
COLL13_SFg3$p2inp1vec <- is.element(COLL13_SFg3$player2, player1vector)
addPlayer1 <- COLL13_SFg3[ which(COLL13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_SFg3[ which(COLL13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_SFg2 <- rbind(COLL13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
COLL13_SFft <- ftable(COLL13_SFg2$player1, COLL13_SFg2$player2)
COLL13_SFft2 <- as.matrix(COLL13_SFft)
numRows <- nrow(COLL13_SFft2)
numCols <- ncol(COLL13_SFft2)
COLL13_SFft3 <- COLL13_SFft2[c(2:numRows) , c(2:numCols)]
COLL13_SFTable <- graph.adjacency(COLL13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(COLL13_SFTable, vertex.label = V(COLL13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
COLL13_SF.clusterCoef <- transitivity(COLL13_SFTable, type="global") #cluster coefficient
COLL13_SF.degreeCent <- centralization.degree(COLL13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_SFftn <- as.network.matrix(COLL13_SFft)
COLL13_SF.netDensity <- network.density(COLL13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_SF.entropy <- entropy(COLL13_SFft) #entropy
COLL13_SF.netMx <- cbind(COLL13_SF.netMx, COLL13_SF.clusterCoef, COLL13_SF.degreeCent$centralization,
COLL13_SF.netDensity, COLL13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "COLL"
KIoutcome = "Turnover_F"
COLL13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
COLL13_TFg2 <- data.frame(COLL13_TF)
COLL13_TFg2 <- COLL13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_TFg2$player1
player2vector <- COLL13_TFg2$player2
COLL13_TFg3 <- COLL13_TFg2
COLL13_TFg3$p1inp2vec <- is.element(COLL13_TFg3$player1, player2vector)
COLL13_TFg3$p2inp1vec <- is.element(COLL13_TFg3$player2, player1vector)
addPlayer1 <- COLL13_TFg3[ which(COLL13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_TFg3[ which(COLL13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_TFg2 <- rbind(COLL13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
COLL13_TFft <- ftable(COLL13_TFg2$player1, COLL13_TFg2$player2)
COLL13_TFft2 <- as.matrix(COLL13_TFft)
numRows <- nrow(COLL13_TFft2)
numCols <- ncol(COLL13_TFft2)
COLL13_TFft3 <- COLL13_TFft2[c(2:numRows) , c(2:numCols)]
COLL13_TFTable <- graph.adjacency(COLL13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(COLL13_TFTable, vertex.label = V(COLL13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
COLL13_TF.clusterCoef <- transitivity(COLL13_TFTable, type="global") #cluster coefficient
COLL13_TF.degreeCent <- centralization.degree(COLL13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_TFftn <- as.network.matrix(COLL13_TFft)
COLL13_TF.netDensity <- network.density(COLL13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_TF.entropy <- entropy(COLL13_TFft) #entropy
COLL13_TF.netMx <- cbind(COLL13_TF.netMx, COLL13_TF.clusterCoef, COLL13_TF.degreeCent$centralization,
COLL13_TF.netDensity, COLL13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
#NA
round = 13
teamName = "COLL"
KIoutcome = "Stoppage_AM"
COLL13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
COLL13_SAMg2 <- data.frame(COLL13_SAM)
COLL13_SAMg2 <- COLL13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_SAMg2$player1
player2vector <- COLL13_SAMg2$player2
COLL13_SAMg3 <- COLL13_SAMg2
COLL13_SAMg3$p1inp2vec <- is.element(COLL13_SAMg3$player1, player2vector)
COLL13_SAMg3$p2inp1vec <- is.element(COLL13_SAMg3$player2, player1vector)
addPlayer1 <- COLL13_SAMg3[ which(COLL13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_SAMg3[ which(COLL13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_SAMg2 <- rbind(COLL13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
COLL13_SAMft <- ftable(COLL13_SAMg2$player1, COLL13_SAMg2$player2)
COLL13_SAMft2 <- as.matrix(COLL13_SAMft)
numRows <- nrow(COLL13_SAMft2)
numCols <- ncol(COLL13_SAMft2)
COLL13_SAMft3 <- COLL13_SAMft2[c(2:numRows) , c(2:numCols)]
COLL13_SAMTable <- graph.adjacency(COLL13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(COLL13_SAMTable, vertex.label = V(COLL13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
COLL13_SAM.clusterCoef <- transitivity(COLL13_SAMTable, type="global") #cluster coefficient
COLL13_SAM.degreeCent <- centralization.degree(COLL13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_SAMftn <- as.network.matrix(COLL13_SAMft)
COLL13_SAM.netDensity <- network.density(COLL13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_SAM.entropy <- entropy(COLL13_SAMft) #entropy
COLL13_SAM.netMx <- cbind(COLL13_SAM.netMx, COLL13_SAM.clusterCoef, COLL13_SAM.degreeCent$centralization,
COLL13_SAM.netDensity, COLL13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "COLL"
KIoutcome = "Turnover_AM"
COLL13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
COLL13_TAMg2 <- data.frame(COLL13_TAM)
COLL13_TAMg2 <- COLL13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_TAMg2$player1
player2vector <- COLL13_TAMg2$player2
COLL13_TAMg3 <- COLL13_TAMg2
COLL13_TAMg3$p1inp2vec <- is.element(COLL13_TAMg3$player1, player2vector)
COLL13_TAMg3$p2inp1vec <- is.element(COLL13_TAMg3$player2, player1vector)
addPlayer1 <- COLL13_TAMg3[ which(COLL13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_TAMg3[ which(COLL13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_TAMg2 <- rbind(COLL13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
COLL13_TAMft <- ftable(COLL13_TAMg2$player1, COLL13_TAMg2$player2)
COLL13_TAMft2 <- as.matrix(COLL13_TAMft)
numRows <- nrow(COLL13_TAMft2)
numCols <- ncol(COLL13_TAMft2)
COLL13_TAMft3 <- COLL13_TAMft2[c(2:numRows) , c(2:numCols)]
COLL13_TAMTable <- graph.adjacency(COLL13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(COLL13_TAMTable, vertex.label = V(COLL13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
COLL13_TAM.clusterCoef <- transitivity(COLL13_TAMTable, type="global") #cluster coefficient
COLL13_TAM.degreeCent <- centralization.degree(COLL13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_TAMftn <- as.network.matrix(COLL13_TAMft)
COLL13_TAM.netDensity <- network.density(COLL13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_TAM.entropy <- entropy(COLL13_TAMft) #entropy
COLL13_TAM.netMx <- cbind(COLL13_TAM.netMx, COLL13_TAM.clusterCoef, COLL13_TAM.degreeCent$centralization,
COLL13_TAM.netDensity, COLL13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "COLL"
KIoutcome = "Stoppage_DM"
COLL13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
COLL13_SDMg2 <- data.frame(COLL13_SDM)
COLL13_SDMg2 <- COLL13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_SDMg2$player1
player2vector <- COLL13_SDMg2$player2
COLL13_SDMg3 <- COLL13_SDMg2
COLL13_SDMg3$p1inp2vec <- is.element(COLL13_SDMg3$player1, player2vector)
COLL13_SDMg3$p2inp1vec <- is.element(COLL13_SDMg3$player2, player1vector)
addPlayer1 <- COLL13_SDMg3[ which(COLL13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_SDMg3[ which(COLL13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_SDMg2 <- rbind(COLL13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
COLL13_SDMft <- ftable(COLL13_SDMg2$player1, COLL13_SDMg2$player2)
COLL13_SDMft2 <- as.matrix(COLL13_SDMft)
numRows <- nrow(COLL13_SDMft2)
numCols <- ncol(COLL13_SDMft2)
COLL13_SDMft3 <- COLL13_SDMft2[c(2:numRows) , c(2:numCols)]
COLL13_SDMTable <- graph.adjacency(COLL13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(COLL13_SDMTable, vertex.label = V(COLL13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
COLL13_SDM.clusterCoef <- transitivity(COLL13_SDMTable, type="global") #cluster coefficient
COLL13_SDM.degreeCent <- centralization.degree(COLL13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_SDMftn <- as.network.matrix(COLL13_SDMft)
COLL13_SDM.netDensity <- network.density(COLL13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_SDM.entropy <- entropy(COLL13_SDMft) #entropy
COLL13_SDM.netMx <- cbind(COLL13_SDM.netMx, COLL13_SDM.clusterCoef, COLL13_SDM.degreeCent$centralization,
COLL13_SDM.netDensity, COLL13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "COLL"
KIoutcome = "Turnover_DM"
COLL13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
COLL13_TDMg2 <- data.frame(COLL13_TDM)
COLL13_TDMg2 <- COLL13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_TDMg2$player1
player2vector <- COLL13_TDMg2$player2
COLL13_TDMg3 <- COLL13_TDMg2
COLL13_TDMg3$p1inp2vec <- is.element(COLL13_TDMg3$player1, player2vector)
COLL13_TDMg3$p2inp1vec <- is.element(COLL13_TDMg3$player2, player1vector)
addPlayer1 <- COLL13_TDMg3[ which(COLL13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_TDMg3[ which(COLL13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_TDMg2 <- rbind(COLL13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
COLL13_TDMft <- ftable(COLL13_TDMg2$player1, COLL13_TDMg2$player2)
COLL13_TDMft2 <- as.matrix(COLL13_TDMft)
numRows <- nrow(COLL13_TDMft2)
numCols <- ncol(COLL13_TDMft2)
COLL13_TDMft3 <- COLL13_TDMft2[c(2:numRows) , c(2:numCols)]
COLL13_TDMTable <- graph.adjacency(COLL13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(COLL13_TDMTable, vertex.label = V(COLL13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
COLL13_TDM.clusterCoef <- transitivity(COLL13_TDMTable, type="global") #cluster coefficient
COLL13_TDM.degreeCent <- centralization.degree(COLL13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_TDMftn <- as.network.matrix(COLL13_TDMft)
COLL13_TDM.netDensity <- network.density(COLL13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_TDM.entropy <- entropy(COLL13_TDMft) #entropy
COLL13_TDM.netMx <- cbind(COLL13_TDM.netMx, COLL13_TDM.clusterCoef, COLL13_TDM.degreeCent$centralization,
COLL13_TDM.netDensity, COLL13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
round = 13
teamName = "COLL"
KIoutcome = "Stoppage_D"
COLL13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
COLL13_SDg2 <- data.frame(COLL13_SD)
COLL13_SDg2 <- COLL13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_SDg2$player1
player2vector <- COLL13_SDg2$player2
COLL13_SDg3 <- COLL13_SDg2
COLL13_SDg3$p1inp2vec <- is.element(COLL13_SDg3$player1, player2vector)
COLL13_SDg3$p2inp1vec <- is.element(COLL13_SDg3$player2, player1vector)
addPlayer1 <- COLL13_SDg3[ which(COLL13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_SDg3[ which(COLL13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_SDg2 <- rbind(COLL13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
COLL13_SDft <- ftable(COLL13_SDg2$player1, COLL13_SDg2$player2)
COLL13_SDft2 <- as.matrix(COLL13_SDft)
numRows <- nrow(COLL13_SDft2)
numCols <- ncol(COLL13_SDft2)
COLL13_SDft3 <- COLL13_SDft2[c(2:numRows) , c(2:numCols)]
COLL13_SDTable <- graph.adjacency(COLL13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(COLL13_SDTable, vertex.label = V(COLL13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
COLL13_SD.clusterCoef <- transitivity(COLL13_SDTable, type="global") #cluster coefficient
COLL13_SD.degreeCent <- centralization.degree(COLL13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_SDftn <- as.network.matrix(COLL13_SDft)
COLL13_SD.netDensity <- network.density(COLL13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_SD.entropy <- entropy(COLL13_SDft) #entropy
COLL13_SD.netMx <- cbind(COLL13_SD.netMx, COLL13_SD.clusterCoef, COLL13_SD.degreeCent$centralization,
COLL13_SD.netDensity, COLL13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "COLL"
KIoutcome = "Turnover_D"
COLL13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
COLL13_TDg2 <- data.frame(COLL13_TD)
COLL13_TDg2 <- COLL13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_TDg2$player1
player2vector <- COLL13_TDg2$player2
COLL13_TDg3 <- COLL13_TDg2
COLL13_TDg3$p1inp2vec <- is.element(COLL13_TDg3$player1, player2vector)
COLL13_TDg3$p2inp1vec <- is.element(COLL13_TDg3$player2, player1vector)
addPlayer1 <- COLL13_TDg3[ which(COLL13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_TDg3[ which(COLL13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_TDg2 <- rbind(COLL13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
COLL13_TDft <- ftable(COLL13_TDg2$player1, COLL13_TDg2$player2)
COLL13_TDft2 <- as.matrix(COLL13_TDft)
numRows <- nrow(COLL13_TDft2)
numCols <- ncol(COLL13_TDft2)
COLL13_TDft3 <- COLL13_TDft2[c(2:numRows) , c(2:numCols)]
COLL13_TDTable <- graph.adjacency(COLL13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(COLL13_TDTable, vertex.label = V(COLL13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
COLL13_TD.clusterCoef <- transitivity(COLL13_TDTable, type="global") #cluster coefficient
COLL13_TD.degreeCent <- centralization.degree(COLL13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_TDftn <- as.network.matrix(COLL13_TDft)
COLL13_TD.netDensity <- network.density(COLL13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_TD.entropy <- entropy(COLL13_TDft) #entropy
COLL13_TD.netMx <- cbind(COLL13_TD.netMx, COLL13_TD.clusterCoef, COLL13_TD.degreeCent$centralization,
COLL13_TD.netDensity, COLL13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "COLL"
KIoutcome = "End of Qtr_DM"
COLL13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
COLL13_QTg2 <- data.frame(COLL13_QT)
COLL13_QTg2 <- COLL13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- COLL13_QTg2$player1
player2vector <- COLL13_QTg2$player2
COLL13_QTg3 <- COLL13_QTg2
COLL13_QTg3$p1inp2vec <- is.element(COLL13_QTg3$player1, player2vector)
COLL13_QTg3$p2inp1vec <- is.element(COLL13_QTg3$player2, player1vector)
addPlayer1 <- COLL13_QTg3[ which(COLL13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- COLL13_QTg3[ which(COLL13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
COLL13_QTg2 <- rbind(COLL13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
COLL13_QTft <- ftable(COLL13_QTg2$player1, COLL13_QTg2$player2)
COLL13_QTft2 <- as.matrix(COLL13_QTft)
numRows <- nrow(COLL13_QTft2)
numCols <- ncol(COLL13_QTft2)
COLL13_QTft3 <- COLL13_QTft2[c(2:numRows) , c(2:numCols)]
COLL13_QTTable <- graph.adjacency(COLL13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(COLL13_QTTable, vertex.label = V(COLL13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(COLL13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
COLL13_QT.clusterCoef <- transitivity(COLL13_QTTable, type="global") #cluster coefficient
COLL13_QT.degreeCent <- centralization.degree(COLL13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
COLL13_QTftn <- as.network.matrix(COLL13_QTft)
COLL13_QT.netDensity <- network.density(COLL13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
COLL13_QT.entropy <- entropy(COLL13_QTft) #entropy
COLL13_QT.netMx <- cbind(COLL13_QT.netMx, COLL13_QT.clusterCoef, COLL13_QT.degreeCent$centralization,
COLL13_QT.netDensity, COLL13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(COLL13_QT.netMx) <- varnames
#############################################################################
#ESSENDON
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
round = 13
teamName = "ESS"
KIoutcome = "Goal_F"
ESS13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
ESS13_Gg2 <- data.frame(ESS13_G)
ESS13_Gg2 <- ESS13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_Gg2$player1
player2vector <- ESS13_Gg2$player2
ESS13_Gg3 <- ESS13_Gg2
ESS13_Gg3$p1inp2vec <- is.element(ESS13_Gg3$player1, player2vector)
ESS13_Gg3$p2inp1vec <- is.element(ESS13_Gg3$player2, player1vector)
addPlayer1 <- ESS13_Gg3[ which(ESS13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, empty, zero)
addPlayer2 <- ESS13_Gg3[ which(ESS13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_Gg2 <- rbind(ESS13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
ESS13_Gft <- ftable(ESS13_Gg2$player1, ESS13_Gg2$player2)
ESS13_Gft2 <- as.matrix(ESS13_Gft)
numRows <- nrow(ESS13_Gft2)
numCols <- ncol(ESS13_Gft2)
ESS13_Gft3 <- ESS13_Gft2[c(2:numRows) , c(2:numCols)]
ESS13_GTable <- graph.adjacency(ESS13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(ESS13_GTable, vertex.label = V(ESS13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
ESS13_G.clusterCoef <- transitivity(ESS13_GTable, type="global") #cluster coefficient
ESS13_G.degreeCent <- centralization.degree(ESS13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_Gftn <- as.network.matrix(ESS13_Gft)
ESS13_G.netDensity <- network.density(ESS13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_G.entropy <- entropy(ESS13_Gft) #entropy
ESS13_G.netMx <- cbind(ESS13_G.netMx, ESS13_G.clusterCoef, ESS13_G.degreeCent$centralization,
ESS13_G.netDensity, ESS13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
round = 13
teamName = "ESS"
KIoutcome = "Behind_F"
ESS13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
ESS13_Bg2 <- data.frame(ESS13_B)
ESS13_Bg2 <- ESS13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_Bg2$player1
player2vector <- ESS13_Bg2$player2
ESS13_Bg3 <- ESS13_Bg2
ESS13_Bg3$p1inp2vec <- is.element(ESS13_Bg3$player1, player2vector)
ESS13_Bg3$p2inp1vec <- is.element(ESS13_Bg3$player2, player1vector)
addPlayer1 <- ESS13_Bg3[ which(ESS13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_Bg3[ which(ESS13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_Bg2 <- rbind(ESS13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
ESS13_Bft <- ftable(ESS13_Bg2$player1, ESS13_Bg2$player2)
ESS13_Bft2 <- as.matrix(ESS13_Bft)
numRows <- nrow(ESS13_Bft2)
numCols <- ncol(ESS13_Bft2)
ESS13_Bft3 <- ESS13_Bft2[c(2:numRows) , c(2:numCols)]
ESS13_BTable <- graph.adjacency(ESS13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(ESS13_BTable, vertex.label = V(ESS13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
ESS13_B.clusterCoef <- transitivity(ESS13_BTable, type="global") #cluster coefficient
ESS13_B.degreeCent <- centralization.degree(ESS13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_Bftn <- as.network.matrix(ESS13_Bft)
ESS13_B.netDensity <- network.density(ESS13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_B.entropy <- entropy(ESS13_Bft) #entropy
ESS13_B.netMx <- cbind(ESS13_B.netMx, ESS13_B.clusterCoef, ESS13_B.degreeCent$centralization,
ESS13_B.netDensity, ESS13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "ESS"
KIoutcome = "Stoppage_F"
ESS13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
ESS13_SFg2 <- data.frame(ESS13_SF)
ESS13_SFg2 <- ESS13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_SFg2$player1
player2vector <- ESS13_SFg2$player2
ESS13_SFg3 <- ESS13_SFg2
ESS13_SFg3$p1inp2vec <- is.element(ESS13_SFg3$player1, player2vector)
ESS13_SFg3$p2inp1vec <- is.element(ESS13_SFg3$player2, player1vector)
addPlayer1 <- ESS13_SFg3[ which(ESS13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_SFg3[ which(ESS13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_SFg2 <- rbind(ESS13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
ESS13_SFft <- ftable(ESS13_SFg2$player1, ESS13_SFg2$player2)
ESS13_SFft2 <- as.matrix(ESS13_SFft)
numRows <- nrow(ESS13_SFft2)
numCols <- ncol(ESS13_SFft2)
ESS13_SFft3 <- ESS13_SFft2[c(2:numRows) , c(2:numCols)]
ESS13_SFTable <- graph.adjacency(ESS13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(ESS13_SFTable, vertex.label = V(ESS13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
ESS13_SF.clusterCoef <- transitivity(ESS13_SFTable, type="global") #cluster coefficient
ESS13_SF.degreeCent <- centralization.degree(ESS13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_SFftn <- as.network.matrix(ESS13_SFft)
ESS13_SF.netDensity <- network.density(ESS13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_SF.entropy <- entropy(ESS13_SFft) #entropy
ESS13_SF.netMx <- cbind(ESS13_SF.netMx, ESS13_SF.clusterCoef, ESS13_SF.degreeCent$centralization,
ESS13_SF.netDensity, ESS13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
#NA
round = 13
teamName = "ESS"
KIoutcome = "Turnover_F"
ESS13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
ESS13_TFg2 <- data.frame(ESS13_TF)
ESS13_TFg2 <- ESS13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_TFg2$player1
player2vector <- ESS13_TFg2$player2
ESS13_TFg3 <- ESS13_TFg2
ESS13_TFg3$p1inp2vec <- is.element(ESS13_TFg3$player1, player2vector)
ESS13_TFg3$p2inp1vec <- is.element(ESS13_TFg3$player2, player1vector)
addPlayer1 <- ESS13_TFg3[ which(ESS13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_TFg3[ which(ESS13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_TFg2 <- rbind(ESS13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
ESS13_TFft <- ftable(ESS13_TFg2$player1, ESS13_TFg2$player2)
ESS13_TFft2 <- as.matrix(ESS13_TFft)
numRows <- nrow(ESS13_TFft2)
numCols <- ncol(ESS13_TFft2)
ESS13_TFft3 <- ESS13_TFft2[c(2:numRows) , c(2:numCols)]
ESS13_TFTable <- graph.adjacency(ESS13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(ESS13_TFTable, vertex.label = V(ESS13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
ESS13_TF.clusterCoef <- transitivity(ESS13_TFTable, type="global") #cluster coefficient
ESS13_TF.degreeCent <- centralization.degree(ESS13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_TFftn <- as.network.matrix(ESS13_TFft)
ESS13_TF.netDensity <- network.density(ESS13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_TF.entropy <- entropy(ESS13_TFft) #entropy
ESS13_TF.netMx <- cbind(ESS13_TF.netMx, ESS13_TF.clusterCoef, ESS13_TF.degreeCent$centralization,
ESS13_TF.netDensity, ESS13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
#NA
round = 13
teamName = "ESS"
KIoutcome = "Stoppage_AM"
ESS13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
ESS13_SAMg2 <- data.frame(ESS13_SAM)
ESS13_SAMg2 <- ESS13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_SAMg2$player1
player2vector <- ESS13_SAMg2$player2
ESS13_SAMg3 <- ESS13_SAMg2
ESS13_SAMg3$p1inp2vec <- is.element(ESS13_SAMg3$player1, player2vector)
ESS13_SAMg3$p2inp1vec <- is.element(ESS13_SAMg3$player2, player1vector)
addPlayer1 <- ESS13_SAMg3[ which(ESS13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_SAMg3[ which(ESS13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_SAMg2 <- rbind(ESS13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
ESS13_SAMft <- ftable(ESS13_SAMg2$player1, ESS13_SAMg2$player2)
ESS13_SAMft2 <- as.matrix(ESS13_SAMft)
numRows <- nrow(ESS13_SAMft2)
numCols <- ncol(ESS13_SAMft2)
ESS13_SAMft3 <- ESS13_SAMft2[c(2:numRows) , c(2:numCols)]
ESS13_SAMTable <- graph.adjacency(ESS13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(ESS13_SAMTable, vertex.label = V(ESS13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
ESS13_SAM.clusterCoef <- transitivity(ESS13_SAMTable, type="global") #cluster coefficient
ESS13_SAM.degreeCent <- centralization.degree(ESS13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_SAMftn <- as.network.matrix(ESS13_SAMft)
ESS13_SAM.netDensity <- network.density(ESS13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_SAM.entropy <- entropy(ESS13_SAMft) #entropy
ESS13_SAM.netMx <- cbind(ESS13_SAM.netMx, ESS13_SAM.clusterCoef, ESS13_SAM.degreeCent$centralization,
ESS13_SAM.netDensity, ESS13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "ESS"
KIoutcome = "Turnover_AM"
ESS13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
ESS13_TAMg2 <- data.frame(ESS13_TAM)
ESS13_TAMg2 <- ESS13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_TAMg2$player1
player2vector <- ESS13_TAMg2$player2
ESS13_TAMg3 <- ESS13_TAMg2
ESS13_TAMg3$p1inp2vec <- is.element(ESS13_TAMg3$player1, player2vector)
ESS13_TAMg3$p2inp1vec <- is.element(ESS13_TAMg3$player2, player1vector)
addPlayer1 <- ESS13_TAMg3[ which(ESS13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_TAMg3[ which(ESS13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_TAMg2 <- rbind(ESS13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
ESS13_TAMft <- ftable(ESS13_TAMg2$player1, ESS13_TAMg2$player2)
ESS13_TAMft2 <- as.matrix(ESS13_TAMft)
numRows <- nrow(ESS13_TAMft2)
numCols <- ncol(ESS13_TAMft2)
ESS13_TAMft3 <- ESS13_TAMft2[c(2:numRows) , c(2:numCols)]
ESS13_TAMTable <- graph.adjacency(ESS13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(ESS13_TAMTable, vertex.label = V(ESS13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
ESS13_TAM.clusterCoef <- transitivity(ESS13_TAMTable, type="global") #cluster coefficient
ESS13_TAM.degreeCent <- centralization.degree(ESS13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_TAMftn <- as.network.matrix(ESS13_TAMft)
ESS13_TAM.netDensity <- network.density(ESS13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_TAM.entropy <- entropy(ESS13_TAMft) #entropy
ESS13_TAM.netMx <- cbind(ESS13_TAM.netMx, ESS13_TAM.clusterCoef, ESS13_TAM.degreeCent$centralization,
ESS13_TAM.netDensity, ESS13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
#NA
round = 13
teamName = "ESS"
KIoutcome = "Stoppage_DM"
ESS13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
ESS13_SDMg2 <- data.frame(ESS13_SDM)
ESS13_SDMg2 <- ESS13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_SDMg2$player1
player2vector <- ESS13_SDMg2$player2
ESS13_SDMg3 <- ESS13_SDMg2
ESS13_SDMg3$p1inp2vec <- is.element(ESS13_SDMg3$player1, player2vector)
ESS13_SDMg3$p2inp1vec <- is.element(ESS13_SDMg3$player2, player1vector)
addPlayer1 <- ESS13_SDMg3[ which(ESS13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_SDMg3[ which(ESS13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_SDMg2 <- rbind(ESS13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
ESS13_SDMft <- ftable(ESS13_SDMg2$player1, ESS13_SDMg2$player2)
ESS13_SDMft2 <- as.matrix(ESS13_SDMft)
numRows <- nrow(ESS13_SDMft2)
numCols <- ncol(ESS13_SDMft2)
ESS13_SDMft3 <- ESS13_SDMft2[c(2:numRows) , c(2:numCols)]
ESS13_SDMTable <- graph.adjacency(ESS13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(ESS13_SDMTable, vertex.label = V(ESS13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
ESS13_SDM.clusterCoef <- transitivity(ESS13_SDMTable, type="global") #cluster coefficient
ESS13_SDM.degreeCent <- centralization.degree(ESS13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_SDMftn <- as.network.matrix(ESS13_SDMft)
ESS13_SDM.netDensity <- network.density(ESS13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_SDM.entropy <- entropy(ESS13_SDMft) #entropy
ESS13_SDM.netMx <- cbind(ESS13_SDM.netMx, ESS13_SDM.clusterCoef, ESS13_SDM.degreeCent$centralization,
ESS13_SDM.netDensity, ESS13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "ESS"
KIoutcome = "Turnover_DM"
ESS13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
ESS13_TDMg2 <- data.frame(ESS13_TDM)
ESS13_TDMg2 <- ESS13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_TDMg2$player1
player2vector <- ESS13_TDMg2$player2
ESS13_TDMg3 <- ESS13_TDMg2
ESS13_TDMg3$p1inp2vec <- is.element(ESS13_TDMg3$player1, player2vector)
ESS13_TDMg3$p2inp1vec <- is.element(ESS13_TDMg3$player2, player1vector)
addPlayer1 <- ESS13_TDMg3[ which(ESS13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_TDMg3[ which(ESS13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(empty, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_TDMg2 <- rbind(ESS13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
ESS13_TDMft <- ftable(ESS13_TDMg2$player1, ESS13_TDMg2$player2)
ESS13_TDMft2 <- as.matrix(ESS13_TDMft)
numRows <- nrow(ESS13_TDMft2)
numCols <- ncol(ESS13_TDMft2)
ESS13_TDMft3 <- ESS13_TDMft2[c(2:numRows) , c(2:numCols)] #Had to change no of cols when only adding rows
ESS13_TDMTable <- graph.adjacency(ESS13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(ESS13_TDMTable, vertex.label = V(ESS13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
ESS13_TDM.clusterCoef <- transitivity(ESS13_TDMTable, type="global") #cluster coefficient
ESS13_TDM.degreeCent <- centralization.degree(ESS13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_TDMftn <- as.network.matrix(ESS13_TDMft)
ESS13_TDM.netDensity <- network.density(ESS13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_TDM.entropy <- entropy(ESS13_TDMft) #entropy
ESS13_TDM.netMx <- cbind(ESS13_TDM.netMx, ESS13_TDM.clusterCoef, ESS13_TDM.degreeCent$centralization,
ESS13_TDM.netDensity, ESS13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "ESS"
KIoutcome = "Stoppage_D"
ESS13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
ESS13_SDg2 <- data.frame(ESS13_SD)
ESS13_SDg2 <- ESS13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_SDg2$player1
player2vector <- ESS13_SDg2$player2
ESS13_SDg3 <- ESS13_SDg2
ESS13_SDg3$p1inp2vec <- is.element(ESS13_SDg3$player1, player2vector)
ESS13_SDg3$p2inp1vec <- is.element(ESS13_SDg3$player2, player1vector)
addPlayer1 <- ESS13_SDg3[ which(ESS13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_SDg3[ which(ESS13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_SDg2 <- rbind(ESS13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
ESS13_SDft <- ftable(ESS13_SDg2$player1, ESS13_SDg2$player2)
ESS13_SDft2 <- as.matrix(ESS13_SDft)
numRows <- nrow(ESS13_SDft2)
numCols <- ncol(ESS13_SDft2)
ESS13_SDft3 <- ESS13_SDft2[c(2:numRows) , c(2:numCols)]
ESS13_SDTable <- graph.adjacency(ESS13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(ESS13_SDTable, vertex.label = V(ESS13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
ESS13_SD.clusterCoef <- transitivity(ESS13_SDTable, type="global") #cluster coefficient
ESS13_SD.degreeCent <- centralization.degree(ESS13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_SDftn <- as.network.matrix(ESS13_SDft)
ESS13_SD.netDensity <- network.density(ESS13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_SD.entropy <- entropy(ESS13_SDft) #entropy
ESS13_SD.netMx <- cbind(ESS13_SD.netMx, ESS13_SD.clusterCoef, ESS13_SD.degreeCent$centralization,
ESS13_SD.netDensity, ESS13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
round = 13
teamName = "ESS"
KIoutcome = "Turnover_D"
ESS13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
ESS13_TDg2 <- data.frame(ESS13_TD)
ESS13_TDg2 <- ESS13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_TDg2$player1
player2vector <- ESS13_TDg2$player2
ESS13_TDg3 <- ESS13_TDg2
ESS13_TDg3$p1inp2vec <- is.element(ESS13_TDg3$player1, player2vector)
ESS13_TDg3$p2inp1vec <- is.element(ESS13_TDg3$player2, player1vector)
addPlayer1 <- ESS13_TDg3[ which(ESS13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_TDg3[ which(ESS13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_TDg2 <- rbind(ESS13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
ESS13_TDft <- ftable(ESS13_TDg2$player1, ESS13_TDg2$player2)
ESS13_TDft2 <- as.matrix(ESS13_TDft)
numRows <- nrow(ESS13_TDft2)
numCols <- ncol(ESS13_TDft2)
ESS13_TDft3 <- ESS13_TDft2[c(2:numRows) , c(2:numCols)]
ESS13_TDTable <- graph.adjacency(ESS13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(ESS13_TDTable, vertex.label = V(ESS13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
ESS13_TD.clusterCoef <- transitivity(ESS13_TDTable, type="global") #cluster coefficient
ESS13_TD.degreeCent <- centralization.degree(ESS13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_TDftn <- as.network.matrix(ESS13_TDft)
ESS13_TD.netDensity <- network.density(ESS13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_TD.entropy <- entropy(ESS13_TDft) #entropy
ESS13_TD.netMx <- cbind(ESS13_TD.netMx, ESS13_TD.clusterCoef, ESS13_TD.degreeCent$centralization,
ESS13_TD.netDensity, ESS13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
round = 13
teamName = "ESS"
KIoutcome = "End of Qtr_DM"
ESS13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
ESS13_QTg2 <- data.frame(ESS13_QT)
ESS13_QTg2 <- ESS13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- ESS13_QTg2$player1
player2vector <- ESS13_QTg2$player2
ESS13_QTg3 <- ESS13_QTg2
ESS13_QTg3$p1inp2vec <- is.element(ESS13_QTg3$player1, player2vector)
ESS13_QTg3$p2inp1vec <- is.element(ESS13_QTg3$player2, player1vector)
addPlayer1 <- ESS13_QTg3[ which(ESS13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- ESS13_QTg3[ which(ESS13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(empty, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
ESS13_QTg2 <- rbind(ESS13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
ESS13_QTft <- ftable(ESS13_QTg2$player1, ESS13_QTg2$player2)
ESS13_QTft2 <- as.matrix(ESS13_QTft)
numRows <- nrow(ESS13_QTft2)
numCols <- ncol(ESS13_QTft2)
ESS13_QTft3 <- ESS13_QTft2[c(2:numRows) , c(2:numCols)]
ESS13_QTTable <- graph.adjacency(ESS13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(ESS13_QTTable, vertex.label = V(ESS13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(ESS13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
ESS13_QT.clusterCoef <- transitivity(ESS13_QTTable, type="global") #cluster coefficient
ESS13_QT.degreeCent <- centralization.degree(ESS13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
ESS13_QTftn <- as.network.matrix(ESS13_QTft)
ESS13_QT.netDensity <- network.density(ESS13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
ESS13_QT.entropy <- entropy(ESS13_QTft) #entropy
ESS13_QT.netMx <- cbind(ESS13_QT.netMx, ESS13_QT.clusterCoef, ESS13_QT.degreeCent$centralization,
ESS13_QT.netDensity, ESS13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(ESS13_QT.netMx) <- varnames
#############################################################################
#FREMANTLE
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
round = 13
teamName = "FRE"
KIoutcome = "Goal_F"
FRE13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
FRE13_Gg2 <- data.frame(FRE13_G)
FRE13_Gg2 <- FRE13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_Gg2$player1
player2vector <- FRE13_Gg2$player2
FRE13_Gg3 <- FRE13_Gg2
FRE13_Gg3$p1inp2vec <- is.element(FRE13_Gg3$player1, player2vector)
FRE13_Gg3$p2inp1vec <- is.element(FRE13_Gg3$player2, player1vector)
addPlayer1 <- FRE13_Gg3[ which(FRE13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_Gg3[ which(FRE13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_Gg2 <- rbind(FRE13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
FRE13_Gft <- ftable(FRE13_Gg2$player1, FRE13_Gg2$player2)
FRE13_Gft2 <- as.matrix(FRE13_Gft)
numRows <- nrow(FRE13_Gft2)
numCols <- ncol(FRE13_Gft2)
FRE13_Gft3 <- FRE13_Gft2[c(2:numRows) , c(2:numCols)]
FRE13_GTable <- graph.adjacency(FRE13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(FRE13_GTable, vertex.label = V(FRE13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
FRE13_G.clusterCoef <- transitivity(FRE13_GTable, type="global") #cluster coefficient
FRE13_G.degreeCent <- centralization.degree(FRE13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_Gftn <- as.network.matrix(FRE13_Gft)
FRE13_G.netDensity <- network.density(FRE13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_G.entropy <- entropy(FRE13_Gft) #entropy
FRE13_G.netMx <- cbind(FRE13_G.netMx, FRE13_G.clusterCoef, FRE13_G.degreeCent$centralization,
FRE13_G.netDensity, FRE13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Behind_F"
FRE13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
FRE13_Bg2 <- data.frame(FRE13_B)
FRE13_Bg2 <- FRE13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_Bg2$player1
player2vector <- FRE13_Bg2$player2
FRE13_Bg3 <- FRE13_Bg2
FRE13_Bg3$p1inp2vec <- is.element(FRE13_Bg3$player1, player2vector)
FRE13_Bg3$p2inp1vec <- is.element(FRE13_Bg3$player2, player1vector)
addPlayer1 <- FRE13_Bg3[ which(FRE13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_Bg3[ which(FRE13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_Bg2 <- rbind(FRE13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
FRE13_Bft <- ftable(FRE13_Bg2$player1, FRE13_Bg2$player2)
FRE13_Bft2 <- as.matrix(FRE13_Bft)
numRows <- nrow(FRE13_Bft2)
numCols <- ncol(FRE13_Bft2)
FRE13_Bft3 <- FRE13_Bft2[c(2:numRows) , c(2:numCols)]
FRE13_BTable <- graph.adjacency(FRE13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(FRE13_BTable, vertex.label = V(FRE13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
FRE13_B.clusterCoef <- transitivity(FRE13_BTable, type="global") #cluster coefficient
FRE13_B.degreeCent <- centralization.degree(FRE13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_Bftn <- as.network.matrix(FRE13_Bft)
FRE13_B.netDensity <- network.density(FRE13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_B.entropy <- entropy(FRE13_Bft) #entropy
FRE13_B.netMx <- cbind(FRE13_B.netMx, FRE13_B.clusterCoef, FRE13_B.degreeCent$centralization,
FRE13_B.netDensity, FRE13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Stoppage_F"
FRE13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
FRE13_SFg2 <- data.frame(FRE13_SF)
FRE13_SFg2 <- FRE13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_SFg2$player1
player2vector <- FRE13_SFg2$player2
FRE13_SFg3 <- FRE13_SFg2
FRE13_SFg3$p1inp2vec <- is.element(FRE13_SFg3$player1, player2vector)
FRE13_SFg3$p2inp1vec <- is.element(FRE13_SFg3$player2, player1vector)
addPlayer1 <- FRE13_SFg3[ which(FRE13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_SFg3[ which(FRE13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_SFg2 <- rbind(FRE13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
FRE13_SFft <- ftable(FRE13_SFg2$player1, FRE13_SFg2$player2)
FRE13_SFft2 <- as.matrix(FRE13_SFft)
numRows <- nrow(FRE13_SFft2)
numCols <- ncol(FRE13_SFft2)
FRE13_SFft3 <- FRE13_SFft2[c(2:numRows) , c(2:numCols)]
FRE13_SFTable <- graph.adjacency(FRE13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(FRE13_SFTable, vertex.label = V(FRE13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
FRE13_SF.clusterCoef <- transitivity(FRE13_SFTable, type="global") #cluster coefficient
FRE13_SF.degreeCent <- centralization.degree(FRE13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_SFftn <- as.network.matrix(FRE13_SFft)
FRE13_SF.netDensity <- network.density(FRE13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_SF.entropy <- entropy(FRE13_SFft) #entropy
FRE13_SF.netMx <- cbind(FRE13_SF.netMx, FRE13_SF.clusterCoef, FRE13_SF.degreeCent$centralization,
FRE13_SF.netDensity, FRE13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Turnover_F"
FRE13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
FRE13_TFg2 <- data.frame(FRE13_TF)
FRE13_TFg2 <- FRE13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_TFg2$player1
player2vector <- FRE13_TFg2$player2
FRE13_TFg3 <- FRE13_TFg2
FRE13_TFg3$p1inp2vec <- is.element(FRE13_TFg3$player1, player2vector)
FRE13_TFg3$p2inp1vec <- is.element(FRE13_TFg3$player2, player1vector)
addPlayer1 <- FRE13_TFg3[ which(FRE13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_TFg3[ which(FRE13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_TFg2 <- rbind(FRE13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
FRE13_TFft <- ftable(FRE13_TFg2$player1, FRE13_TFg2$player2)
FRE13_TFft2 <- as.matrix(FRE13_TFft)
numRows <- nrow(FRE13_TFft2)
numCols <- ncol(FRE13_TFft2)
FRE13_TFft3 <- FRE13_TFft2[c(2:numRows) , c(2:numCols)]
FRE13_TFTable <- graph.adjacency(FRE13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(FRE13_TFTable, vertex.label = V(FRE13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
FRE13_TF.clusterCoef <- transitivity(FRE13_TFTable, type="global") #cluster coefficient
FRE13_TF.degreeCent <- centralization.degree(FRE13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_TFftn <- as.network.matrix(FRE13_TFft)
FRE13_TF.netDensity <- network.density(FRE13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_TF.entropy <- entropy(FRE13_TFft) #entropy
FRE13_TF.netMx <- cbind(FRE13_TF.netMx, FRE13_TF.clusterCoef, FRE13_TF.degreeCent$centralization,
FRE13_TF.netDensity, FRE13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Stoppage_AM"
FRE13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
FRE13_SAMg2 <- data.frame(FRE13_SAM)
FRE13_SAMg2 <- FRE13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_SAMg2$player1
player2vector <- FRE13_SAMg2$player2
FRE13_SAMg3 <- FRE13_SAMg2
FRE13_SAMg3$p1inp2vec <- is.element(FRE13_SAMg3$player1, player2vector)
FRE13_SAMg3$p2inp1vec <- is.element(FRE13_SAMg3$player2, player1vector)
addPlayer1 <- FRE13_SAMg3[ which(FRE13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_SAMg3[ which(FRE13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_SAMg2 <- rbind(FRE13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
FRE13_SAMft <- ftable(FRE13_SAMg2$player1, FRE13_SAMg2$player2)
FRE13_SAMft2 <- as.matrix(FRE13_SAMft)
numRows <- nrow(FRE13_SAMft2)
numCols <- ncol(FRE13_SAMft2)
FRE13_SAMft3 <- FRE13_SAMft2[c(2:numRows) , c(2:numCols)]
FRE13_SAMTable <- graph.adjacency(FRE13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(FRE13_SAMTable, vertex.label = V(FRE13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
FRE13_SAM.clusterCoef <- transitivity(FRE13_SAMTable, type="global") #cluster coefficient
FRE13_SAM.degreeCent <- centralization.degree(FRE13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_SAMftn <- as.network.matrix(FRE13_SAMft)
FRE13_SAM.netDensity <- network.density(FRE13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_SAM.entropy <- entropy(FRE13_SAMft) #entropy
FRE13_SAM.netMx <- cbind(FRE13_SAM.netMx, FRE13_SAM.clusterCoef, FRE13_SAM.degreeCent$centralization,
FRE13_SAM.netDensity, FRE13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Turnover_AM"
FRE13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
FRE13_TAMg2 <- data.frame(FRE13_TAM)
FRE13_TAMg2 <- FRE13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_TAMg2$player1
player2vector <- FRE13_TAMg2$player2
FRE13_TAMg3 <- FRE13_TAMg2
FRE13_TAMg3$p1inp2vec <- is.element(FRE13_TAMg3$player1, player2vector)
FRE13_TAMg3$p2inp1vec <- is.element(FRE13_TAMg3$player2, player1vector)
addPlayer1 <- FRE13_TAMg3[ which(FRE13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_TAMg3[ which(FRE13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_TAMg2 <- rbind(FRE13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
FRE13_TAMft <- ftable(FRE13_TAMg2$player1, FRE13_TAMg2$player2)
FRE13_TAMft2 <- as.matrix(FRE13_TAMft)
numRows <- nrow(FRE13_TAMft2)
numCols <- ncol(FRE13_TAMft2)
FRE13_TAMft3 <- FRE13_TAMft2[c(2:numRows) , c(2:numCols)]
FRE13_TAMTable <- graph.adjacency(FRE13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(FRE13_TAMTable, vertex.label = V(FRE13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
FRE13_TAM.clusterCoef <- transitivity(FRE13_TAMTable, type="global") #cluster coefficient
FRE13_TAM.degreeCent <- centralization.degree(FRE13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_TAMftn <- as.network.matrix(FRE13_TAMft)
FRE13_TAM.netDensity <- network.density(FRE13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_TAM.entropy <- entropy(FRE13_TAMft) #entropy
FRE13_TAM.netMx <- cbind(FRE13_TAM.netMx, FRE13_TAM.clusterCoef, FRE13_TAM.degreeCent$centralization,
FRE13_TAM.netDensity, FRE13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "FRE"
KIoutcome = "Stoppage_DM"
FRE13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
FRE13_SDMg2 <- data.frame(FRE13_SDM)
FRE13_SDMg2 <- FRE13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_SDMg2$player1
player2vector <- FRE13_SDMg2$player2
FRE13_SDMg3 <- FRE13_SDMg2
FRE13_SDMg3$p1inp2vec <- is.element(FRE13_SDMg3$player1, player2vector)
FRE13_SDMg3$p2inp1vec <- is.element(FRE13_SDMg3$player2, player1vector)
addPlayer1 <- FRE13_SDMg3[ which(FRE13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_SDMg3[ which(FRE13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_SDMg2 <- rbind(FRE13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
FRE13_SDMft <- ftable(FRE13_SDMg2$player1, FRE13_SDMg2$player2)
FRE13_SDMft2 <- as.matrix(FRE13_SDMft)
numRows <- nrow(FRE13_SDMft2)
numCols <- ncol(FRE13_SDMft2)
FRE13_SDMft3 <- FRE13_SDMft2[c(2:numRows) , c(2:numCols)]
FRE13_SDMTable <- graph.adjacency(FRE13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(FRE13_SDMTable, vertex.label = V(FRE13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
FRE13_SDM.clusterCoef <- transitivity(FRE13_SDMTable, type="global") #cluster coefficient
FRE13_SDM.degreeCent <- centralization.degree(FRE13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_SDMftn <- as.network.matrix(FRE13_SDMft)
FRE13_SDM.netDensity <- network.density(FRE13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_SDM.entropy <- entropy(FRE13_SDMft) #entropy
FRE13_SDM.netMx <- cbind(FRE13_SDM.netMx, FRE13_SDM.clusterCoef, FRE13_SDM.degreeCent$centralization,
FRE13_SDM.netDensity, FRE13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Turnover_DM"
FRE13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
FRE13_TDMg2 <- data.frame(FRE13_TDM)
FRE13_TDMg2 <- FRE13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_TDMg2$player1
player2vector <- FRE13_TDMg2$player2
FRE13_TDMg3 <- FRE13_TDMg2
FRE13_TDMg3$p1inp2vec <- is.element(FRE13_TDMg3$player1, player2vector)
FRE13_TDMg3$p2inp1vec <- is.element(FRE13_TDMg3$player2, player1vector)
addPlayer1 <- FRE13_TDMg3[ which(FRE13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_TDMg3[ which(FRE13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_TDMg2 <- rbind(FRE13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
FRE13_TDMft <- ftable(FRE13_TDMg2$player1, FRE13_TDMg2$player2)
FRE13_TDMft2 <- as.matrix(FRE13_TDMft)
numRows <- nrow(FRE13_TDMft2)
numCols <- ncol(FRE13_TDMft2)
FRE13_TDMft3 <- FRE13_TDMft2[c(2:numRows) , c(2:numCols)]
FRE13_TDMTable <- graph.adjacency(FRE13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(FRE13_TDMTable, vertex.label = V(FRE13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
FRE13_TDM.clusterCoef <- transitivity(FRE13_TDMTable, type="global") #cluster coefficient
FRE13_TDM.degreeCent <- centralization.degree(FRE13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_TDMftn <- as.network.matrix(FRE13_TDMft)
FRE13_TDM.netDensity <- network.density(FRE13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_TDM.entropy <- entropy(FRE13_TDMft) #entropy
FRE13_TDM.netMx <- cbind(FRE13_TDM.netMx, FRE13_TDM.clusterCoef, FRE13_TDM.degreeCent$centralization,
FRE13_TDM.netDensity, FRE13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Stoppage_D"
FRE13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
FRE13_SDg2 <- data.frame(FRE13_SD)
FRE13_SDg2 <- FRE13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_SDg2$player1
player2vector <- FRE13_SDg2$player2
FRE13_SDg3 <- FRE13_SDg2
FRE13_SDg3$p1inp2vec <- is.element(FRE13_SDg3$player1, player2vector)
FRE13_SDg3$p2inp1vec <- is.element(FRE13_SDg3$player2, player1vector)
addPlayer1 <- FRE13_SDg3[ which(FRE13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_SDg3[ which(FRE13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_SDg2 <- rbind(FRE13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
FRE13_SDft <- ftable(FRE13_SDg2$player1, FRE13_SDg2$player2)
FRE13_SDft2 <- as.matrix(FRE13_SDft)
numRows <- nrow(FRE13_SDft2)
numCols <- ncol(FRE13_SDft2)
FRE13_SDft3 <- FRE13_SDft2[c(2:numRows) , c(2:numCols)]
FRE13_SDTable <- graph.adjacency(FRE13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(FRE13_SDTable, vertex.label = V(FRE13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
FRE13_SD.clusterCoef <- transitivity(FRE13_SDTable, type="global") #cluster coefficient
FRE13_SD.degreeCent <- centralization.degree(FRE13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_SDftn <- as.network.matrix(FRE13_SDft)
FRE13_SD.netDensity <- network.density(FRE13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_SD.entropy <- entropy(FRE13_SDft) #entropy
FRE13_SD.netMx <- cbind(FRE13_SD.netMx, FRE13_SD.clusterCoef, FRE13_SD.degreeCent$centralization,
FRE13_SD.netDensity, FRE13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "Turnover_D"
FRE13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
FRE13_TDg2 <- data.frame(FRE13_TD)
FRE13_TDg2 <- FRE13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_TDg2$player1
player2vector <- FRE13_TDg2$player2
FRE13_TDg3 <- FRE13_TDg2
FRE13_TDg3$p1inp2vec <- is.element(FRE13_TDg3$player1, player2vector)
FRE13_TDg3$p2inp1vec <- is.element(FRE13_TDg3$player2, player1vector)
addPlayer1 <- FRE13_TDg3[ which(FRE13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_TDg3[ which(FRE13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_TDg2 <- rbind(FRE13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
FRE13_TDft <- ftable(FRE13_TDg2$player1, FRE13_TDg2$player2)
FRE13_TDft2 <- as.matrix(FRE13_TDft)
numRows <- nrow(FRE13_TDft2)
numCols <- ncol(FRE13_TDft2)
FRE13_TDft3 <- FRE13_TDft2[c(2:numRows) , c(2:numCols)]
FRE13_TDTable <- graph.adjacency(FRE13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(FRE13_TDTable, vertex.label = V(FRE13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
FRE13_TD.clusterCoef <- transitivity(FRE13_TDTable, type="global") #cluster coefficient
FRE13_TD.degreeCent <- centralization.degree(FRE13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_TDftn <- as.network.matrix(FRE13_TDft)
FRE13_TD.netDensity <- network.density(FRE13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_TD.entropy <- entropy(FRE13_TDft) #entropy
FRE13_TD.netMx <- cbind(FRE13_TD.netMx, FRE13_TD.clusterCoef, FRE13_TD.degreeCent$centralization,
FRE13_TD.netDensity, FRE13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "FRE"
KIoutcome = "End of Qtr_DM"
FRE13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
FRE13_QTg2 <- data.frame(FRE13_QT)
FRE13_QTg2 <- FRE13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- FRE13_QTg2$player1
player2vector <- FRE13_QTg2$player2
FRE13_QTg3 <- FRE13_QTg2
FRE13_QTg3$p1inp2vec <- is.element(FRE13_QTg3$player1, player2vector)
FRE13_QTg3$p2inp1vec <- is.element(FRE13_QTg3$player2, player1vector)
addPlayer1 <- FRE13_QTg3[ which(FRE13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- FRE13_QTg3[ which(FRE13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
FRE13_QTg2 <- rbind(FRE13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
FRE13_QTft <- ftable(FRE13_QTg2$player1, FRE13_QTg2$player2)
FRE13_QTft2 <- as.matrix(FRE13_QTft)
numRows <- nrow(FRE13_QTft2)
numCols <- ncol(FRE13_QTft2)
FRE13_QTft3 <- FRE13_QTft2[c(2:numRows) , c(2:numCols)]
FRE13_QTTable <- graph.adjacency(FRE13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(FRE13_QTTable, vertex.label = V(FRE13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(FRE13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
FRE13_QT.clusterCoef <- transitivity(FRE13_QTTable, type="global") #cluster coefficient
FRE13_QT.degreeCent <- centralization.degree(FRE13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
FRE13_QTftn <- as.network.matrix(FRE13_QTft)
FRE13_QT.netDensity <- network.density(FRE13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
FRE13_QT.entropy <- entropy(FRE13_QTft) #entropy
FRE13_QT.netMx <- cbind(FRE13_QT.netMx, FRE13_QT.clusterCoef, FRE13_QT.degreeCent$centralization,
FRE13_QT.netDensity, FRE13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(FRE13_QT.netMx) <- varnames
#############################################################################
#GOLD COAST
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "GCFC"
KIoutcome = "Goal_F"
GCFC13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
GCFC13_Gg2 <- data.frame(GCFC13_G)
GCFC13_Gg2 <- GCFC13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_Gg2$player1
player2vector <- GCFC13_Gg2$player2
GCFC13_Gg3 <- GCFC13_Gg2
GCFC13_Gg3$p1inp2vec <- is.element(GCFC13_Gg3$player1, player2vector)
GCFC13_Gg3$p2inp1vec <- is.element(GCFC13_Gg3$player2, player1vector)
addPlayer1 <- GCFC13_Gg3[ which(GCFC13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_Gg3[ which(GCFC13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_Gg2 <- rbind(GCFC13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
GCFC13_Gft <- ftable(GCFC13_Gg2$player1, GCFC13_Gg2$player2)
GCFC13_Gft2 <- as.matrix(GCFC13_Gft)
numRows <- nrow(GCFC13_Gft2)
numCols <- ncol(GCFC13_Gft2)
GCFC13_Gft3 <- GCFC13_Gft2[c(2:numRows) , c(2:numCols)]
GCFC13_GTable <- graph.adjacency(GCFC13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(GCFC13_GTable, vertex.label = V(GCFC13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
GCFC13_G.clusterCoef <- transitivity(GCFC13_GTable, type="global") #cluster coefficient
GCFC13_G.degreeCent <- centralization.degree(GCFC13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_Gftn <- as.network.matrix(GCFC13_Gft)
GCFC13_G.netDensity <- network.density(GCFC13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_G.entropy <- entropy(GCFC13_Gft) #entropy
GCFC13_G.netMx <- cbind(GCFC13_G.netMx, GCFC13_G.clusterCoef, GCFC13_G.degreeCent$centralization,
GCFC13_G.netDensity, GCFC13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
round = 13
teamName = "GCFC"
KIoutcome = "Behind_F"
GCFC13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
GCFC13_Bg2 <- data.frame(GCFC13_B)
GCFC13_Bg2 <- GCFC13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_Bg2$player1
player2vector <- GCFC13_Bg2$player2
GCFC13_Bg3 <- GCFC13_Bg2
GCFC13_Bg3$p1inp2vec <- is.element(GCFC13_Bg3$player1, player2vector)
GCFC13_Bg3$p2inp1vec <- is.element(GCFC13_Bg3$player2, player1vector)
addPlayer1 <- GCFC13_Bg3[ which(GCFC13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_Bg3[ which(GCFC13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_Bg2 <- rbind(GCFC13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
GCFC13_Bft <- ftable(GCFC13_Bg2$player1, GCFC13_Bg2$player2)
GCFC13_Bft2 <- as.matrix(GCFC13_Bft)
numRows <- nrow(GCFC13_Bft2)
numCols <- ncol(GCFC13_Bft2)
GCFC13_Bft3 <- GCFC13_Bft2[c(2:numRows) , c(2:numCols)]
GCFC13_BTable <- graph.adjacency(GCFC13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(GCFC13_BTable, vertex.label = V(GCFC13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
GCFC13_B.clusterCoef <- transitivity(GCFC13_BTable, type="global") #cluster coefficient
GCFC13_B.degreeCent <- centralization.degree(GCFC13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_Bftn <- as.network.matrix(GCFC13_Bft)
GCFC13_B.netDensity <- network.density(GCFC13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_B.entropy <- entropy(GCFC13_Bft) #entropy
GCFC13_B.netMx <- cbind(GCFC13_B.netMx, GCFC13_B.clusterCoef, GCFC13_B.degreeCent$centralization,
GCFC13_B.netDensity, GCFC13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "GCFC"
KIoutcome = "Stoppage_F"
GCFC13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
GCFC13_SFg2 <- data.frame(GCFC13_SF)
GCFC13_SFg2 <- GCFC13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_SFg2$player1
player2vector <- GCFC13_SFg2$player2
GCFC13_SFg3 <- GCFC13_SFg2
GCFC13_SFg3$p1inp2vec <- is.element(GCFC13_SFg3$player1, player2vector)
GCFC13_SFg3$p2inp1vec <- is.element(GCFC13_SFg3$player2, player1vector)
addPlayer1 <- GCFC13_SFg3[ which(GCFC13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
varnames <- c("player1", "player2", "weight")
colnames(addPlayer1) <- varnames
GCFC13_SFg2 <- rbind(GCFC13_SFg2, addPlayer1)
#ROUND 13, FWD Stoppage graph using weighted edges
GCFC13_SFft <- ftable(GCFC13_SFg2$player1, GCFC13_SFg2$player2)
GCFC13_SFft2 <- as.matrix(GCFC13_SFft)
numRows <- nrow(GCFC13_SFft2)
numCols <- ncol(GCFC13_SFft2)
GCFC13_SFft3 <- GCFC13_SFft2[c(2:numRows) , c(1:numCols)]
GCFC13_SFTable <- graph.adjacency(GCFC13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(GCFC13_SFTable, vertex.label = V(GCFC13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
GCFC13_SF.clusterCoef <- transitivity(GCFC13_SFTable, type="global") #cluster coefficient
GCFC13_SF.degreeCent <- centralization.degree(GCFC13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_SFftn <- as.network.matrix(GCFC13_SFft)
GCFC13_SF.netDensity <- network.density(GCFC13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_SF.entropy <- entropy(GCFC13_SFft) #entropy
GCFC13_SF.netMx <- cbind(GCFC13_SF.netMx, GCFC13_SF.clusterCoef, GCFC13_SF.degreeCent$centralization,
GCFC13_SF.netDensity, GCFC13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "GCFC"
KIoutcome = "Turnover_F"
GCFC13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
GCFC13_TFg2 <- data.frame(GCFC13_TF)
GCFC13_TFg2 <- GCFC13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_TFg2$player1
player2vector <- GCFC13_TFg2$player2
GCFC13_TFg3 <- GCFC13_TFg2
GCFC13_TFg3$p1inp2vec <- is.element(GCFC13_TFg3$player1, player2vector)
GCFC13_TFg3$p2inp1vec <- is.element(GCFC13_TFg3$player2, player1vector)
addPlayer1 <- GCFC13_TFg3[ which(GCFC13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_TFg3[ which(GCFC13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_TFg2 <- rbind(GCFC13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
GCFC13_TFft <- ftable(GCFC13_TFg2$player1, GCFC13_TFg2$player2)
GCFC13_TFft2 <- as.matrix(GCFC13_TFft)
numRows <- nrow(GCFC13_TFft2)
numCols <- ncol(GCFC13_TFft2)
GCFC13_TFft3 <- GCFC13_TFft2[c(2:numRows) , c(2:numCols)]
GCFC13_TFTable <- graph.adjacency(GCFC13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(GCFC13_TFTable, vertex.label = V(GCFC13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
GCFC13_TF.clusterCoef <- transitivity(GCFC13_TFTable, type="global") #cluster coefficient
GCFC13_TF.degreeCent <- centralization.degree(GCFC13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_TFftn <- as.network.matrix(GCFC13_TFft)
GCFC13_TF.netDensity <- network.density(GCFC13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_TF.entropy <- entropy(GCFC13_TFft) #entropy
GCFC13_TF.netMx <- cbind(GCFC13_TF.netMx, GCFC13_TF.clusterCoef, GCFC13_TF.degreeCent$centralization,
GCFC13_TF.netDensity, GCFC13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
#NA
round = 13
teamName = "GCFC"
KIoutcome = "Stoppage_AM"
GCFC13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
GCFC13_SAMg2 <- data.frame(GCFC13_SAM)
GCFC13_SAMg2 <- GCFC13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_SAMg2$player1
player2vector <- GCFC13_SAMg2$player2
GCFC13_SAMg3 <- GCFC13_SAMg2
GCFC13_SAMg3$p1inp2vec <- is.element(GCFC13_SAMg3$player1, player2vector)
GCFC13_SAMg3$p2inp1vec <- is.element(GCFC13_SAMg3$player2, player1vector)
addPlayer1 <- GCFC13_SAMg3[ which(GCFC13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_SAMg3[ which(GCFC13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_SAMg2 <- rbind(GCFC13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
GCFC13_SAMft <- ftable(GCFC13_SAMg2$player1, GCFC13_SAMg2$player2)
GCFC13_SAMft2 <- as.matrix(GCFC13_SAMft)
numRows <- nrow(GCFC13_SAMft2)
numCols <- ncol(GCFC13_SAMft2)
GCFC13_SAMft3 <- GCFC13_SAMft2[c(2:numRows) , c(2:numCols)]
GCFC13_SAMTable <- graph.adjacency(GCFC13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(GCFC13_SAMTable, vertex.label = V(GCFC13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
GCFC13_SAM.clusterCoef <- transitivity(GCFC13_SAMTable, type="global") #cluster coefficient
GCFC13_SAM.degreeCent <- centralization.degree(GCFC13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_SAMftn <- as.network.matrix(GCFC13_SAMft)
GCFC13_SAM.netDensity <- network.density(GCFC13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_SAM.entropy <- entropy(GCFC13_SAMft) #entropy
GCFC13_SAM.netMx <- cbind(GCFC13_SAM.netMx, GCFC13_SAM.clusterCoef, GCFC13_SAM.degreeCent$centralization,
GCFC13_SAM.netDensity, GCFC13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "GCFC"
KIoutcome = "Turnover_AM"
GCFC13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
GCFC13_TAMg2 <- data.frame(GCFC13_TAM)
GCFC13_TAMg2 <- GCFC13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_TAMg2$player1
player2vector <- GCFC13_TAMg2$player2
GCFC13_TAMg3 <- GCFC13_TAMg2
GCFC13_TAMg3$p1inp2vec <- is.element(GCFC13_TAMg3$player1, player2vector)
GCFC13_TAMg3$p2inp1vec <- is.element(GCFC13_TAMg3$player2, player1vector)
addPlayer1 <- GCFC13_TAMg3[ which(GCFC13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_TAMg3[ which(GCFC13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_TAMg2 <- rbind(GCFC13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
GCFC13_TAMft <- ftable(GCFC13_TAMg2$player1, GCFC13_TAMg2$player2)
GCFC13_TAMft2 <- as.matrix(GCFC13_TAMft)
numRows <- nrow(GCFC13_TAMft2)
numCols <- ncol(GCFC13_TAMft2)
GCFC13_TAMft3 <- GCFC13_TAMft2[c(2:numRows) , c(2:numCols)]
GCFC13_TAMTable <- graph.adjacency(GCFC13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(GCFC13_TAMTable, vertex.label = V(GCFC13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
GCFC13_TAM.clusterCoef <- transitivity(GCFC13_TAMTable, type="global") #cluster coefficient
GCFC13_TAM.degreeCent <- centralization.degree(GCFC13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_TAMftn <- as.network.matrix(GCFC13_TAMft)
GCFC13_TAM.netDensity <- network.density(GCFC13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_TAM.entropy <- entropy(GCFC13_TAMft) #entropy
GCFC13_TAM.netMx <- cbind(GCFC13_TAM.netMx, GCFC13_TAM.clusterCoef, GCFC13_TAM.degreeCent$centralization,
GCFC13_TAM.netDensity, GCFC13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "GCFC"
KIoutcome = "Stoppage_DM"
GCFC13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
GCFC13_SDMg2 <- data.frame(GCFC13_SDM)
GCFC13_SDMg2 <- GCFC13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_SDMg2$player1
player2vector <- GCFC13_SDMg2$player2
GCFC13_SDMg3 <- GCFC13_SDMg2
GCFC13_SDMg3$p1inp2vec <- is.element(GCFC13_SDMg3$player1, player2vector)
GCFC13_SDMg3$p2inp1vec <- is.element(GCFC13_SDMg3$player2, player1vector)
addPlayer1 <- GCFC13_SDMg3[ which(GCFC13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_SDMg3[ which(GCFC13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_SDMg2 <- rbind(GCFC13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
GCFC13_SDMft <- ftable(GCFC13_SDMg2$player1, GCFC13_SDMg2$player2)
GCFC13_SDMft2 <- as.matrix(GCFC13_SDMft)
numRows <- nrow(GCFC13_SDMft2)
numCols <- ncol(GCFC13_SDMft2)
GCFC13_SDMft3 <- GCFC13_SDMft2[c(2:numRows) , c(2:numCols)]
GCFC13_SDMTable <- graph.adjacency(GCFC13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(GCFC13_SDMTable, vertex.label = V(GCFC13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
GCFC13_SDM.clusterCoef <- transitivity(GCFC13_SDMTable, type="global") #cluster coefficient
GCFC13_SDM.degreeCent <- centralization.degree(GCFC13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_SDMftn <- as.network.matrix(GCFC13_SDMft)
GCFC13_SDM.netDensity <- network.density(GCFC13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_SDM.entropy <- entropy(GCFC13_SDMft) #entropy
GCFC13_SDM.netMx <- cbind(GCFC13_SDM.netMx, GCFC13_SDM.clusterCoef, GCFC13_SDM.degreeCent$centralization,
GCFC13_SDM.netDensity, GCFC13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "GCFC"
KIoutcome = "Turnover_DM"
GCFC13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
GCFC13_TDMg2 <- data.frame(GCFC13_TDM)
GCFC13_TDMg2 <- GCFC13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_TDMg2$player1
player2vector <- GCFC13_TDMg2$player2
GCFC13_TDMg3 <- GCFC13_TDMg2
GCFC13_TDMg3$p1inp2vec <- is.element(GCFC13_TDMg3$player1, player2vector)
GCFC13_TDMg3$p2inp1vec <- is.element(GCFC13_TDMg3$player2, player1vector)
addPlayer1 <- GCFC13_TDMg3[ which(GCFC13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_TDMg3[ which(GCFC13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_TDMg2 <- rbind(GCFC13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
GCFC13_TDMft <- ftable(GCFC13_TDMg2$player1, GCFC13_TDMg2$player2)
GCFC13_TDMft2 <- as.matrix(GCFC13_TDMft)
numRows <- nrow(GCFC13_TDMft2)
numCols <- ncol(GCFC13_TDMft2)
GCFC13_TDMft3 <- GCFC13_TDMft2[c(2:numRows) , c(2:numCols)]
GCFC13_TDMTable <- graph.adjacency(GCFC13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(GCFC13_TDMTable, vertex.label = V(GCFC13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
GCFC13_TDM.clusterCoef <- transitivity(GCFC13_TDMTable, type="global") #cluster coefficient
GCFC13_TDM.degreeCent <- centralization.degree(GCFC13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_TDMftn <- as.network.matrix(GCFC13_TDMft)
GCFC13_TDM.netDensity <- network.density(GCFC13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_TDM.entropy <- entropy(GCFC13_TDMft) #entropy
GCFC13_TDM.netMx <- cbind(GCFC13_TDM.netMx, GCFC13_TDM.clusterCoef, GCFC13_TDM.degreeCent$centralization,
GCFC13_TDM.netDensity, GCFC13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "GCFC"
KIoutcome = "Stoppage_D"
GCFC13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
GCFC13_SDg2 <- data.frame(GCFC13_SD)
GCFC13_SDg2 <- GCFC13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_SDg2$player1
player2vector <- GCFC13_SDg2$player2
GCFC13_SDg3 <- GCFC13_SDg2
GCFC13_SDg3$p1inp2vec <- is.element(GCFC13_SDg3$player1, player2vector)
GCFC13_SDg3$p2inp1vec <- is.element(GCFC13_SDg3$player2, player1vector)
addPlayer1 <- GCFC13_SDg3[ which(GCFC13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_SDg3[ which(GCFC13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_SDg2 <- rbind(GCFC13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
GCFC13_SDft <- ftable(GCFC13_SDg2$player1, GCFC13_SDg2$player2)
GCFC13_SDft2 <- as.matrix(GCFC13_SDft)
numRows <- nrow(GCFC13_SDft2)
numCols <- ncol(GCFC13_SDft2)
GCFC13_SDft3 <- GCFC13_SDft2[c(2:numRows) , c(2:numCols)]
GCFC13_SDTable <- graph.adjacency(GCFC13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(GCFC13_SDTable, vertex.label = V(GCFC13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
GCFC13_SD.clusterCoef <- transitivity(GCFC13_SDTable, type="global") #cluster coefficient
GCFC13_SD.degreeCent <- centralization.degree(GCFC13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_SDftn <- as.network.matrix(GCFC13_SDft)
GCFC13_SD.netDensity <- network.density(GCFC13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_SD.entropy <- entropy(GCFC13_SDft) #entropy
GCFC13_SD.netMx <- cbind(GCFC13_SD.netMx, GCFC13_SD.clusterCoef, GCFC13_SD.degreeCent$centralization,
GCFC13_SD.netDensity, GCFC13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "GCFC"
KIoutcome = "Turnover_D"
GCFC13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
GCFC13_TDg2 <- data.frame(GCFC13_TD)
GCFC13_TDg2 <- GCFC13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_TDg2$player1
player2vector <- GCFC13_TDg2$player2
GCFC13_TDg3 <- GCFC13_TDg2
GCFC13_TDg3$p1inp2vec <- is.element(GCFC13_TDg3$player1, player2vector)
GCFC13_TDg3$p2inp1vec <- is.element(GCFC13_TDg3$player2, player1vector)
addPlayer1 <- GCFC13_TDg3[ which(GCFC13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_TDg3[ which(GCFC13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_TDg2 <- rbind(GCFC13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
GCFC13_TDft <- ftable(GCFC13_TDg2$player1, GCFC13_TDg2$player2)
GCFC13_TDft2 <- as.matrix(GCFC13_TDft)
numRows <- nrow(GCFC13_TDft2)
numCols <- ncol(GCFC13_TDft2)
GCFC13_TDft3 <- GCFC13_TDft2[c(2:numRows) , c(2:numCols)]
GCFC13_TDTable <- graph.adjacency(GCFC13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(GCFC13_TDTable, vertex.label = V(GCFC13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
GCFC13_TD.clusterCoef <- transitivity(GCFC13_TDTable, type="global") #cluster coefficient
GCFC13_TD.degreeCent <- centralization.degree(GCFC13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_TDftn <- as.network.matrix(GCFC13_TDft)
GCFC13_TD.netDensity <- network.density(GCFC13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_TD.entropy <- entropy(GCFC13_TDft) #entropy
GCFC13_TD.netMx <- cbind(GCFC13_TD.netMx, GCFC13_TD.clusterCoef, GCFC13_TD.degreeCent$centralization,
GCFC13_TD.netDensity, GCFC13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "GCFC"
KIoutcome = "End of Qtr_DM"
GCFC13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
GCFC13_QTg2 <- data.frame(GCFC13_QT)
GCFC13_QTg2 <- GCFC13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- GCFC13_QTg2$player1
player2vector <- GCFC13_QTg2$player2
GCFC13_QTg3 <- GCFC13_QTg2
GCFC13_QTg3$p1inp2vec <- is.element(GCFC13_QTg3$player1, player2vector)
GCFC13_QTg3$p2inp1vec <- is.element(GCFC13_QTg3$player2, player1vector)
addPlayer1 <- GCFC13_QTg3[ which(GCFC13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- GCFC13_QTg3[ which(GCFC13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
GCFC13_QTg2 <- rbind(GCFC13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
GCFC13_QTft <- ftable(GCFC13_QTg2$player1, GCFC13_QTg2$player2)
GCFC13_QTft2 <- as.matrix(GCFC13_QTft)
numRows <- nrow(GCFC13_QTft2)
numCols <- ncol(GCFC13_QTft2)
GCFC13_QTft3 <- GCFC13_QTft2[c(2:numRows) , c(2:numCols)]
GCFC13_QTTable <- graph.adjacency(GCFC13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(GCFC13_QTTable, vertex.label = V(GCFC13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(GCFC13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
GCFC13_QT.clusterCoef <- transitivity(GCFC13_QTTable, type="global") #cluster coefficient
GCFC13_QT.degreeCent <- centralization.degree(GCFC13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
GCFC13_QTftn <- as.network.matrix(GCFC13_QTft)
GCFC13_QT.netDensity <- network.density(GCFC13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
GCFC13_QT.entropy <- entropy(GCFC13_QTft) #entropy
GCFC13_QT.netMx <- cbind(GCFC13_QT.netMx, GCFC13_QT.clusterCoef, GCFC13_QT.degreeCent$centralization,
GCFC13_QT.netDensity, GCFC13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(GCFC13_QT.netMx) <- varnames
#############################################################################
#HAWTHORN
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
round = 13
teamName = "HAW"
KIoutcome = "Goal_F"
HAW13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
HAW13_Gg2 <- data.frame(HAW13_G)
HAW13_Gg2 <- HAW13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_Gg2$player1
player2vector <- HAW13_Gg2$player2
HAW13_Gg3 <- HAW13_Gg2
HAW13_Gg3$p1inp2vec <- is.element(HAW13_Gg3$player1, player2vector)
HAW13_Gg3$p2inp1vec <- is.element(HAW13_Gg3$player2, player1vector)
addPlayer1 <- HAW13_Gg3[ which(HAW13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_Gg3[ which(HAW13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_Gg2 <- rbind(HAW13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
HAW13_Gft <- ftable(HAW13_Gg2$player1, HAW13_Gg2$player2)
HAW13_Gft2 <- as.matrix(HAW13_Gft)
numRows <- nrow(HAW13_Gft2)
numCols <- ncol(HAW13_Gft2)
HAW13_Gft3 <- HAW13_Gft2[c(2:numRows) , c(2:numCols)]
HAW13_GTable <- graph.adjacency(HAW13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(HAW13_GTable, vertex.label = V(HAW13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
HAW13_G.clusterCoef <- transitivity(HAW13_GTable, type="global") #cluster coefficient
HAW13_G.degreeCent <- centralization.degree(HAW13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_Gftn <- as.network.matrix(HAW13_Gft)
HAW13_G.netDensity <- network.density(HAW13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_G.entropy <- entropy(HAW13_Gft) #entropy
HAW13_G.netMx <- cbind(HAW13_G.netMx, HAW13_G.clusterCoef, HAW13_G.degreeCent$centralization,
HAW13_G.netDensity, HAW13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
#NA
round = 13
teamName = "HAW"
KIoutcome = "Behind_F"
HAW13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
HAW13_Bg2 <- data.frame(HAW13_B)
HAW13_Bg2 <- HAW13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_Bg2$player1
player2vector <- HAW13_Bg2$player2
HAW13_Bg3 <- HAW13_Bg2
HAW13_Bg3$p1inp2vec <- is.element(HAW13_Bg3$player1, player2vector)
HAW13_Bg3$p2inp1vec <- is.element(HAW13_Bg3$player2, player1vector)
addPlayer1 <- HAW13_Bg3[ which(HAW13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
varnames <- c("player1", "player2", "weight")
colnames(addPlayer1) <- varnames
HAW13_Bg2 <- rbind(HAW13_Bg2, addPlayer1)
#ROUND 13, Behind graph using weighted edges
HAW13_Bft <- ftable(HAW13_Bg2$player1, HAW13_Bg2$player2)
HAW13_Bft2 <- as.matrix(HAW13_Bft)
numRows <- nrow(HAW13_Bft2)
numCols <- ncol(HAW13_Bft2)
HAW13_Bft3 <- HAW13_Bft2[c(2:numRows) , c(1:numCols)]
HAW13_BTable <- graph.adjacency(HAW13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(HAW13_BTable, vertex.label = V(HAW13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
HAW13_B.clusterCoef <- transitivity(HAW13_BTable, type="global") #cluster coefficient
HAW13_B.degreeCent <- centralization.degree(HAW13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_Bftn <- as.network.matrix(HAW13_Bft)
HAW13_B.netDensity <- network.density(HAW13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_B.entropy <- entropy(HAW13_Bft) #entropy
HAW13_B.netMx <- cbind(HAW13_B.netMx, HAW13_B.clusterCoef, HAW13_B.degreeCent$centralization,
HAW13_B.netDensity, HAW13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "HAW"
KIoutcome = "Stoppage_F"
HAW13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
HAW13_SFg2 <- data.frame(HAW13_SF)
HAW13_SFg2 <- HAW13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_SFg2$player1
player2vector <- HAW13_SFg2$player2
HAW13_SFg3 <- HAW13_SFg2
HAW13_SFg3$p1inp2vec <- is.element(HAW13_SFg3$player1, player2vector)
HAW13_SFg3$p2inp1vec <- is.element(HAW13_SFg3$player2, player1vector)
addPlayer1 <- HAW13_SFg3[ which(HAW13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_SFg3[ which(HAW13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_SFg2 <- rbind(HAW13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
HAW13_SFft <- ftable(HAW13_SFg2$player1, HAW13_SFg2$player2)
HAW13_SFft2 <- as.matrix(HAW13_SFft)
numRows <- nrow(HAW13_SFft2)
numCols <- ncol(HAW13_SFft2)
HAW13_SFft3 <- HAW13_SFft2[c(2:numRows) , c(2:numCols)]
HAW13_SFTable <- graph.adjacency(HAW13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(HAW13_SFTable, vertex.label = V(HAW13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
HAW13_SF.clusterCoef <- transitivity(HAW13_SFTable, type="global") #cluster coefficient
HAW13_SF.degreeCent <- centralization.degree(HAW13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_SFftn <- as.network.matrix(HAW13_SFft)
HAW13_SF.netDensity <- network.density(HAW13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_SF.entropy <- entropy(HAW13_SFft) #entropy
HAW13_SF.netMx <- cbind(HAW13_SF.netMx, HAW13_SF.clusterCoef, HAW13_SF.degreeCent$centralization,
HAW13_SF.netDensity, HAW13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "HAW"
KIoutcome = "Turnover_F"
HAW13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
HAW13_TFg2 <- data.frame(HAW13_TF)
HAW13_TFg2 <- HAW13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_TFg2$player1
player2vector <- HAW13_TFg2$player2
HAW13_TFg3 <- HAW13_TFg2
HAW13_TFg3$p1inp2vec <- is.element(HAW13_TFg3$player1, player2vector)
HAW13_TFg3$p2inp1vec <- is.element(HAW13_TFg3$player2, player1vector)
addPlayer1 <- HAW13_TFg3[ which(HAW13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_TFg3[ which(HAW13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_TFg2 <- rbind(HAW13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
HAW13_TFft <- ftable(HAW13_TFg2$player1, HAW13_TFg2$player2)
HAW13_TFft2 <- as.matrix(HAW13_TFft)
numRows <- nrow(HAW13_TFft2)
numCols <- ncol(HAW13_TFft2)
HAW13_TFft3 <- HAW13_TFft2[c(2:numRows) , c(2:numCols)]
HAW13_TFTable <- graph.adjacency(HAW13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(HAW13_TFTable, vertex.label = V(HAW13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
HAW13_TF.clusterCoef <- transitivity(HAW13_TFTable, type="global") #cluster coefficient
HAW13_TF.degreeCent <- centralization.degree(HAW13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_TFftn <- as.network.matrix(HAW13_TFft)
HAW13_TF.netDensity <- network.density(HAW13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_TF.entropy <- entropy(HAW13_TFft) #entropy
HAW13_TF.netMx <- cbind(HAW13_TF.netMx, HAW13_TF.clusterCoef, HAW13_TF.degreeCent$centralization,
HAW13_TF.netDensity, HAW13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
round = 13
teamName = "HAW"
KIoutcome = "Stoppage_AM"
HAW13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
HAW13_SAMg2 <- data.frame(HAW13_SAM)
HAW13_SAMg2 <- HAW13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_SAMg2$player1
player2vector <- HAW13_SAMg2$player2
HAW13_SAMg3 <- HAW13_SAMg2
HAW13_SAMg3$p1inp2vec <- is.element(HAW13_SAMg3$player1, player2vector)
HAW13_SAMg3$p2inp1vec <- is.element(HAW13_SAMg3$player2, player1vector)
addPlayer1 <- HAW13_SAMg3[ which(HAW13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_SAMg3[ which(HAW13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_SAMg2 <- rbind(HAW13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
HAW13_SAMft <- ftable(HAW13_SAMg2$player1, HAW13_SAMg2$player2)
HAW13_SAMft2 <- as.matrix(HAW13_SAMft)
numRows <- nrow(HAW13_SAMft2)
numCols <- ncol(HAW13_SAMft2)
HAW13_SAMft3 <- HAW13_SAMft2[c(2:numRows) , c(2:numCols)]
HAW13_SAMTable <- graph.adjacency(HAW13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(HAW13_SAMTable, vertex.label = V(HAW13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
HAW13_SAM.clusterCoef <- transitivity(HAW13_SAMTable, type="global") #cluster coefficient
HAW13_SAM.degreeCent <- centralization.degree(HAW13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_SAMftn <- as.network.matrix(HAW13_SAMft)
HAW13_SAM.netDensity <- network.density(HAW13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_SAM.entropy <- entropy(HAW13_SAMft) #entropy
HAW13_SAM.netMx <- cbind(HAW13_SAM.netMx, HAW13_SAM.clusterCoef, HAW13_SAM.degreeCent$centralization,
HAW13_SAM.netDensity, HAW13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
#NA
round = 13
teamName = "HAW"
KIoutcome = "Turnover_AM"
HAW13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
HAW13_TAMg2 <- data.frame(HAW13_TAM)
HAW13_TAMg2 <- HAW13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_TAMg2$player1
player2vector <- HAW13_TAMg2$player2
HAW13_TAMg3 <- HAW13_TAMg2
HAW13_TAMg3$p1inp2vec <- is.element(HAW13_TAMg3$player1, player2vector)
HAW13_TAMg3$p2inp1vec <- is.element(HAW13_TAMg3$player2, player1vector)
addPlayer1 <- HAW13_TAMg3[ which(HAW13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_TAMg3[ which(HAW13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_TAMg2 <- rbind(HAW13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
HAW13_TAMft <- ftable(HAW13_TAMg2$player1, HAW13_TAMg2$player2)
HAW13_TAMft2 <- as.matrix(HAW13_TAMft)
numRows <- nrow(HAW13_TAMft2)
numCols <- ncol(HAW13_TAMft2)
HAW13_TAMft3 <- HAW13_TAMft2[c(2:numRows) , c(2:numCols)]
HAW13_TAMTable <- graph.adjacency(HAW13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(HAW13_TAMTable, vertex.label = V(HAW13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
HAW13_TAM.clusterCoef <- transitivity(HAW13_TAMTable, type="global") #cluster coefficient
HAW13_TAM.degreeCent <- centralization.degree(HAW13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_TAMftn <- as.network.matrix(HAW13_TAMft)
HAW13_TAM.netDensity <- network.density(HAW13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_TAM.entropy <- entropy(HAW13_TAMft) #entropy
HAW13_TAM.netMx <- cbind(HAW13_TAM.netMx, HAW13_TAM.clusterCoef, HAW13_TAM.degreeCent$centralization,
HAW13_TAM.netDensity, HAW13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
#NA
round = 13
teamName = "HAW"
KIoutcome = "Stoppage_DM"
HAW13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
HAW13_SDMg2 <- data.frame(HAW13_SDM)
HAW13_SDMg2 <- HAW13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_SDMg2$player1
player2vector <- HAW13_SDMg2$player2
HAW13_SDMg3 <- HAW13_SDMg2
HAW13_SDMg3$p1inp2vec <- is.element(HAW13_SDMg3$player1, player2vector)
HAW13_SDMg3$p2inp1vec <- is.element(HAW13_SDMg3$player2, player1vector)
addPlayer1 <- HAW13_SDMg3[ which(HAW13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_SDMg3[ which(HAW13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_SDMg2 <- rbind(HAW13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
HAW13_SDMft <- ftable(HAW13_SDMg2$player1, HAW13_SDMg2$player2)
HAW13_SDMft2 <- as.matrix(HAW13_SDMft)
numRows <- nrow(HAW13_SDMft2)
numCols <- ncol(HAW13_SDMft2)
HAW13_SDMft3 <- HAW13_SDMft2[c(2:numRows) , c(2:numCols)]
HAW13_SDMTable <- graph.adjacency(HAW13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(HAW13_SDMTable, vertex.label = V(HAW13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
HAW13_SDM.clusterCoef <- transitivity(HAW13_SDMTable, type="global") #cluster coefficient
HAW13_SDM.degreeCent <- centralization.degree(HAW13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_SDMftn <- as.network.matrix(HAW13_SDMft)
HAW13_SDM.netDensity <- network.density(HAW13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_SDM.entropy <- entropy(HAW13_SDMft) #entropy
HAW13_SDM.netMx <- cbind(HAW13_SDM.netMx, HAW13_SDM.clusterCoef, HAW13_SDM.degreeCent$centralization,
HAW13_SDM.netDensity, HAW13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "HAW"
KIoutcome = "Turnover_DM"
HAW13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
HAW13_TDMg2 <- data.frame(HAW13_TDM)
HAW13_TDMg2 <- HAW13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_TDMg2$player1
player2vector <- HAW13_TDMg2$player2
HAW13_TDMg3 <- HAW13_TDMg2
HAW13_TDMg3$p1inp2vec <- is.element(HAW13_TDMg3$player1, player2vector)
HAW13_TDMg3$p2inp1vec <- is.element(HAW13_TDMg3$player2, player1vector)
addPlayer1 <- HAW13_TDMg3[ which(HAW13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_TDMg3[ which(HAW13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_TDMg2 <- rbind(HAW13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
HAW13_TDMft <- ftable(HAW13_TDMg2$player1, HAW13_TDMg2$player2)
HAW13_TDMft2 <- as.matrix(HAW13_TDMft)
numRows <- nrow(HAW13_TDMft2)
numCols <- ncol(HAW13_TDMft2)
HAW13_TDMft3 <- HAW13_TDMft2[c(2:numRows) , c(2:numCols)]
HAW13_TDMTable <- graph.adjacency(HAW13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(HAW13_TDMTable, vertex.label = V(HAW13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
HAW13_TDM.clusterCoef <- transitivity(HAW13_TDMTable, type="global") #cluster coefficient
HAW13_TDM.degreeCent <- centralization.degree(HAW13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_TDMftn <- as.network.matrix(HAW13_TDMft)
HAW13_TDM.netDensity <- network.density(HAW13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_TDM.entropy <- entropy(HAW13_TDMft) #entropy
HAW13_TDM.netMx <- cbind(HAW13_TDM.netMx, HAW13_TDM.clusterCoef, HAW13_TDM.degreeCent$centralization,
HAW13_TDM.netDensity, HAW13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "HAW"
KIoutcome = "Stoppage_D"
HAW13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
HAW13_SDg2 <- data.frame(HAW13_SD)
HAW13_SDg2 <- HAW13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_SDg2$player1
player2vector <- HAW13_SDg2$player2
HAW13_SDg3 <- HAW13_SDg2
HAW13_SDg3$p1inp2vec <- is.element(HAW13_SDg3$player1, player2vector)
HAW13_SDg3$p2inp1vec <- is.element(HAW13_SDg3$player2, player1vector)
addPlayer1 <- HAW13_SDg3[ which(HAW13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_SDg3[ which(HAW13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_SDg2 <- rbind(HAW13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
HAW13_SDft <- ftable(HAW13_SDg2$player1, HAW13_SDg2$player2)
HAW13_SDft2 <- as.matrix(HAW13_SDft)
numRows <- nrow(HAW13_SDft2)
numCols <- ncol(HAW13_SDft2)
HAW13_SDft3 <- HAW13_SDft2[c(2:numRows) , c(2:numCols)]
HAW13_SDTable <- graph.adjacency(HAW13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(HAW13_SDTable, vertex.label = V(HAW13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
HAW13_SD.clusterCoef <- transitivity(HAW13_SDTable, type="global") #cluster coefficient
HAW13_SD.degreeCent <- centralization.degree(HAW13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_SDftn <- as.network.matrix(HAW13_SDft)
HAW13_SD.netDensity <- network.density(HAW13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_SD.entropy <- entropy(HAW13_SDft) #entropy
HAW13_SD.netMx <- cbind(HAW13_SD.netMx, HAW13_SD.clusterCoef, HAW13_SD.degreeCent$centralization,
HAW13_SD.netDensity, HAW13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "HAW"
KIoutcome = "Turnover_D"
HAW13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
HAW13_TDg2 <- data.frame(HAW13_TD)
HAW13_TDg2 <- HAW13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_TDg2$player1
player2vector <- HAW13_TDg2$player2
HAW13_TDg3 <- HAW13_TDg2
HAW13_TDg3$p1inp2vec <- is.element(HAW13_TDg3$player1, player2vector)
HAW13_TDg3$p2inp1vec <- is.element(HAW13_TDg3$player2, player1vector)
addPlayer1 <- HAW13_TDg3[ which(HAW13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_TDg3[ which(HAW13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_TDg2 <- rbind(HAW13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
HAW13_TDft <- ftable(HAW13_TDg2$player1, HAW13_TDg2$player2)
HAW13_TDft2 <- as.matrix(HAW13_TDft)
numRows <- nrow(HAW13_TDft2)
numCols <- ncol(HAW13_TDft2)
HAW13_TDft3 <- HAW13_TDft2[c(2:numRows) , c(2:numCols)]
HAW13_TDTable <- graph.adjacency(HAW13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(HAW13_TDTable, vertex.label = V(HAW13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
HAW13_TD.clusterCoef <- transitivity(HAW13_TDTable, type="global") #cluster coefficient
HAW13_TD.degreeCent <- centralization.degree(HAW13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_TDftn <- as.network.matrix(HAW13_TDft)
HAW13_TD.netDensity <- network.density(HAW13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_TD.entropy <- entropy(HAW13_TDft) #entropy
HAW13_TD.netMx <- cbind(HAW13_TD.netMx, HAW13_TD.clusterCoef, HAW13_TD.degreeCent$centralization,
HAW13_TD.netDensity, HAW13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "HAW"
KIoutcome = "End of Qtr_DM"
HAW13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
HAW13_QTg2 <- data.frame(HAW13_QT)
HAW13_QTg2 <- HAW13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- HAW13_QTg2$player1
player2vector <- HAW13_QTg2$player2
HAW13_QTg3 <- HAW13_QTg2
HAW13_QTg3$p1inp2vec <- is.element(HAW13_QTg3$player1, player2vector)
HAW13_QTg3$p2inp1vec <- is.element(HAW13_QTg3$player2, player1vector)
addPlayer1 <- HAW13_QTg3[ which(HAW13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- HAW13_QTg3[ which(HAW13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
HAW13_QTg2 <- rbind(HAW13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
HAW13_QTft <- ftable(HAW13_QTg2$player1, HAW13_QTg2$player2)
HAW13_QTft2 <- as.matrix(HAW13_QTft)
numRows <- nrow(HAW13_QTft2)
numCols <- ncol(HAW13_QTft2)
HAW13_QTft3 <- HAW13_QTft2[c(2:numRows) , c(2:numCols)]
HAW13_QTTable <- graph.adjacency(HAW13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(HAW13_QTTable, vertex.label = V(HAW13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(HAW13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
HAW13_QT.clusterCoef <- transitivity(HAW13_QTTable, type="global") #cluster coefficient
HAW13_QT.degreeCent <- centralization.degree(HAW13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
HAW13_QTftn <- as.network.matrix(HAW13_QTft)
HAW13_QT.netDensity <- network.density(HAW13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
HAW13_QT.entropy <- entropy(HAW13_QTft) #entropy
HAW13_QT.netMx <- cbind(HAW13_QT.netMx, HAW13_QT.clusterCoef, HAW13_QT.degreeCent$centralization,
HAW13_QT.netDensity, HAW13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(HAW13_QT.netMx) <- varnames
#############################################################################
#RICHMOND
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "RICH"
KIoutcome = "Goal_F"
RICH13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
RICH13_Gg2 <- data.frame(RICH13_G)
RICH13_Gg2 <- RICH13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_Gg2$player1
player2vector <- RICH13_Gg2$player2
RICH13_Gg3 <- RICH13_Gg2
RICH13_Gg3$p1inp2vec <- is.element(RICH13_Gg3$player1, player2vector)
RICH13_Gg3$p2inp1vec <- is.element(RICH13_Gg3$player2, player1vector)
addPlayer1 <- RICH13_Gg3[ which(RICH13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_Gg3[ which(RICH13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_Gg2 <- rbind(RICH13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
RICH13_Gft <- ftable(RICH13_Gg2$player1, RICH13_Gg2$player2)
RICH13_Gft2 <- as.matrix(RICH13_Gft)
numRows <- nrow(RICH13_Gft2)
numCols <- ncol(RICH13_Gft2)
RICH13_Gft3 <- RICH13_Gft2[c(2:numRows) , c(2:numCols)]
RICH13_GTable <- graph.adjacency(RICH13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(RICH13_GTable, vertex.label = V(RICH13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
RICH13_G.clusterCoef <- transitivity(RICH13_GTable, type="global") #cluster coefficient
RICH13_G.degreeCent <- centralization.degree(RICH13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_Gftn <- as.network.matrix(RICH13_Gft)
RICH13_G.netDensity <- network.density(RICH13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_G.entropy <- entropy(RICH13_Gft) #entropy
RICH13_G.netMx <- cbind(RICH13_G.netMx, RICH13_G.clusterCoef, RICH13_G.degreeCent$centralization,
RICH13_G.netDensity, RICH13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
round = 13
teamName = "RICH"
KIoutcome = "Behind_F"
RICH13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
RICH13_Bg2 <- data.frame(RICH13_B)
RICH13_Bg2 <- RICH13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_Bg2$player1
player2vector <- RICH13_Bg2$player2
RICH13_Bg3 <- RICH13_Bg2
RICH13_Bg3$p1inp2vec <- is.element(RICH13_Bg3$player1, player2vector)
RICH13_Bg3$p2inp1vec <- is.element(RICH13_Bg3$player2, player1vector)
addPlayer1 <- RICH13_Bg3[ which(RICH13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_Bg3[ which(RICH13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_Bg2 <- rbind(RICH13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
RICH13_Bft <- ftable(RICH13_Bg2$player1, RICH13_Bg2$player2)
RICH13_Bft2 <- as.matrix(RICH13_Bft)
numRows <- nrow(RICH13_Bft2)
numCols <- ncol(RICH13_Bft2)
RICH13_Bft3 <- RICH13_Bft2[c(2:numRows) , c(2:numCols)]
RICH13_BTable <- graph.adjacency(RICH13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(RICH13_BTable, vertex.label = V(RICH13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
RICH13_B.clusterCoef <- transitivity(RICH13_BTable, type="global") #cluster coefficient
RICH13_B.degreeCent <- centralization.degree(RICH13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_Bftn <- as.network.matrix(RICH13_Bft)
RICH13_B.netDensity <- network.density(RICH13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_B.entropy <- entropy(RICH13_Bft) #entropy
RICH13_B.netMx <- cbind(RICH13_B.netMx, RICH13_B.clusterCoef, RICH13_B.degreeCent$centralization,
RICH13_B.netDensity, RICH13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "RICH"
KIoutcome = "Stoppage_F"
RICH13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
RICH13_SFg2 <- data.frame(RICH13_SF)
RICH13_SFg2 <- RICH13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_SFg2$player1
player2vector <- RICH13_SFg2$player2
RICH13_SFg3 <- RICH13_SFg2
RICH13_SFg3$p1inp2vec <- is.element(RICH13_SFg3$player1, player2vector)
RICH13_SFg3$p2inp1vec <- is.element(RICH13_SFg3$player2, player1vector)
addPlayer1 <- RICH13_SFg3[ which(RICH13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_SFg3[ which(RICH13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_SFg2 <- rbind(RICH13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
RICH13_SFft <- ftable(RICH13_SFg2$player1, RICH13_SFg2$player2)
RICH13_SFft2 <- as.matrix(RICH13_SFft)
numRows <- nrow(RICH13_SFft2)
numCols <- ncol(RICH13_SFft2)
RICH13_SFft3 <- RICH13_SFft2[c(2:numRows) , c(2:numCols)]
RICH13_SFTable <- graph.adjacency(RICH13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(RICH13_SFTable, vertex.label = V(RICH13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
RICH13_SF.clusterCoef <- transitivity(RICH13_SFTable, type="global") #cluster coefficient
RICH13_SF.degreeCent <- centralization.degree(RICH13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_SFftn <- as.network.matrix(RICH13_SFft)
RICH13_SF.netDensity <- network.density(RICH13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_SF.entropy <- entropy(RICH13_SFft) #entropy
RICH13_SF.netMx <- cbind(RICH13_SF.netMx, RICH13_SF.clusterCoef, RICH13_SF.degreeCent$centralization,
RICH13_SF.netDensity, RICH13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
#NA
round = 13
teamName = "RICH"
KIoutcome = "Turnover_F"
RICH13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
RICH13_TFg2 <- data.frame(RICH13_TF)
RICH13_TFg2 <- RICH13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_TFg2$player1
player2vector <- RICH13_TFg2$player2
RICH13_TFg3 <- RICH13_TFg2
RICH13_TFg3$p1inp2vec <- is.element(RICH13_TFg3$player1, player2vector)
RICH13_TFg3$p2inp1vec <- is.element(RICH13_TFg3$player2, player1vector)
addPlayer1 <- RICH13_TFg3[ which(RICH13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_TFg3[ which(RICH13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_TFg2 <- rbind(RICH13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
RICH13_TFft <- ftable(RICH13_TFg2$player1, RICH13_TFg2$player2)
RICH13_TFft2 <- as.matrix(RICH13_TFft)
numRows <- nrow(RICH13_TFft2)
numCols <- ncol(RICH13_TFft2)
RICH13_TFft3 <- RICH13_TFft2[c(2:numRows) , c(2:numCols)]
RICH13_TFTable <- graph.adjacency(RICH13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(RICH13_TFTable, vertex.label = V(RICH13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
RICH13_TF.clusterCoef <- transitivity(RICH13_TFTable, type="global") #cluster coefficient
RICH13_TF.degreeCent <- centralization.degree(RICH13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_TFftn <- as.network.matrix(RICH13_TFft)
RICH13_TF.netDensity <- network.density(RICH13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_TF.entropy <- entropy(RICH13_TFft) #entropy
RICH13_TF.netMx <- cbind(RICH13_TF.netMx, RICH13_TF.clusterCoef, RICH13_TF.degreeCent$centralization,
RICH13_TF.netDensity, RICH13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
round = 13
teamName = "RICH"
KIoutcome = "Stoppage_AM"
RICH13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
RICH13_SAMg2 <- data.frame(RICH13_SAM)
RICH13_SAMg2 <- RICH13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_SAMg2$player1
player2vector <- RICH13_SAMg2$player2
RICH13_SAMg3 <- RICH13_SAMg2
RICH13_SAMg3$p1inp2vec <- is.element(RICH13_SAMg3$player1, player2vector)
RICH13_SAMg3$p2inp1vec <- is.element(RICH13_SAMg3$player2, player1vector)
addPlayer1 <- RICH13_SAMg3[ which(RICH13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_SAMg3[ which(RICH13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(empty, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_SAMg2 <- rbind(RICH13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
RICH13_SAMft <- ftable(RICH13_SAMg2$player1, RICH13_SAMg2$player2)
RICH13_SAMft2 <- as.matrix(RICH13_SAMft)
numRows <- nrow(RICH13_SAMft2)
numCols <- ncol(RICH13_SAMft2)
RICH13_SAMft3 <- RICH13_SAMft2[c(2:numRows) , c(2:numCols)]
RICH13_SAMTable <- graph.adjacency(RICH13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(RICH13_SAMTable, vertex.label = V(RICH13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
RICH13_SAM.clusterCoef <- transitivity(RICH13_SAMTable, type="global") #cluster coefficient
RICH13_SAM.degreeCent <- centralization.degree(RICH13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_SAMftn <- as.network.matrix(RICH13_SAMft)
RICH13_SAM.netDensity <- network.density(RICH13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_SAM.entropy <- entropy(RICH13_SAMft) #entropy
RICH13_SAM.netMx <- cbind(RICH13_SAM.netMx, RICH13_SAM.clusterCoef, RICH13_SAM.degreeCent$centralization,
RICH13_SAM.netDensity, RICH13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "RICH"
KIoutcome = "Turnover_AM"
RICH13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
RICH13_TAMg2 <- data.frame(RICH13_TAM)
RICH13_TAMg2 <- RICH13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_TAMg2$player1
player2vector <- RICH13_TAMg2$player2
RICH13_TAMg3 <- RICH13_TAMg2
RICH13_TAMg3$p1inp2vec <- is.element(RICH13_TAMg3$player1, player2vector)
RICH13_TAMg3$p2inp1vec <- is.element(RICH13_TAMg3$player2, player1vector)
addPlayer1 <- RICH13_TAMg3[ which(RICH13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_TAMg3[ which(RICH13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_TAMg2 <- rbind(RICH13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
RICH13_TAMft <- ftable(RICH13_TAMg2$player1, RICH13_TAMg2$player2)
RICH13_TAMft2 <- as.matrix(RICH13_TAMft)
numRows <- nrow(RICH13_TAMft2)
numCols <- ncol(RICH13_TAMft2)
RICH13_TAMft3 <- RICH13_TAMft2[c(2:numRows) , c(2:numCols)]
RICH13_TAMTable <- graph.adjacency(RICH13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(RICH13_TAMTable, vertex.label = V(RICH13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
RICH13_TAM.clusterCoef <- transitivity(RICH13_TAMTable, type="global") #cluster coefficient
RICH13_TAM.degreeCent <- centralization.degree(RICH13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_TAMftn <- as.network.matrix(RICH13_TAMft)
RICH13_TAM.netDensity <- network.density(RICH13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_TAM.entropy <- entropy(RICH13_TAMft) #entropy
RICH13_TAM.netMx <- cbind(RICH13_TAM.netMx, RICH13_TAM.clusterCoef, RICH13_TAM.degreeCent$centralization,
RICH13_TAM.netDensity, RICH13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "RICH"
KIoutcome = "Stoppage_DM"
RICH13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
RICH13_SDMg2 <- data.frame(RICH13_SDM)
RICH13_SDMg2 <- RICH13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_SDMg2$player1
player2vector <- RICH13_SDMg2$player2
RICH13_SDMg3 <- RICH13_SDMg2
RICH13_SDMg3$p1inp2vec <- is.element(RICH13_SDMg3$player1, player2vector)
RICH13_SDMg3$p2inp1vec <- is.element(RICH13_SDMg3$player2, player1vector)
addPlayer1 <- RICH13_SDMg3[ which(RICH13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_SDMg3[ which(RICH13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_SDMg2 <- rbind(RICH13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
RICH13_SDMft <- ftable(RICH13_SDMg2$player1, RICH13_SDMg2$player2)
RICH13_SDMft2 <- as.matrix(RICH13_SDMft)
numRows <- nrow(RICH13_SDMft2)
numCols <- ncol(RICH13_SDMft2)
RICH13_SDMft3 <- RICH13_SDMft2[c(2:numRows) , c(2:numCols)]
RICH13_SDMTable <- graph.adjacency(RICH13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(RICH13_SDMTable, vertex.label = V(RICH13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
RICH13_SDM.clusterCoef <- transitivity(RICH13_SDMTable, type="global") #cluster coefficient
RICH13_SDM.degreeCent <- centralization.degree(RICH13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_SDMftn <- as.network.matrix(RICH13_SDMft)
RICH13_SDM.netDensity <- network.density(RICH13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_SDM.entropy <- entropy(RICH13_SDMft) #entropy
RICH13_SDM.netMx <- cbind(RICH13_SDM.netMx, RICH13_SDM.clusterCoef, RICH13_SDM.degreeCent$centralization,
RICH13_SDM.netDensity, RICH13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "RICH"
KIoutcome = "Turnover_DM"
RICH13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
RICH13_TDMg2 <- data.frame(RICH13_TDM)
RICH13_TDMg2 <- RICH13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_TDMg2$player1
player2vector <- RICH13_TDMg2$player2
RICH13_TDMg3 <- RICH13_TDMg2
RICH13_TDMg3$p1inp2vec <- is.element(RICH13_TDMg3$player1, player2vector)
RICH13_TDMg3$p2inp1vec <- is.element(RICH13_TDMg3$player2, player1vector)
addPlayer1 <- RICH13_TDMg3[ which(RICH13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_TDMg3[ which(RICH13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_TDMg2 <- rbind(RICH13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
RICH13_TDMft <- ftable(RICH13_TDMg2$player1, RICH13_TDMg2$player2)
RICH13_TDMft2 <- as.matrix(RICH13_TDMft)
numRows <- nrow(RICH13_TDMft2)
numCols <- ncol(RICH13_TDMft2)
RICH13_TDMft3 <- RICH13_TDMft2[c(2:numRows) , c(2:numCols)]
RICH13_TDMTable <- graph.adjacency(RICH13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(RICH13_TDMTable, vertex.label = V(RICH13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
RICH13_TDM.clusterCoef <- transitivity(RICH13_TDMTable, type="global") #cluster coefficient
RICH13_TDM.degreeCent <- centralization.degree(RICH13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_TDMftn <- as.network.matrix(RICH13_TDMft)
RICH13_TDM.netDensity <- network.density(RICH13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_TDM.entropy <- entropy(RICH13_TDMft) #entropy
RICH13_TDM.netMx <- cbind(RICH13_TDM.netMx, RICH13_TDM.clusterCoef, RICH13_TDM.degreeCent$centralization,
RICH13_TDM.netDensity, RICH13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "RICH"
KIoutcome = "Stoppage_D"
RICH13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
RICH13_SDg2 <- data.frame(RICH13_SD)
RICH13_SDg2 <- RICH13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_SDg2$player1
player2vector <- RICH13_SDg2$player2
RICH13_SDg3 <- RICH13_SDg2
RICH13_SDg3$p1inp2vec <- is.element(RICH13_SDg3$player1, player2vector)
RICH13_SDg3$p2inp1vec <- is.element(RICH13_SDg3$player2, player1vector)
addPlayer1 <- RICH13_SDg3[ which(RICH13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_SDg3[ which(RICH13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_SDg2 <- rbind(RICH13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
RICH13_SDft <- ftable(RICH13_SDg2$player1, RICH13_SDg2$player2)
RICH13_SDft2 <- as.matrix(RICH13_SDft)
numRows <- nrow(RICH13_SDft2)
numCols <- ncol(RICH13_SDft2)
RICH13_SDft3 <- RICH13_SDft2[c(2:numRows) , c(2:numCols)]
RICH13_SDTable <- graph.adjacency(RICH13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(RICH13_SDTable, vertex.label = V(RICH13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
RICH13_SD.clusterCoef <- transitivity(RICH13_SDTable, type="global") #cluster coefficient
RICH13_SD.degreeCent <- centralization.degree(RICH13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_SDftn <- as.network.matrix(RICH13_SDft)
RICH13_SD.netDensity <- network.density(RICH13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_SD.entropy <- entropy(RICH13_SDft) #entropy
RICH13_SD.netMx <- cbind(RICH13_SD.netMx, RICH13_SD.clusterCoef, RICH13_SD.degreeCent$centralization,
RICH13_SD.netDensity, RICH13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "RICH"
KIoutcome = "Turnover_D"
RICH13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
RICH13_TDg2 <- data.frame(RICH13_TD)
RICH13_TDg2 <- RICH13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_TDg2$player1
player2vector <- RICH13_TDg2$player2
RICH13_TDg3 <- RICH13_TDg2
RICH13_TDg3$p1inp2vec <- is.element(RICH13_TDg3$player1, player2vector)
RICH13_TDg3$p2inp1vec <- is.element(RICH13_TDg3$player2, player1vector)
addPlayer1 <- RICH13_TDg3[ which(RICH13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_TDg3[ which(RICH13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_TDg2 <- rbind(RICH13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
RICH13_TDft <- ftable(RICH13_TDg2$player1, RICH13_TDg2$player2)
RICH13_TDft2 <- as.matrix(RICH13_TDft)
numRows <- nrow(RICH13_TDft2)
numCols <- ncol(RICH13_TDft2)
RICH13_TDft3 <- RICH13_TDft2[c(2:numRows) , c(2:numCols)]
RICH13_TDTable <- graph.adjacency(RICH13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(RICH13_TDTable, vertex.label = V(RICH13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
RICH13_TD.clusterCoef <- transitivity(RICH13_TDTable, type="global") #cluster coefficient
RICH13_TD.degreeCent <- centralization.degree(RICH13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_TDftn <- as.network.matrix(RICH13_TDft)
RICH13_TD.netDensity <- network.density(RICH13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_TD.entropy <- entropy(RICH13_TDft) #entropy
RICH13_TD.netMx <- cbind(RICH13_TD.netMx, RICH13_TD.clusterCoef, RICH13_TD.degreeCent$centralization,
RICH13_TD.netDensity, RICH13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "RICH"
KIoutcome = "End of Qtr_DM"
RICH13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
RICH13_QTg2 <- data.frame(RICH13_QT)
RICH13_QTg2 <- RICH13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- RICH13_QTg2$player1
player2vector <- RICH13_QTg2$player2
RICH13_QTg3 <- RICH13_QTg2
RICH13_QTg3$p1inp2vec <- is.element(RICH13_QTg3$player1, player2vector)
RICH13_QTg3$p2inp1vec <- is.element(RICH13_QTg3$player2, player1vector)
addPlayer1 <- RICH13_QTg3[ which(RICH13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- RICH13_QTg3[ which(RICH13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
RICH13_QTg2 <- rbind(RICH13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
RICH13_QTft <- ftable(RICH13_QTg2$player1, RICH13_QTg2$player2)
RICH13_QTft2 <- as.matrix(RICH13_QTft)
numRows <- nrow(RICH13_QTft2)
numCols <- ncol(RICH13_QTft2)
RICH13_QTft3 <- RICH13_QTft2[c(2:numRows) , c(2:numCols)]
RICH13_QTTable <- graph.adjacency(RICH13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(RICH13_QTTable, vertex.label = V(RICH13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(RICH13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
RICH13_QT.clusterCoef <- transitivity(RICH13_QTTable, type="global") #cluster coefficient
RICH13_QT.degreeCent <- centralization.degree(RICH13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
RICH13_QTftn <- as.network.matrix(RICH13_QTft)
RICH13_QT.netDensity <- network.density(RICH13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
RICH13_QT.entropy <- entropy(RICH13_QTft) #entropy
RICH13_QT.netMx <- cbind(RICH13_QT.netMx, RICH13_QT.clusterCoef, RICH13_QT.degreeCent$centralization,
RICH13_QT.netDensity, RICH13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(RICH13_QT.netMx) <- varnames
#############################################################################
#STKILDA
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "STK"
KIoutcome = "Goal_F"
STK13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
STK13_Gg2 <- data.frame(STK13_G)
STK13_Gg2 <- STK13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_Gg2$player1
player2vector <- STK13_Gg2$player2
STK13_Gg3 <- STK13_Gg2
STK13_Gg3$p1inp2vec <- is.element(STK13_Gg3$player1, player2vector)
STK13_Gg3$p2inp1vec <- is.element(STK13_Gg3$player2, player1vector)
addPlayer1 <- STK13_Gg3[ which(STK13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_Gg3[ which(STK13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_Gg2 <- rbind(STK13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
STK13_Gft <- ftable(STK13_Gg2$player1, STK13_Gg2$player2)
STK13_Gft2 <- as.matrix(STK13_Gft)
numRows <- nrow(STK13_Gft2)
numCols <- ncol(STK13_Gft2)
STK13_Gft3 <- STK13_Gft2[c(2:numRows) , c(2:numCols)]
STK13_GTable <- graph.adjacency(STK13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(STK13_GTable, vertex.label = V(STK13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
STK13_G.clusterCoef <- transitivity(STK13_GTable, type="global") #cluster coefficient
STK13_G.degreeCent <- centralization.degree(STK13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_Gftn <- as.network.matrix(STK13_Gft)
STK13_G.netDensity <- network.density(STK13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_G.entropy <- entropy(STK13_Gft) #entropy
STK13_G.netMx <- cbind(STK13_G.netMx, STK13_G.clusterCoef, STK13_G.degreeCent$centralization,
STK13_G.netDensity, STK13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
round = 13
teamName = "STK"
KIoutcome = "Behind_F"
STK13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
STK13_Bg2 <- data.frame(STK13_B)
STK13_Bg2 <- STK13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_Bg2$player1
player2vector <- STK13_Bg2$player2
STK13_Bg3 <- STK13_Bg2
STK13_Bg3$p1inp2vec <- is.element(STK13_Bg3$player1, player2vector)
STK13_Bg3$p2inp1vec <- is.element(STK13_Bg3$player2, player1vector)
addPlayer1 <- STK13_Bg3[ which(STK13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, empty, zero)
addPlayer2 <- STK13_Bg3[ which(STK13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_Bg2 <- rbind(STK13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
STK13_Bft <- ftable(STK13_Bg2$player1, STK13_Bg2$player2)
STK13_Bft2 <- as.matrix(STK13_Bft)
numRows <- nrow(STK13_Bft2)
numCols <- ncol(STK13_Bft2)
STK13_Bft3 <- STK13_Bft2[c(2:numRows) , c(2:numCols)]
STK13_BTable <- graph.adjacency(STK13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(STK13_BTable, vertex.label = V(STK13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
STK13_B.clusterCoef <- transitivity(STK13_BTable, type="global") #cluster coefficient
STK13_B.degreeCent <- centralization.degree(STK13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_Bftn <- as.network.matrix(STK13_Bft)
STK13_B.netDensity <- network.density(STK13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_B.entropy <- entropy(STK13_Bft) #entropy
STK13_B.netMx <- cbind(STK13_B.netMx, STK13_B.clusterCoef, STK13_B.degreeCent$centralization,
STK13_B.netDensity, STK13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
#NA
round = 13
teamName = "STK"
KIoutcome = "Stoppage_F"
STK13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
STK13_SFg2 <- data.frame(STK13_SF)
STK13_SFg2 <- STK13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_SFg2$player1
player2vector <- STK13_SFg2$player2
STK13_SFg3 <- STK13_SFg2
STK13_SFg3$p1inp2vec <- is.element(STK13_SFg3$player1, player2vector)
STK13_SFg3$p2inp1vec <- is.element(STK13_SFg3$player2, player1vector)
addPlayer1 <- STK13_SFg3[ which(STK13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_SFg3[ which(STK13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_SFg2 <- rbind(STK13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
STK13_SFft <- ftable(STK13_SFg2$player1, STK13_SFg2$player2)
STK13_SFft2 <- as.matrix(STK13_SFft)
numRows <- nrow(STK13_SFft2)
numCols <- ncol(STK13_SFft2)
STK13_SFft3 <- STK13_SFft2[c(2:numRows) , c(2:numCols)]
STK13_SFTable <- graph.adjacency(STK13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(STK13_SFTable, vertex.label = V(STK13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
STK13_SF.clusterCoef <- transitivity(STK13_SFTable, type="global") #cluster coefficient
STK13_SF.degreeCent <- centralization.degree(STK13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_SFftn <- as.network.matrix(STK13_SFft)
STK13_SF.netDensity <- network.density(STK13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_SF.entropy <- entropy(STK13_SFft) #entropy
STK13_SF.netMx <- cbind(STK13_SF.netMx, STK13_SF.clusterCoef, STK13_SF.degreeCent$centralization,
STK13_SF.netDensity, STK13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "STK"
KIoutcome = "Turnover_F"
STK13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
STK13_TFg2 <- data.frame(STK13_TF)
STK13_TFg2 <- STK13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_TFg2$player1
player2vector <- STK13_TFg2$player2
STK13_TFg3 <- STK13_TFg2
STK13_TFg3$p1inp2vec <- is.element(STK13_TFg3$player1, player2vector)
STK13_TFg3$p2inp1vec <- is.element(STK13_TFg3$player2, player1vector)
addPlayer1 <- STK13_TFg3[ which(STK13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_TFg3[ which(STK13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_TFg2 <- rbind(STK13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
STK13_TFft <- ftable(STK13_TFg2$player1, STK13_TFg2$player2)
STK13_TFft2 <- as.matrix(STK13_TFft)
numRows <- nrow(STK13_TFft2)
numCols <- ncol(STK13_TFft2)
STK13_TFft3 <- STK13_TFft2[c(2:numRows) , c(2:numCols)]
STK13_TFTable <- graph.adjacency(STK13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(STK13_TFTable, vertex.label = V(STK13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
STK13_TF.clusterCoef <- transitivity(STK13_TFTable, type="global") #cluster coefficient
STK13_TF.degreeCent <- centralization.degree(STK13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_TFftn <- as.network.matrix(STK13_TFft)
STK13_TF.netDensity <- network.density(STK13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_TF.entropy <- entropy(STK13_TFft) #entropy
STK13_TF.netMx <- cbind(STK13_TF.netMx, STK13_TF.clusterCoef, STK13_TF.degreeCent$centralization,
STK13_TF.netDensity, STK13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
round = 13
teamName = "STK"
KIoutcome = "Stoppage_AM"
STK13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
STK13_SAMg2 <- data.frame(STK13_SAM)
STK13_SAMg2 <- STK13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_SAMg2$player1
player2vector <- STK13_SAMg2$player2
STK13_SAMg3 <- STK13_SAMg2
STK13_SAMg3$p1inp2vec <- is.element(STK13_SAMg3$player1, player2vector)
STK13_SAMg3$p2inp1vec <- is.element(STK13_SAMg3$player2, player1vector)
addPlayer1 <- STK13_SAMg3[ which(STK13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_SAMg3[ which(STK13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_SAMg2 <- rbind(STK13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
STK13_SAMft <- ftable(STK13_SAMg2$player1, STK13_SAMg2$player2)
STK13_SAMft2 <- as.matrix(STK13_SAMft)
numRows <- nrow(STK13_SAMft2)
numCols <- ncol(STK13_SAMft2)
STK13_SAMft3 <- STK13_SAMft2[c(2:numRows) , c(2:numCols)]
STK13_SAMTable <- graph.adjacency(STK13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(STK13_SAMTable, vertex.label = V(STK13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
STK13_SAM.clusterCoef <- transitivity(STK13_SAMTable, type="global") #cluster coefficient
STK13_SAM.degreeCent <- centralization.degree(STK13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_SAMftn <- as.network.matrix(STK13_SAMft)
STK13_SAM.netDensity <- network.density(STK13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_SAM.entropy <- entropy(STK13_SAMft) #entropy
STK13_SAM.netMx <- cbind(STK13_SAM.netMx, STK13_SAM.clusterCoef, STK13_SAM.degreeCent$centralization,
STK13_SAM.netDensity, STK13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "STK"
KIoutcome = "Turnover_AM"
STK13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
STK13_TAMg2 <- data.frame(STK13_TAM)
STK13_TAMg2 <- STK13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_TAMg2$player1
player2vector <- STK13_TAMg2$player2
STK13_TAMg3 <- STK13_TAMg2
STK13_TAMg3$p1inp2vec <- is.element(STK13_TAMg3$player1, player2vector)
STK13_TAMg3$p2inp1vec <- is.element(STK13_TAMg3$player2, player1vector)
addPlayer1 <- STK13_TAMg3[ which(STK13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_TAMg3[ which(STK13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(empty, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_TAMg2 <- rbind(STK13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
STK13_TAMft <- ftable(STK13_TAMg2$player1, STK13_TAMg2$player2)
STK13_TAMft2 <- as.matrix(STK13_TAMft)
numRows <- nrow(STK13_TAMft2)
numCols <- ncol(STK13_TAMft2)
STK13_TAMft3 <- STK13_TAMft2[c(2:numRows) , c(2:numCols)]
STK13_TAMTable <- graph.adjacency(STK13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(STK13_TAMTable, vertex.label = V(STK13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
STK13_TAM.clusterCoef <- transitivity(STK13_TAMTable, type="global") #cluster coefficient
STK13_TAM.degreeCent <- centralization.degree(STK13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_TAMftn <- as.network.matrix(STK13_TAMft)
STK13_TAM.netDensity <- network.density(STK13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_TAM.entropy <- entropy(STK13_TAMft) #entropy
STK13_TAM.netMx <- cbind(STK13_TAM.netMx, STK13_TAM.clusterCoef, STK13_TAM.degreeCent$centralization,
STK13_TAM.netDensity, STK13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "STK"
KIoutcome = "Stoppage_DM"
STK13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
STK13_SDMg2 <- data.frame(STK13_SDM)
STK13_SDMg2 <- STK13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_SDMg2$player1
player2vector <- STK13_SDMg2$player2
STK13_SDMg3 <- STK13_SDMg2
STK13_SDMg3$p1inp2vec <- is.element(STK13_SDMg3$player1, player2vector)
STK13_SDMg3$p2inp1vec <- is.element(STK13_SDMg3$player2, player1vector)
addPlayer1 <- STK13_SDMg3[ which(STK13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_SDMg3[ which(STK13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(empty, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_SDMg2 <- rbind(STK13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
STK13_SDMft <- ftable(STK13_SDMg2$player1, STK13_SDMg2$player2)
STK13_SDMft2 <- as.matrix(STK13_SDMft)
numRows <- nrow(STK13_SDMft2)
numCols <- ncol(STK13_SDMft2)
STK13_SDMft3 <- STK13_SDMft2[c(2:numRows) , c(2:numCols)]
STK13_SDMTable <- graph.adjacency(STK13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(STK13_SDMTable, vertex.label = V(STK13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
STK13_SDM.clusterCoef <- transitivity(STK13_SDMTable, type="global") #cluster coefficient
STK13_SDM.degreeCent <- centralization.degree(STK13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_SDMftn <- as.network.matrix(STK13_SDMft)
STK13_SDM.netDensity <- network.density(STK13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_SDM.entropy <- entropy(STK13_SDMft) #entropy
STK13_SDM.netMx <- cbind(STK13_SDM.netMx, STK13_SDM.clusterCoef, STK13_SDM.degreeCent$centralization,
STK13_SDM.netDensity, STK13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "STK"
KIoutcome = "Turnover_DM"
STK13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
STK13_TDMg2 <- data.frame(STK13_TDM)
STK13_TDMg2 <- STK13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_TDMg2$player1
player2vector <- STK13_TDMg2$player2
STK13_TDMg3 <- STK13_TDMg2
STK13_TDMg3$p1inp2vec <- is.element(STK13_TDMg3$player1, player2vector)
STK13_TDMg3$p2inp1vec <- is.element(STK13_TDMg3$player2, player1vector)
addPlayer1 <- STK13_TDMg3[ which(STK13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_TDMg3[ which(STK13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_TDMg2 <- rbind(STK13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
STK13_TDMft <- ftable(STK13_TDMg2$player1, STK13_TDMg2$player2)
STK13_TDMft2 <- as.matrix(STK13_TDMft)
numRows <- nrow(STK13_TDMft2)
numCols <- ncol(STK13_TDMft2)
STK13_TDMft3 <- STK13_TDMft2[c(2:numRows) , c(2:numCols)]
STK13_TDMTable <- graph.adjacency(STK13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(STK13_TDMTable, vertex.label = V(STK13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
STK13_TDM.clusterCoef <- transitivity(STK13_TDMTable, type="global") #cluster coefficient
STK13_TDM.degreeCent <- centralization.degree(STK13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_TDMftn <- as.network.matrix(STK13_TDMft)
STK13_TDM.netDensity <- network.density(STK13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_TDM.entropy <- entropy(STK13_TDMft) #entropy
STK13_TDM.netMx <- cbind(STK13_TDM.netMx, STK13_TDM.clusterCoef, STK13_TDM.degreeCent$centralization,
STK13_TDM.netDensity, STK13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "STK"
KIoutcome = "Stoppage_D"
STK13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
STK13_SDg2 <- data.frame(STK13_SD)
STK13_SDg2 <- STK13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_SDg2$player1
player2vector <- STK13_SDg2$player2
STK13_SDg3 <- STK13_SDg2
STK13_SDg3$p1inp2vec <- is.element(STK13_SDg3$player1, player2vector)
STK13_SDg3$p2inp1vec <- is.element(STK13_SDg3$player2, player1vector)
addPlayer1 <- STK13_SDg3[ which(STK13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_SDg3[ which(STK13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_SDg2 <- rbind(STK13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
STK13_SDft <- ftable(STK13_SDg2$player1, STK13_SDg2$player2)
STK13_SDft2 <- as.matrix(STK13_SDft)
numRows <- nrow(STK13_SDft2)
numCols <- ncol(STK13_SDft2)
STK13_SDft3 <- STK13_SDft2[c(2:numRows) , c(2:numCols)]
STK13_SDTable <- graph.adjacency(STK13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(STK13_SDTable, vertex.label = V(STK13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
STK13_SD.clusterCoef <- transitivity(STK13_SDTable, type="global") #cluster coefficient
STK13_SD.degreeCent <- centralization.degree(STK13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_SDftn <- as.network.matrix(STK13_SDft)
STK13_SD.netDensity <- network.density(STK13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_SD.entropy <- entropy(STK13_SDft) #entropy
STK13_SD.netMx <- cbind(STK13_SD.netMx, STK13_SD.clusterCoef, STK13_SD.degreeCent$centralization,
STK13_SD.netDensity, STK13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "STK"
KIoutcome = "Turnover_D"
STK13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
STK13_TDg2 <- data.frame(STK13_TD)
STK13_TDg2 <- STK13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_TDg2$player1
player2vector <- STK13_TDg2$player2
STK13_TDg3 <- STK13_TDg2
STK13_TDg3$p1inp2vec <- is.element(STK13_TDg3$player1, player2vector)
STK13_TDg3$p2inp1vec <- is.element(STK13_TDg3$player2, player1vector)
addPlayer1 <- STK13_TDg3[ which(STK13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_TDg3[ which(STK13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_TDg2 <- rbind(STK13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
STK13_TDft <- ftable(STK13_TDg2$player1, STK13_TDg2$player2)
STK13_TDft2 <- as.matrix(STK13_TDft)
numRows <- nrow(STK13_TDft2)
numCols <- ncol(STK13_TDft2)
STK13_TDft3 <- STK13_TDft2[c(2:numRows) , c(2:numCols)]
STK13_TDTable <- graph.adjacency(STK13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(STK13_TDTable, vertex.label = V(STK13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
STK13_TD.clusterCoef <- transitivity(STK13_TDTable, type="global") #cluster coefficient
STK13_TD.degreeCent <- centralization.degree(STK13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_TDftn <- as.network.matrix(STK13_TDft)
STK13_TD.netDensity <- network.density(STK13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_TD.entropy <- entropy(STK13_TDft) #entropy
STK13_TD.netMx <- cbind(STK13_TD.netMx, STK13_TD.clusterCoef, STK13_TD.degreeCent$centralization,
STK13_TD.netDensity, STK13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "STK"
KIoutcome = "End of Qtr_DM"
STK13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
STK13_QTg2 <- data.frame(STK13_QT)
STK13_QTg2 <- STK13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- STK13_QTg2$player1
player2vector <- STK13_QTg2$player2
STK13_QTg3 <- STK13_QTg2
STK13_QTg3$p1inp2vec <- is.element(STK13_QTg3$player1, player2vector)
STK13_QTg3$p2inp1vec <- is.element(STK13_QTg3$player2, player1vector)
addPlayer1 <- STK13_QTg3[ which(STK13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- STK13_QTg3[ which(STK13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
STK13_QTg2 <- rbind(STK13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
STK13_QTft <- ftable(STK13_QTg2$player1, STK13_QTg2$player2)
STK13_QTft2 <- as.matrix(STK13_QTft)
numRows <- nrow(STK13_QTft2)
numCols <- ncol(STK13_QTft2)
STK13_QTft3 <- STK13_QTft2[c(2:numRows) , c(2:numCols)]
STK13_QTTable <- graph.adjacency(STK13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(STK13_QTTable, vertex.label = V(STK13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(STK13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
STK13_QT.clusterCoef <- transitivity(STK13_QTTable, type="global") #cluster coefficient
STK13_QT.degreeCent <- centralization.degree(STK13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
STK13_QTftn <- as.network.matrix(STK13_QTft)
STK13_QT.netDensity <- network.density(STK13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
STK13_QT.entropy <- entropy(STK13_QTft) #entropy
STK13_QT.netMx <- cbind(STK13_QT.netMx, STK13_QT.clusterCoef, STK13_QT.degreeCent$centralization,
STK13_QT.netDensity, STK13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(STK13_QT.netMx) <- varnames
#############################################################################
#SYDNEY
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "SYD"
KIoutcome = "Goal_F"
SYD13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
SYD13_Gg2 <- data.frame(SYD13_G)
SYD13_Gg2 <- SYD13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_Gg2$player1
player2vector <- SYD13_Gg2$player2
SYD13_Gg3 <- SYD13_Gg2
SYD13_Gg3$p1inp2vec <- is.element(SYD13_Gg3$player1, player2vector)
SYD13_Gg3$p2inp1vec <- is.element(SYD13_Gg3$player2, player1vector)
addPlayer1 <- SYD13_Gg3[ which(SYD13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_Gg3[ which(SYD13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_Gg2 <- rbind(SYD13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
SYD13_Gft <- ftable(SYD13_Gg2$player1, SYD13_Gg2$player2)
SYD13_Gft2 <- as.matrix(SYD13_Gft)
numRows <- nrow(SYD13_Gft2)
numCols <- ncol(SYD13_Gft2)
SYD13_Gft3 <- SYD13_Gft2[c(2:numRows) , c(2:numCols)]
SYD13_GTable <- graph.adjacency(SYD13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(SYD13_GTable, vertex.label = V(SYD13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
SYD13_G.clusterCoef <- transitivity(SYD13_GTable, type="global") #cluster coefficient
SYD13_G.degreeCent <- centralization.degree(SYD13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_Gftn <- as.network.matrix(SYD13_Gft)
SYD13_G.netDensity <- network.density(SYD13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_G.entropy <- entropy(SYD13_Gft) #entropy
SYD13_G.netMx <- cbind(SYD13_G.netMx, SYD13_G.clusterCoef, SYD13_G.degreeCent$centralization,
SYD13_G.netDensity, SYD13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
#NA
round = 13
teamName = "SYD"
KIoutcome = "Behind_F"
SYD13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
SYD13_Bg2 <- data.frame(SYD13_B)
SYD13_Bg2 <- SYD13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_Bg2$player1
player2vector <- SYD13_Bg2$player2
SYD13_Bg3 <- SYD13_Bg2
SYD13_Bg3$p1inp2vec <- is.element(SYD13_Bg3$player1, player2vector)
SYD13_Bg3$p2inp1vec <- is.element(SYD13_Bg3$player2, player1vector)
addPlayer1 <- SYD13_Bg3[ which(SYD13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_Bg3[ which(SYD13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_Bg2 <- rbind(SYD13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
SYD13_Bft <- ftable(SYD13_Bg2$player1, SYD13_Bg2$player2)
SYD13_Bft2 <- as.matrix(SYD13_Bft)
numRows <- nrow(SYD13_Bft2)
numCols <- ncol(SYD13_Bft2)
SYD13_Bft3 <- SYD13_Bft2[c(2:numRows) , c(2:numCols)]
SYD13_BTable <- graph.adjacency(SYD13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(SYD13_BTable, vertex.label = V(SYD13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
SYD13_B.clusterCoef <- transitivity(SYD13_BTable, type="global") #cluster coefficient
SYD13_B.degreeCent <- centralization.degree(SYD13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_Bftn <- as.network.matrix(SYD13_Bft)
SYD13_B.netDensity <- network.density(SYD13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_B.entropy <- entropy(SYD13_Bft) #entropy
SYD13_B.netMx <- cbind(SYD13_B.netMx, SYD13_B.clusterCoef, SYD13_B.degreeCent$centralization,
SYD13_B.netDensity, SYD13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
round = 13
teamName = "SYD"
KIoutcome = "Stoppage_F"
SYD13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
SYD13_SFg2 <- data.frame(SYD13_SF)
SYD13_SFg2 <- SYD13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_SFg2$player1
player2vector <- SYD13_SFg2$player2
SYD13_SFg3 <- SYD13_SFg2
SYD13_SFg3$p1inp2vec <- is.element(SYD13_SFg3$player1, player2vector)
SYD13_SFg3$p2inp1vec <- is.element(SYD13_SFg3$player2, player1vector)
addPlayer1 <- SYD13_SFg3[ which(SYD13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_SFg3[ which(SYD13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_SFg2 <- rbind(SYD13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
SYD13_SFft <- ftable(SYD13_SFg2$player1, SYD13_SFg2$player2)
SYD13_SFft2 <- as.matrix(SYD13_SFft)
numRows <- nrow(SYD13_SFft2)
numCols <- ncol(SYD13_SFft2)
SYD13_SFft3 <- SYD13_SFft2[c(2:numRows) , c(2:numCols)]
SYD13_SFTable <- graph.adjacency(SYD13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(SYD13_SFTable, vertex.label = V(SYD13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
SYD13_SF.clusterCoef <- transitivity(SYD13_SFTable, type="global") #cluster coefficient
SYD13_SF.degreeCent <- centralization.degree(SYD13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_SFftn <- as.network.matrix(SYD13_SFft)
SYD13_SF.netDensity <- network.density(SYD13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_SF.entropy <- entropy(SYD13_SFft) #entropy
SYD13_SF.netMx <- cbind(SYD13_SF.netMx, SYD13_SF.clusterCoef, SYD13_SF.degreeCent$centralization,
SYD13_SF.netDensity, SYD13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "SYD"
KIoutcome = "Turnover_F"
SYD13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
SYD13_TFg2 <- data.frame(SYD13_TF)
SYD13_TFg2 <- SYD13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_TFg2$player1
player2vector <- SYD13_TFg2$player2
SYD13_TFg3 <- SYD13_TFg2
SYD13_TFg3$p1inp2vec <- is.element(SYD13_TFg3$player1, player2vector)
SYD13_TFg3$p2inp1vec <- is.element(SYD13_TFg3$player2, player1vector)
addPlayer1 <- SYD13_TFg3[ which(SYD13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_TFg3[ which(SYD13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_TFg2 <- rbind(SYD13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
SYD13_TFft <- ftable(SYD13_TFg2$player1, SYD13_TFg2$player2)
SYD13_TFft2 <- as.matrix(SYD13_TFft)
numRows <- nrow(SYD13_TFft2)
numCols <- ncol(SYD13_TFft2)
SYD13_TFft3 <- SYD13_TFft2[c(2:numRows) , c(2:numCols)]
SYD13_TFTable <- graph.adjacency(SYD13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(SYD13_TFTable, vertex.label = V(SYD13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
SYD13_TF.clusterCoef <- transitivity(SYD13_TFTable, type="global") #cluster coefficient
SYD13_TF.degreeCent <- centralization.degree(SYD13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_TFftn <- as.network.matrix(SYD13_TFft)
SYD13_TF.netDensity <- network.density(SYD13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_TF.entropy <- entropy(SYD13_TFft) #entropy
SYD13_TF.netMx <- cbind(SYD13_TF.netMx, SYD13_TF.clusterCoef, SYD13_TF.degreeCent$centralization,
SYD13_TF.netDensity, SYD13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
#NA
round = 13
teamName = "SYD"
KIoutcome = "Stoppage_AM"
SYD13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
SYD13_SAMg2 <- data.frame(SYD13_SAM)
SYD13_SAMg2 <- SYD13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_SAMg2$player1
player2vector <- SYD13_SAMg2$player2
SYD13_SAMg3 <- SYD13_SAMg2
SYD13_SAMg3$p1inp2vec <- is.element(SYD13_SAMg3$player1, player2vector)
SYD13_SAMg3$p2inp1vec <- is.element(SYD13_SAMg3$player2, player1vector)
addPlayer1 <- SYD13_SAMg3[ which(SYD13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_SAMg3[ which(SYD13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_SAMg2 <- rbind(SYD13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
SYD13_SAMft <- ftable(SYD13_SAMg2$player1, SYD13_SAMg2$player2)
SYD13_SAMft2 <- as.matrix(SYD13_SAMft)
numRows <- nrow(SYD13_SAMft2)
numCols <- ncol(SYD13_SAMft2)
SYD13_SAMft3 <- SYD13_SAMft2[c(2:numRows) , c(2:numCols)]
SYD13_SAMTable <- graph.adjacency(SYD13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(SYD13_SAMTable, vertex.label = V(SYD13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
SYD13_SAM.clusterCoef <- transitivity(SYD13_SAMTable, type="global") #cluster coefficient
SYD13_SAM.degreeCent <- centralization.degree(SYD13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_SAMftn <- as.network.matrix(SYD13_SAMft)
SYD13_SAM.netDensity <- network.density(SYD13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_SAM.entropy <- entropy(SYD13_SAMft) #entropy
SYD13_SAM.netMx <- cbind(SYD13_SAM.netMx, SYD13_SAM.clusterCoef, SYD13_SAM.degreeCent$centralization,
SYD13_SAM.netDensity, SYD13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "SYD"
KIoutcome = "Turnover_AM"
SYD13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
SYD13_TAMg2 <- data.frame(SYD13_TAM)
SYD13_TAMg2 <- SYD13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_TAMg2$player1
player2vector <- SYD13_TAMg2$player2
SYD13_TAMg3 <- SYD13_TAMg2
SYD13_TAMg3$p1inp2vec <- is.element(SYD13_TAMg3$player1, player2vector)
SYD13_TAMg3$p2inp1vec <- is.element(SYD13_TAMg3$player2, player1vector)
addPlayer1 <- SYD13_TAMg3[ which(SYD13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_TAMg3[ which(SYD13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_TAMg2 <- rbind(SYD13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
SYD13_TAMft <- ftable(SYD13_TAMg2$player1, SYD13_TAMg2$player2)
SYD13_TAMft2 <- as.matrix(SYD13_TAMft)
numRows <- nrow(SYD13_TAMft2)
numCols <- ncol(SYD13_TAMft2)
SYD13_TAMft3 <- SYD13_TAMft2[c(2:numRows) , c(2:numCols)]
SYD13_TAMTable <- graph.adjacency(SYD13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(SYD13_TAMTable, vertex.label = V(SYD13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
SYD13_TAM.clusterCoef <- transitivity(SYD13_TAMTable, type="global") #cluster coefficient
SYD13_TAM.degreeCent <- centralization.degree(SYD13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_TAMftn <- as.network.matrix(SYD13_TAMft)
SYD13_TAM.netDensity <- network.density(SYD13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_TAM.entropy <- entropy(SYD13_TAMft) #entropy
SYD13_TAM.netMx <- cbind(SYD13_TAM.netMx, SYD13_TAM.clusterCoef, SYD13_TAM.degreeCent$centralization,
SYD13_TAM.netDensity, SYD13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
#NA
round = 13
teamName = "SYD"
KIoutcome = "Stoppage_DM"
SYD13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
SYD13_SDMg2 <- data.frame(SYD13_SDM)
SYD13_SDMg2 <- SYD13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_SDMg2$player1
player2vector <- SYD13_SDMg2$player2
SYD13_SDMg3 <- SYD13_SDMg2
SYD13_SDMg3$p1inp2vec <- is.element(SYD13_SDMg3$player1, player2vector)
SYD13_SDMg3$p2inp1vec <- is.element(SYD13_SDMg3$player2, player1vector)
addPlayer1 <- SYD13_SDMg3[ which(SYD13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_SDMg3[ which(SYD13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_SDMg2 <- rbind(SYD13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
SYD13_SDMft <- ftable(SYD13_SDMg2$player1, SYD13_SDMg2$player2)
SYD13_SDMft2 <- as.matrix(SYD13_SDMft)
numRows <- nrow(SYD13_SDMft2)
numCols <- ncol(SYD13_SDMft2)
SYD13_SDMft3 <- SYD13_SDMft2[c(2:numRows) , c(2:numCols)]
SYD13_SDMTable <- graph.adjacency(SYD13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(SYD13_SDMTable, vertex.label = V(SYD13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
SYD13_SDM.clusterCoef <- transitivity(SYD13_SDMTable, type="global") #cluster coefficient
SYD13_SDM.degreeCent <- centralization.degree(SYD13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_SDMftn <- as.network.matrix(SYD13_SDMft)
SYD13_SDM.netDensity <- network.density(SYD13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_SDM.entropy <- entropy(SYD13_SDMft) #entropy
SYD13_SDM.netMx <- cbind(SYD13_SDM.netMx, SYD13_SDM.clusterCoef, SYD13_SDM.degreeCent$centralization,
SYD13_SDM.netDensity, SYD13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "SYD"
KIoutcome = "Turnover_DM"
SYD13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
SYD13_TDMg2 <- data.frame(SYD13_TDM)
SYD13_TDMg2 <- SYD13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_TDMg2$player1
player2vector <- SYD13_TDMg2$player2
SYD13_TDMg3 <- SYD13_TDMg2
SYD13_TDMg3$p1inp2vec <- is.element(SYD13_TDMg3$player1, player2vector)
SYD13_TDMg3$p2inp1vec <- is.element(SYD13_TDMg3$player2, player1vector)
addPlayer1 <- SYD13_TDMg3[ which(SYD13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_TDMg3[ which(SYD13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_TDMg2 <- rbind(SYD13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
SYD13_TDMft <- ftable(SYD13_TDMg2$player1, SYD13_TDMg2$player2)
SYD13_TDMft2 <- as.matrix(SYD13_TDMft)
numRows <- nrow(SYD13_TDMft2)
numCols <- ncol(SYD13_TDMft2)
SYD13_TDMft3 <- SYD13_TDMft2[c(2:numRows) , c(2:numCols)]
SYD13_TDMTable <- graph.adjacency(SYD13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(SYD13_TDMTable, vertex.label = V(SYD13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
SYD13_TDM.clusterCoef <- transitivity(SYD13_TDMTable, type="global") #cluster coefficient
SYD13_TDM.degreeCent <- centralization.degree(SYD13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_TDMftn <- as.network.matrix(SYD13_TDMft)
SYD13_TDM.netDensity <- network.density(SYD13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_TDM.entropy <- entropy(SYD13_TDMft) #entropy
SYD13_TDM.netMx <- cbind(SYD13_TDM.netMx, SYD13_TDM.clusterCoef, SYD13_TDM.degreeCent$centralization,
SYD13_TDM.netDensity, SYD13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "SYD"
KIoutcome = "Stoppage_D"
SYD13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
SYD13_SDg2 <- data.frame(SYD13_SD)
SYD13_SDg2 <- SYD13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_SDg2$player1
player2vector <- SYD13_SDg2$player2
SYD13_SDg3 <- SYD13_SDg2
SYD13_SDg3$p1inp2vec <- is.element(SYD13_SDg3$player1, player2vector)
SYD13_SDg3$p2inp1vec <- is.element(SYD13_SDg3$player2, player1vector)
addPlayer1 <- SYD13_SDg3[ which(SYD13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_SDg3[ which(SYD13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_SDg2 <- rbind(SYD13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
SYD13_SDft <- ftable(SYD13_SDg2$player1, SYD13_SDg2$player2)
SYD13_SDft2 <- as.matrix(SYD13_SDft)
numRows <- nrow(SYD13_SDft2)
numCols <- ncol(SYD13_SDft2)
SYD13_SDft3 <- SYD13_SDft2[c(2:numRows) , c(2:numCols)]
SYD13_SDTable <- graph.adjacency(SYD13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(SYD13_SDTable, vertex.label = V(SYD13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
SYD13_SD.clusterCoef <- transitivity(SYD13_SDTable, type="global") #cluster coefficient
SYD13_SD.degreeCent <- centralization.degree(SYD13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_SDftn <- as.network.matrix(SYD13_SDft)
SYD13_SD.netDensity <- network.density(SYD13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_SD.entropy <- entropy(SYD13_SDft) #entropy
SYD13_SD.netMx <- cbind(SYD13_SD.netMx, SYD13_SD.clusterCoef, SYD13_SD.degreeCent$centralization,
SYD13_SD.netDensity, SYD13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "SYD"
KIoutcome = "Turnover_D"
SYD13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
SYD13_TDg2 <- data.frame(SYD13_TD)
SYD13_TDg2 <- SYD13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_TDg2$player1
player2vector <- SYD13_TDg2$player2
SYD13_TDg3 <- SYD13_TDg2
SYD13_TDg3$p1inp2vec <- is.element(SYD13_TDg3$player1, player2vector)
SYD13_TDg3$p2inp1vec <- is.element(SYD13_TDg3$player2, player1vector)
addPlayer1 <- SYD13_TDg3[ which(SYD13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_TDg3[ which(SYD13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_TDg2 <- rbind(SYD13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
SYD13_TDft <- ftable(SYD13_TDg2$player1, SYD13_TDg2$player2)
SYD13_TDft2 <- as.matrix(SYD13_TDft)
numRows <- nrow(SYD13_TDft2)
numCols <- ncol(SYD13_TDft2)
SYD13_TDft3 <- SYD13_TDft2[c(2:numRows) , c(2:numCols)]
SYD13_TDTable <- graph.adjacency(SYD13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(SYD13_TDTable, vertex.label = V(SYD13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
SYD13_TD.clusterCoef <- transitivity(SYD13_TDTable, type="global") #cluster coefficient
SYD13_TD.degreeCent <- centralization.degree(SYD13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_TDftn <- as.network.matrix(SYD13_TDft)
SYD13_TD.netDensity <- network.density(SYD13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_TD.entropy <- entropy(SYD13_TDft) #entropy
SYD13_TD.netMx <- cbind(SYD13_TD.netMx, SYD13_TD.clusterCoef, SYD13_TD.degreeCent$centralization,
SYD13_TD.netDensity, SYD13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "SYD"
KIoutcome = "End of Qtr_DM"
SYD13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
SYD13_QTg2 <- data.frame(SYD13_QT)
SYD13_QTg2 <- SYD13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- SYD13_QTg2$player1
player2vector <- SYD13_QTg2$player2
SYD13_QTg3 <- SYD13_QTg2
SYD13_QTg3$p1inp2vec <- is.element(SYD13_QTg3$player1, player2vector)
SYD13_QTg3$p2inp1vec <- is.element(SYD13_QTg3$player2, player1vector)
addPlayer1 <- SYD13_QTg3[ which(SYD13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- SYD13_QTg3[ which(SYD13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
SYD13_QTg2 <- rbind(SYD13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
SYD13_QTft <- ftable(SYD13_QTg2$player1, SYD13_QTg2$player2)
SYD13_QTft2 <- as.matrix(SYD13_QTft)
numRows <- nrow(SYD13_QTft2)
numCols <- ncol(SYD13_QTft2)
SYD13_QTft3 <- SYD13_QTft2[c(2:numRows) , c(2:numCols)]
SYD13_QTTable <- graph.adjacency(SYD13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(SYD13_QTTable, vertex.label = V(SYD13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(SYD13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
SYD13_QT.clusterCoef <- transitivity(SYD13_QTTable, type="global") #cluster coefficient
SYD13_QT.degreeCent <- centralization.degree(SYD13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
SYD13_QTftn <- as.network.matrix(SYD13_QTft)
SYD13_QT.netDensity <- network.density(SYD13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
SYD13_QT.entropy <- entropy(SYD13_QTft) #entropy
SYD13_QT.netMx <- cbind(SYD13_QT.netMx, SYD13_QT.clusterCoef, SYD13_QT.degreeCent$centralization,
SYD13_QT.netDensity, SYD13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(SYD13_QT.netMx) <- varnames
#############################################################################
#WESTERN BULLDOGS
##
#ROUND 13
##
#ROUND 13, Goal***************************************************************
#NA
round = 13
teamName = "WB"
KIoutcome = "Goal_F"
WB13_G.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Goal with weighted edges
WB13_Gg2 <- data.frame(WB13_G)
WB13_Gg2 <- WB13_Gg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_Gg2$player1
player2vector <- WB13_Gg2$player2
WB13_Gg3 <- WB13_Gg2
WB13_Gg3$p1inp2vec <- is.element(WB13_Gg3$player1, player2vector)
WB13_Gg3$p2inp1vec <- is.element(WB13_Gg3$player2, player1vector)
addPlayer1 <- WB13_Gg3[ which(WB13_Gg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_Gg3[ which(WB13_Gg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_Gg2 <- rbind(WB13_Gg2, addPlayers)
#ROUND 13, Goal graph using weighted edges
WB13_Gft <- ftable(WB13_Gg2$player1, WB13_Gg2$player2)
WB13_Gft2 <- as.matrix(WB13_Gft)
numRows <- nrow(WB13_Gft2)
numCols <- ncol(WB13_Gft2)
WB13_Gft3 <- WB13_Gft2[c(2:numRows) , c(2:numCols)]
WB13_GTable <- graph.adjacency(WB13_Gft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Goal graph=weighted
plot.igraph(WB13_GTable, vertex.label = V(WB13_GTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_GTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Goal calulation of network metrics
#igraph
WB13_G.clusterCoef <- transitivity(WB13_GTable, type="global") #cluster coefficient
WB13_G.degreeCent <- centralization.degree(WB13_GTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_Gftn <- as.network.matrix(WB13_Gft)
WB13_G.netDensity <- network.density(WB13_Gftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_G.entropy <- entropy(WB13_Gft) #entropy
WB13_G.netMx <- cbind(WB13_G.netMx, WB13_G.clusterCoef, WB13_G.degreeCent$centralization,
WB13_G.netDensity, WB13_G.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_G.netMx) <- varnames
#ROUND 13, Behind***************************************************************
#NA
round = 13
teamName = "WB"
KIoutcome = "Behind_F"
WB13_B.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, Behind with weighted edges
WB13_Bg2 <- data.frame(WB13_B)
WB13_Bg2 <- WB13_Bg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_Bg2$player1
player2vector <- WB13_Bg2$player2
WB13_Bg3 <- WB13_Bg2
WB13_Bg3$p1inp2vec <- is.element(WB13_Bg3$player1, player2vector)
WB13_Bg3$p2inp1vec <- is.element(WB13_Bg3$player2, player1vector)
addPlayer1 <- WB13_Bg3[ which(WB13_Bg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_Bg3[ which(WB13_Bg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_Bg2 <- rbind(WB13_Bg2, addPlayers)
#ROUND 13, Behind graph using weighted edges
WB13_Bft <- ftable(WB13_Bg2$player1, WB13_Bg2$player2)
WB13_Bft2 <- as.matrix(WB13_Bft)
numRows <- nrow(WB13_Bft2)
numCols <- ncol(WB13_Bft2)
WB13_Bft3 <- WB13_Bft2[c(2:numRows) , c(2:numCols)]
WB13_BTable <- graph.adjacency(WB13_Bft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, Behind graph=weighted
plot.igraph(WB13_BTable, vertex.label = V(WB13_BTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_BTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, Behind calulation of network metrics
#igraph
WB13_B.clusterCoef <- transitivity(WB13_BTable, type="global") #cluster coefficient
WB13_B.degreeCent <- centralization.degree(WB13_BTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_Bftn <- as.network.matrix(WB13_Bft)
WB13_B.netDensity <- network.density(WB13_Bftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_B.entropy <- entropy(WB13_Bft) #entropy
WB13_B.netMx <- cbind(WB13_B.netMx, WB13_B.clusterCoef, WB13_B.degreeCent$centralization,
WB13_B.netDensity, WB13_B.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_B.netMx) <- varnames
#ROUND 13, FWD Stoppage**********************************************************
round = 13
teamName = "WB"
KIoutcome = "Stoppage_F"
WB13_SF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Stoppage with weighted edges
WB13_SFg2 <- data.frame(WB13_SF)
WB13_SFg2 <- WB13_SFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_SFg2$player1
player2vector <- WB13_SFg2$player2
WB13_SFg3 <- WB13_SFg2
WB13_SFg3$p1inp2vec <- is.element(WB13_SFg3$player1, player2vector)
WB13_SFg3$p2inp1vec <- is.element(WB13_SFg3$player2, player1vector)
addPlayer1 <- WB13_SFg3[ which(WB13_SFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_SFg3[ which(WB13_SFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_SFg2 <- rbind(WB13_SFg2, addPlayers)
#ROUND 13, FWD Stoppage graph using weighted edges
WB13_SFft <- ftable(WB13_SFg2$player1, WB13_SFg2$player2)
WB13_SFft2 <- as.matrix(WB13_SFft)
numRows <- nrow(WB13_SFft2)
numCols <- ncol(WB13_SFft2)
WB13_SFft3 <- WB13_SFft2[c(2:numRows) , c(2:numCols)]
WB13_SFTable <- graph.adjacency(WB13_SFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Stoppage graph=weighted
plot.igraph(WB13_SFTable, vertex.label = V(WB13_SFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_SFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Stoppage calulation of network metrics
#igraph
WB13_SF.clusterCoef <- transitivity(WB13_SFTable, type="global") #cluster coefficient
WB13_SF.degreeCent <- centralization.degree(WB13_SFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_SFftn <- as.network.matrix(WB13_SFft)
WB13_SF.netDensity <- network.density(WB13_SFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_SF.entropy <- entropy(WB13_SFft) #entropy
WB13_SF.netMx <- cbind(WB13_SF.netMx, WB13_SF.clusterCoef, WB13_SF.degreeCent$centralization,
WB13_SF.netDensity, WB13_SF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_SF.netMx) <- varnames
#ROUND 13, FWD Turnover**********************************************************
round = 13
teamName = "WB"
KIoutcome = "Turnover_F"
WB13_TF.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, FWD Turnover with weighted edges
WB13_TFg2 <- data.frame(WB13_TF)
WB13_TFg2 <- WB13_TFg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_TFg2$player1
player2vector <- WB13_TFg2$player2
WB13_TFg3 <- WB13_TFg2
WB13_TFg3$p1inp2vec <- is.element(WB13_TFg3$player1, player2vector)
WB13_TFg3$p2inp1vec <- is.element(WB13_TFg3$player2, player1vector)
addPlayer1 <- WB13_TFg3[ which(WB13_TFg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_TFg3[ which(WB13_TFg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_TFg2 <- rbind(WB13_TFg2, addPlayers)
#ROUND 13, FWD Turnover graph using weighted edges
WB13_TFft <- ftable(WB13_TFg2$player1, WB13_TFg2$player2)
WB13_TFft2 <- as.matrix(WB13_TFft)
numRows <- nrow(WB13_TFft2)
numCols <- ncol(WB13_TFft2)
WB13_TFft3 <- WB13_TFft2[c(2:numRows) , c(2:numCols)]
WB13_TFTable <- graph.adjacency(WB13_TFft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, FWD Turnover graph=weighted
plot.igraph(WB13_TFTable, vertex.label = V(WB13_TFTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_TFTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, FWD Turnover calulation of network metrics
#igraph
WB13_TF.clusterCoef <- transitivity(WB13_TFTable, type="global") #cluster coefficient
WB13_TF.degreeCent <- centralization.degree(WB13_TFTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_TFftn <- as.network.matrix(WB13_TFft)
WB13_TF.netDensity <- network.density(WB13_TFftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_TF.entropy <- entropy(WB13_TFft) #entropy
WB13_TF.netMx <- cbind(WB13_TF.netMx, WB13_TF.clusterCoef, WB13_TF.degreeCent$centralization,
WB13_TF.netDensity, WB13_TF.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_TF.netMx) <- varnames
#ROUND 13, AM Stoppage**********************************************************
#NA
round = 13
teamName = "WB"
KIoutcome = "Stoppage_AM"
WB13_SAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Stoppage with weighted edges
WB13_SAMg2 <- data.frame(WB13_SAM)
WB13_SAMg2 <- WB13_SAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_SAMg2$player1
player2vector <- WB13_SAMg2$player2
WB13_SAMg3 <- WB13_SAMg2
WB13_SAMg3$p1inp2vec <- is.element(WB13_SAMg3$player1, player2vector)
WB13_SAMg3$p2inp1vec <- is.element(WB13_SAMg3$player2, player1vector)
addPlayer1 <- WB13_SAMg3[ which(WB13_SAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_SAMg3[ which(WB13_SAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_SAMg2 <- rbind(WB13_SAMg2, addPlayers)
#ROUND 13, AM Stoppage graph using weighted edges
WB13_SAMft <- ftable(WB13_SAMg2$player1, WB13_SAMg2$player2)
WB13_SAMft2 <- as.matrix(WB13_SAMft)
numRows <- nrow(WB13_SAMft2)
numCols <- ncol(WB13_SAMft2)
WB13_SAMft3 <- WB13_SAMft2[c(2:numRows) , c(2:numCols)]
WB13_SAMTable <- graph.adjacency(WB13_SAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Stoppage graph=weighted
plot.igraph(WB13_SAMTable, vertex.label = V(WB13_SAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_SAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Stoppage calulation of network metrics
#igraph
WB13_SAM.clusterCoef <- transitivity(WB13_SAMTable, type="global") #cluster coefficient
WB13_SAM.degreeCent <- centralization.degree(WB13_SAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_SAMftn <- as.network.matrix(WB13_SAMft)
WB13_SAM.netDensity <- network.density(WB13_SAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_SAM.entropy <- entropy(WB13_SAMft) #entropy
WB13_SAM.netMx <- cbind(WB13_SAM.netMx, WB13_SAM.clusterCoef, WB13_SAM.degreeCent$centralization,
WB13_SAM.netDensity, WB13_SAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_SAM.netMx) <- varnames
#ROUND 13, AM Turnover**********************************************************
round = 13
teamName = "WB"
KIoutcome = "Turnover_AM"
WB13_TAM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, AM Turnover with weighted edges
WB13_TAMg2 <- data.frame(WB13_TAM)
WB13_TAMg2 <- WB13_TAMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_TAMg2$player1
player2vector <- WB13_TAMg2$player2
WB13_TAMg3 <- WB13_TAMg2
WB13_TAMg3$p1inp2vec <- is.element(WB13_TAMg3$player1, player2vector)
WB13_TAMg3$p2inp1vec <- is.element(WB13_TAMg3$player2, player1vector)
addPlayer1 <- WB13_TAMg3[ which(WB13_TAMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_TAMg3[ which(WB13_TAMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_TAMg2 <- rbind(WB13_TAMg2, addPlayers)
#ROUND 13, AM Turnover graph using weighted edges
WB13_TAMft <- ftable(WB13_TAMg2$player1, WB13_TAMg2$player2)
WB13_TAMft2 <- as.matrix(WB13_TAMft)
numRows <- nrow(WB13_TAMft2)
numCols <- ncol(WB13_TAMft2)
WB13_TAMft3 <- WB13_TAMft2[c(2:numRows) , c(2:numCols)]
WB13_TAMTable <- graph.adjacency(WB13_TAMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, AM Turnover graph=weighted
plot.igraph(WB13_TAMTable, vertex.label = V(WB13_TAMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_TAMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, AM Turnover calulation of network metrics
#igraph
WB13_TAM.clusterCoef <- transitivity(WB13_TAMTable, type="global") #cluster coefficient
WB13_TAM.degreeCent <- centralization.degree(WB13_TAMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_TAMftn <- as.network.matrix(WB13_TAMft)
WB13_TAM.netDensity <- network.density(WB13_TAMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_TAM.entropy <- entropy(WB13_TAMft) #entropy
WB13_TAM.netMx <- cbind(WB13_TAM.netMx, WB13_TAM.clusterCoef, WB13_TAM.degreeCent$centralization,
WB13_TAM.netDensity, WB13_TAM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_TAM.netMx) <- varnames
#ROUND 13, DM Stoppage**********************************************************
round = 13
teamName = "WB"
KIoutcome = "Stoppage_DM"
WB13_SDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Stoppage with weighted edges
WB13_SDMg2 <- data.frame(WB13_SDM)
WB13_SDMg2 <- WB13_SDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_SDMg2$player1
player2vector <- WB13_SDMg2$player2
WB13_SDMg3 <- WB13_SDMg2
WB13_SDMg3$p1inp2vec <- is.element(WB13_SDMg3$player1, player2vector)
WB13_SDMg3$p2inp1vec <- is.element(WB13_SDMg3$player2, player1vector)
addPlayer1 <- WB13_SDMg3[ which(WB13_SDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_SDMg3[ which(WB13_SDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_SDMg2 <- rbind(WB13_SDMg2, addPlayers)
#ROUND 13, DM Stoppage graph using weighted edges
WB13_SDMft <- ftable(WB13_SDMg2$player1, WB13_SDMg2$player2)
WB13_SDMft2 <- as.matrix(WB13_SDMft)
numRows <- nrow(WB13_SDMft2)
numCols <- ncol(WB13_SDMft2)
WB13_SDMft3 <- WB13_SDMft2[c(2:numRows) , c(2:numCols)]
WB13_SDMTable <- graph.adjacency(WB13_SDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Stoppage graph=weighted
plot.igraph(WB13_SDMTable, vertex.label = V(WB13_SDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_SDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Stoppage calulation of network metrics
#igraph
WB13_SDM.clusterCoef <- transitivity(WB13_SDMTable, type="global") #cluster coefficient
WB13_SDM.degreeCent <- centralization.degree(WB13_SDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_SDMftn <- as.network.matrix(WB13_SDMft)
WB13_SDM.netDensity <- network.density(WB13_SDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_SDM.entropy <- entropy(WB13_SDMft) #entropy
WB13_SDM.netMx <- cbind(WB13_SDM.netMx, WB13_SDM.clusterCoef, WB13_SDM.degreeCent$centralization,
WB13_SDM.netDensity, WB13_SDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_SDM.netMx) <- varnames
#ROUND 13, DM Turnover**********************************************************
round = 13
teamName = "WB"
KIoutcome = "Turnover_DM"
WB13_TDM.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, DM Turnover with weighted edges
WB13_TDMg2 <- data.frame(WB13_TDM)
WB13_TDMg2 <- WB13_TDMg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_TDMg2$player1
player2vector <- WB13_TDMg2$player2
WB13_TDMg3 <- WB13_TDMg2
WB13_TDMg3$p1inp2vec <- is.element(WB13_TDMg3$player1, player2vector)
WB13_TDMg3$p2inp1vec <- is.element(WB13_TDMg3$player2, player1vector)
addPlayer1 <- WB13_TDMg3[ which(WB13_TDMg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_TDMg3[ which(WB13_TDMg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_TDMg2 <- rbind(WB13_TDMg2, addPlayers)
#ROUND 13, DM Turnover graph using weighted edges
WB13_TDMft <- ftable(WB13_TDMg2$player1, WB13_TDMg2$player2)
WB13_TDMft2 <- as.matrix(WB13_TDMft)
numRows <- nrow(WB13_TDMft2)
numCols <- ncol(WB13_TDMft2)
WB13_TDMft3 <- WB13_TDMft2[c(2:numRows) , c(2:numCols)]
WB13_TDMTable <- graph.adjacency(WB13_TDMft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, DM Turnover graph=weighted
plot.igraph(WB13_TDMTable, vertex.label = V(WB13_TDMTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_TDMTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, DM Turnover calulation of network metrics
#igraph
WB13_TDM.clusterCoef <- transitivity(WB13_TDMTable, type="global") #cluster coefficient
WB13_TDM.degreeCent <- centralization.degree(WB13_TDMTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_TDMftn <- as.network.matrix(WB13_TDMft)
WB13_TDM.netDensity <- network.density(WB13_TDMftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_TDM.entropy <- entropy(WB13_TDMft) #entropy
WB13_TDM.netMx <- cbind(WB13_TDM.netMx, WB13_TDM.clusterCoef, WB13_TDM.degreeCent$centralization,
WB13_TDM.netDensity, WB13_TDM.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_TDM.netMx) <- varnames
#ROUND 13, D Stoppage**********************************************************
#NA
round = 13
teamName = "WB"
KIoutcome = "Stoppage_D"
WB13_SD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Stoppage with weighted edges
WB13_SDg2 <- data.frame(WB13_SD)
WB13_SDg2 <- WB13_SDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_SDg2$player1
player2vector <- WB13_SDg2$player2
WB13_SDg3 <- WB13_SDg2
WB13_SDg3$p1inp2vec <- is.element(WB13_SDg3$player1, player2vector)
WB13_SDg3$p2inp1vec <- is.element(WB13_SDg3$player2, player1vector)
addPlayer1 <- WB13_SDg3[ which(WB13_SDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_SDg3[ which(WB13_SDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_SDg2 <- rbind(WB13_SDg2, addPlayers)
#ROUND 13, D Stoppage graph using weighted edges
WB13_SDft <- ftable(WB13_SDg2$player1, WB13_SDg2$player2)
WB13_SDft2 <- as.matrix(WB13_SDft)
numRows <- nrow(WB13_SDft2)
numCols <- ncol(WB13_SDft2)
WB13_SDft3 <- WB13_SDft2[c(2:numRows) , c(2:numCols)]
WB13_SDTable <- graph.adjacency(WB13_SDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Stoppage graph=weighted
plot.igraph(WB13_SDTable, vertex.label = V(WB13_SDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_SDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Stoppage calulation of network metrics
#igraph
WB13_SD.clusterCoef <- transitivity(WB13_SDTable, type="global") #cluster coefficient
WB13_SD.degreeCent <- centralization.degree(WB13_SDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_SDftn <- as.network.matrix(WB13_SDft)
WB13_SD.netDensity <- network.density(WB13_SDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_SD.entropy <- entropy(WB13_SDft) #entropy
WB13_SD.netMx <- cbind(WB13_SD.netMx, WB13_SD.clusterCoef, WB13_SD.degreeCent$centralization,
WB13_SD.netDensity, WB13_SD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_SD.netMx) <- varnames
#ROUND 13, D Turnover**********************************************************
#NA
round = 13
teamName = "WB"
KIoutcome = "Turnover_D"
WB13_TD.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, D Turnover with weighted edges
WB13_TDg2 <- data.frame(WB13_TD)
WB13_TDg2 <- WB13_TDg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_TDg2$player1
player2vector <- WB13_TDg2$player2
WB13_TDg3 <- WB13_TDg2
WB13_TDg3$p1inp2vec <- is.element(WB13_TDg3$player1, player2vector)
WB13_TDg3$p2inp1vec <- is.element(WB13_TDg3$player2, player1vector)
addPlayer1 <- WB13_TDg3[ which(WB13_TDg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_TDg3[ which(WB13_TDg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_TDg2 <- rbind(WB13_TDg2, addPlayers)
#ROUND 13, D Turnover graph using weighted edges
WB13_TDft <- ftable(WB13_TDg2$player1, WB13_TDg2$player2)
WB13_TDft2 <- as.matrix(WB13_TDft)
numRows <- nrow(WB13_TDft2)
numCols <- ncol(WB13_TDft2)
WB13_TDft3 <- WB13_TDft2[c(2:numRows) , c(2:numCols)]
WB13_TDTable <- graph.adjacency(WB13_TDft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, D Turnover graph=weighted
plot.igraph(WB13_TDTable, vertex.label = V(WB13_TDTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_TDTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, D Turnover calulation of network metrics
#igraph
WB13_TD.clusterCoef <- transitivity(WB13_TDTable, type="global") #cluster coefficient
WB13_TD.degreeCent <- centralization.degree(WB13_TDTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_TDftn <- as.network.matrix(WB13_TDft)
WB13_TD.netDensity <- network.density(WB13_TDftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_TD.entropy <- entropy(WB13_TDft) #entropy
WB13_TD.netMx <- cbind(WB13_TD.netMx, WB13_TD.clusterCoef, WB13_TD.degreeCent$centralization,
WB13_TD.netDensity, WB13_TD.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_TD.netMx) <- varnames
#ROUND 13, End of Qtr**********************************************************
#NA
round = 13
teamName = "WB"
KIoutcome = "End of Qtr_DM"
WB13_QT.netMx <- cbind(round, teamName, KIoutcome)
#ROUND 13, End of Qtr with weighted edges
WB13_QTg2 <- data.frame(WB13_QT)
WB13_QTg2 <- WB13_QTg2[,c(4:6)]
# Identify players who only disposed but did not receive OR only received but did not dispose of the ball
# These players need to be added into the data frame without a 'partner' in order to create a square matrix
player1vector <- WB13_QTg2$player1
player2vector <- WB13_QTg2$player2
WB13_QTg3 <- WB13_QTg2
WB13_QTg3$p1inp2vec <- is.element(WB13_QTg3$player1, player2vector)
WB13_QTg3$p2inp1vec <- is.element(WB13_QTg3$player2, player1vector)
addPlayer1 <- WB13_QTg3[ which(WB13_QTg3$p1inp2vec == FALSE), 1]
empty <- ""
zero <- 0
addPlayer1 <- cbind(empty, addPlayer1, zero)
addPlayer2 <- WB13_QTg3[ which(WB13_QTg3$p2inp1vec == FALSE), 2]
addPlayer2 <- cbind(addPlayer2, empty, zero)
addPlayers <- rbind(addPlayer1, addPlayer2)
varnames <- c("player1", "player2", "weight")
colnames(addPlayers) <- varnames
WB13_QTg2 <- rbind(WB13_QTg2, addPlayers)
#ROUND 13, End of Qtr graph using weighted edges
WB13_QTft <- ftable(WB13_QTg2$player1, WB13_QTg2$player2)
WB13_QTft2 <- as.matrix(WB13_QTft)
numRows <- nrow(WB13_QTft2)
numCols <- ncol(WB13_QTft2)
WB13_QTft3 <- WB13_QTft2[c(2:numRows) , c(2:numCols)]
WB13_QTTable <- graph.adjacency(WB13_QTft3, mode="directed", weighted = T, diag = F,
add.colnames = NULL)
#ROUND 13, End of Qtr graph=weighted
plot.igraph(WB13_QTTable, vertex.label = V(WB13_QTTable)$names,
layout = layout.fruchterman.reingold,
edge.color="black", edge.width = E(WB13_QTTable)$weight, edge.arrow.size=0.15,vertex.label.cex=0.4)
#ROUND 13, End of Qtr calulation of network metrics
#igraph
WB13_QT.clusterCoef <- transitivity(WB13_QTTable, type="global") #cluster coefficient
WB13_QT.degreeCent <- centralization.degree(WB13_QTTable, mode=c("all"), normalized = TRUE) #degree centrality
#network-create a nework object
WB13_QTftn <- as.network.matrix(WB13_QTft)
WB13_QT.netDensity <- network.density(WB13_QTftn, na.omit=TRUE, discount.bipartite = FALSE) #density
#QuACN- take the original ftable
WB13_QT.entropy <- entropy(WB13_QTft) #entropy
WB13_QT.netMx <- cbind(WB13_QT.netMx, WB13_QT.clusterCoef, WB13_QT.degreeCent$centralization,
WB13_QT.netDensity, WB13_QT.entropy)
varnames <- c("round", "team", "kickInOutcome", "clusterCoef", "degreeCent", "netDensity", "entropy")
colnames(WB13_QT.netMx) <- varnames
|
#' @title Unsaturated hydraulic conductivity
#' @description Calculates unsaturated hydraulic conductivity for a given suction for unimodal or bimodal van Genuchten-Mualem (vg/vgm), Peters-Durner-Iden (PDI) and Brooks and Corey (bc) (only unimodal) parameterisation.
#' @param suc Suction/pressure heads. Negative if suc.negativ = TRUE
#' @param FUN.shp Funktion for soil hydraulic properties (vGM or PDI) (see details)
#' @param par.shp named parameter in list or vector
#' @param modality pore size distribution ('uni' or 'bi')
#' @param suc.negativ set TRUE if suction/pressure heads are negative and FALSE if positive
#' @return unsaturated hydraulic conductivity (ku)
#' @details
#' \describe{\item{FUN.shp:}{vGM: van Genuchten-Mualem (uni or bimodal) ('vg' works aswell)\cr
#' PDI: Peters-Durner-Iden with van Genuchtens saturation function (uni or bimodal) \cr
#' bc: Brooks and Corey (unimodal)}}
#' \describe{\item{par.shp (vG and PDI):}{
#' ths [-]: saturated water content\cr
#' thr [-]: residual water content\cr
#' alfa [1/L]: van Genuchten shape parameter\cr
#' n [-]: van Genuchten shape parameter\cr
#' m [-]: shape parameter (m = 1-(1/n) if missing)\cr
#' Ks [L/time]: saturated hydraulic conductivity\cr
#' tau [-]: tortuosity and connectivity parameter (minimum -1 or -2 for the PDI model; see Peters (2014) for details)}
#' \item{par.shp (additional parameter for 'PDI'):}{
#' omega: weighting between relative capillary and film conductivity \cr
#' h0 [L]: suction at water content of 0 (i.e. oven dryness) (h0 = 10^6.8 if missing, corresponding to oven dryness at 105°C (Schneider and Goss, 2012))\cr
#' a: slope at the log scale (a = -1.5 if missing as suggested by Tokunaga (2009) and Peters (2013))}
#' \item{par.shp (additional parameter for bimodal (modality = 'bi')):}{
#' w2 [-]: weigthing between pore space distributions \cr
#' alfa2 [1/L]: van Genuchten parameter alfa for second pore space distribution \cr
#' n2 [-]: van Genuchten parameter n for second pore space distribution}}
#' \describe{\item{par.shp (BC):}{
#' ths [-]: saturated water content \cr
#' thr [-]: residual water content\cr
#' alfa [1/L]: inverse of the air-entry value or bubbling pressure \cr
#' lambda [-]: pore size distribution index \cr
#' tau [-]: tortuosity and connectivity parameter (minimum -1 or -2 for the PDI model; see Peters (2014) for details)}}
#' @details most input works for upper- and lowercase letters
#' @examples
#' # --------------------------------------------
#' # Unimodal van Genuchten
#' # --------------------------------------------
#' Ku(suc = seq(1, 1000, by = 1), FUN.shp = 'vGM',
#' par.shp = list(Ks = 10, ths = 0.5, thr = 0, alfa = 0.02, n = 1.5, tau = 0.5),
#' modality = 'uni', suc.negativ = FALSE)
#' # --------------------------------------------
#' # Bimodal van Genuchten
#' # --------------------------------------------
#' Ku(suc = seq(1, 1000, by = 1), FUN.shp = 'vGM',
#' par.shp = list(Ks = 10, ths = 0.5, thr = 0, alfa = 0.02,
#' n = 1.5, tau = 0.5, w2 = 0.1, alfa2 = 0.1, n2 = 3),
#' modality = 'bi', suc.negativ = FALSE)
#' # --------------------------------------------
#' # Unimodal Peters-Durner-Iden (PDI)
#' # --------------------------------------------
#' Ku(suc = seq(1, 1000, by = 1), FUN.shp = 'PDI', modality = 'uni',
#' par.shp = list(Ks = 10, ths = 0.5, thr = 0, alfa = 0.02, n = 1.5, tau = 0.5, omega = 0.001),
#' suc.negativ = FALSE)
#' # --------------------------------------------
#' # Brooks and Corey (BC) (only unimodal)
#' # --------------------------------------------
#' Ku(suc = seq(1, 1000, by = 1), FUN.shp = 'bc', modality = 'uni',
#' par.shp = list(ths = 0.4, thr = 0, lambda = 0.211, alfa = 0.1, tau = 0.5, ks = 10),
#' suc.negativ = FALSE)
#' # --------------------------------------------
#' @references Van Genuchten, M. T. (1980). A closed-form equation for predicting the hydraulic conductivity of unsaturated soils. Soil science society of America journal, 44(5), 892-898.
#' @references Mualem, Y. (1976). A new model for predicting the hydraulic conductivity of unsaturated porous media. Water resources research, 12(3), 513-522.
#' @references Peters, A. (2013). Simple consistent models for water retention and hydraulic conductivity in the complete moisture range. Water Resour. Res. 49, 6765–6780. physics-a review. Vadose Zone J. http://dx.doi.org/10.2136/vzj2012.0163.
#' @references Iden, S., Durner, W. (2014). Comment to Simple consistent models for water retention and hydraulic conductivity in the complete moisture range by A. Peters. Water Resour. Res. 50, 7530–7534.
#' @references Peters, A. (2014). Reply to comment by S. Iden and W. Durner on Simple consistent models for water retention and hydraulic conductivity in the complete moisture range. Water Resour. Res. 50, 7535–7539.
#' @references Tokunaga, T. K. (2009), Hydraulic properties of adsorbed water films in unsaturated porous media, Water Resour. Res., 45, W06415, doi: 10.1029/2009WR007734.
#' @references Priesack, E., Durner, W., 2006. Closed-form expression for the multi-modal unsaturated conductivity function. Vadose Zone J. 5, 121–124.
#' @references Durner, W. (1994). Hydraulic conductivity estimation for soils with heterogeneous pore structure. Water Resources Research, 30(2), 211-223.
#' @references Schneider, M., & Goss, K. U. (2012). Prediction of the water sorption isotherm in air dry soils. Geoderma, 170, 64-69.
#' @references Brooks, R.H., and A.T. Corey (1964): Hydraulic properties of porous media. Hydrol. Paper 3. Colorado State Univ., Fort Collins, CO, USA.
#' @author Ullrich Dettmann
#' @seealso \code{\link{SWC}} and \code{\link{Sat}}
#' @export
Ku <- function(suc, FUN.shp = 'vG', par.shp, modality = 'uni', suc.negativ = TRUE) {
if (!is.list(par.shp)) { par.shp <- as.list(par.shp) }
# tolower input
names(par.shp) <- tolower(names(par.shp))
modality <- tolower(modality)
FUN.shp <- tolower(FUN.shp)
if(modality == 'bimodal') { modality = 'bi'}
if(modality == 'unimodal') { modality = 'uni'}
if (FUN.shp == 'vgm') {FUN.shp <- 'vg'}
# prepare input
if(suc.negativ == FALSE) { suc <- suc * -1 }
suc <- ifelse(suc > 0, 0, suc)
# check if all necessary parameter are given in input
stopifnot(any(names(par.shp) == 'alfa'))
stopifnot(any(names(par.shp) == 'thr'))
stopifnot(any(names(par.shp) == 'ths'))
stopifnot(any(names(par.shp) == 'ks'))
stopifnot(any(names(par.shp) == 'tau'))
# add m if missing
if(!any(names(par.shp) %in% 'm')) { par.shp$m <- 1 - (1/par.shp$n) }
# --------------------------------------------------------------------------------------------
## pdi
if (FUN.shp == 'pdi') {
# add h0 if missing
stopifnot(any(names(par.shp) == 'n'))
if(!any(names(par.shp) %in% 'h0')) { par.shp$h0 <- 10^6.8 }
if(!any(names(par.shp) %in% 'a')) { par.shp$a <- -1.5 }
# stop if a parameter is missing in par.shp
stopifnot(any(names(par.shp) == 'omega'))
suc[suc < -par.shp$h0] <- -par.shp$h0
kfilm <- Kfilm(suc, par.shp = par.shp, modality = modality, suc.negativ = TRUE)
kcap <- Kcap(suc, par.shp = par.shp, modality = modality, suc.negativ = TRUE)
K <- ((par.shp$ks*(1 - par.shp$omega)) * kcap) +
((par.shp$ks* par.shp$omega) * kfilm)
K[suc == 0] <- par.shp$ks
}
if (FUN.shp == 'vg') {
stopifnot(any(names(par.shp) == 'n'))
if (modality == 'uni'){
Se1<-(1+(par.shp$alfa*-suc)^par.shp$n)^(-par.shp$m)
K <- par.shp$ks * Se1^par.shp$tau*((1-((1 - (Se1^(1/par.shp$m)))^par.shp$m))^2)
}
if (modality == 'bi') {
# check if all necessary parameter are given in input
stopifnot(any(names(par.shp) == 'alfa2'))
stopifnot(any(names(par.shp) == 'n2'))
stopifnot(any(names(par.shp) == 'w2'))
if(!any(names(par.shp) %in% 'm2')) { par.shp$m2 <- 1 - (1/par.shp$n2) }
Se1<-(1+(par.shp$alfa*-suc)^par.shp$n)^(-par.shp$m)
Se2<-(1+(par.shp$alfa2*-suc)^par.shp$n2)^(-par.shp$m2)
wSe1<- (1 - par.shp$w2) *(1 + (par.shp$alfa*-suc)^par.shp$n)^(-par.shp$m)
wSe2<- par.shp$w2 *(1+(par.shp$alfa2*-suc)^par.shp$n2)^(-par.shp$m2)
term1_oben<-(wSe1+wSe2)^par.shp$tau;
w1 <- (1 -par.shp$w2)
temp_w1<- (w1) * par.shp$alfa *(1-(1- Se1 ^(1/par.shp$m))^par.shp$m)
temp_w2<- (par.shp$w2) * par.shp$alfa2 *(1-(1- Se2 ^(1/par.shp$m2))^par.shp$m2)
t_o<- (temp_w1 + temp_w2)^2
temp_u<- ((w1 *par.shp$alfa)+(par.shp$w2*par.shp$alfa2))^2
K <- par.shp$ks * ((term1_oben * t_o) / temp_u)
}
}
if (FUN.shp == 'bc') {
# check if all necessary parameter are given in input
stopifnot(any(names(par.shp) == 'alfa'))
stopifnot(any(names(par.shp) == 'lambda'))
stopifnot(modality == 'uni')
K <- par.shp$ks * (Sat(suc = suc, par.shp = par.shp, FUN.shp = FUN.shp, modality = 'uni', suc.negativ = TRUE))^((2/par.shp$lambda) + par.shp$tau + 2)
}
K
}
| /R/Ku.R | no_license | cran/SoilHyP | R | false | false | 9,044 | r | #' @title Unsaturated hydraulic conductivity
#' @description Calculates unsaturated hydraulic conductivity for a given suction for unimodal or bimodal van Genuchten-Mualem (vg/vgm), Peters-Durner-Iden (PDI) and Brooks and Corey (bc) (only unimodal) parameterisation.
#' @param suc Suction/pressure heads. Negative if suc.negativ = TRUE
#' @param FUN.shp Funktion for soil hydraulic properties (vGM or PDI) (see details)
#' @param par.shp named parameter in list or vector
#' @param modality pore size distribution ('uni' or 'bi')
#' @param suc.negativ set TRUE if suction/pressure heads are negative and FALSE if positive
#' @return unsaturated hydraulic conductivity (ku)
#' @details
#' \describe{\item{FUN.shp:}{vGM: van Genuchten-Mualem (uni or bimodal) ('vg' works aswell)\cr
#' PDI: Peters-Durner-Iden with van Genuchtens saturation function (uni or bimodal) \cr
#' bc: Brooks and Corey (unimodal)}}
#' \describe{\item{par.shp (vG and PDI):}{
#' ths [-]: saturated water content\cr
#' thr [-]: residual water content\cr
#' alfa [1/L]: van Genuchten shape parameter\cr
#' n [-]: van Genuchten shape parameter\cr
#' m [-]: shape parameter (m = 1-(1/n) if missing)\cr
#' Ks [L/time]: saturated hydraulic conductivity\cr
#' tau [-]: tortuosity and connectivity parameter (minimum -1 or -2 for the PDI model; see Peters (2014) for details)}
#' \item{par.shp (additional parameter for 'PDI'):}{
#' omega: weighting between relative capillary and film conductivity \cr
#' h0 [L]: suction at water content of 0 (i.e. oven dryness) (h0 = 10^6.8 if missing, corresponding to oven dryness at 105°C (Schneider and Goss, 2012))\cr
#' a: slope at the log scale (a = -1.5 if missing as suggested by Tokunaga (2009) and Peters (2013))}
#' \item{par.shp (additional parameter for bimodal (modality = 'bi')):}{
#' w2 [-]: weigthing between pore space distributions \cr
#' alfa2 [1/L]: van Genuchten parameter alfa for second pore space distribution \cr
#' n2 [-]: van Genuchten parameter n for second pore space distribution}}
#' \describe{\item{par.shp (BC):}{
#' ths [-]: saturated water content \cr
#' thr [-]: residual water content\cr
#' alfa [1/L]: inverse of the air-entry value or bubbling pressure \cr
#' lambda [-]: pore size distribution index \cr
#' tau [-]: tortuosity and connectivity parameter (minimum -1 or -2 for the PDI model; see Peters (2014) for details)}}
#' @details most input works for upper- and lowercase letters
#' @examples
#' # --------------------------------------------
#' # Unimodal van Genuchten
#' # --------------------------------------------
#' Ku(suc = seq(1, 1000, by = 1), FUN.shp = 'vGM',
#' par.shp = list(Ks = 10, ths = 0.5, thr = 0, alfa = 0.02, n = 1.5, tau = 0.5),
#' modality = 'uni', suc.negativ = FALSE)
#' # --------------------------------------------
#' # Bimodal van Genuchten
#' # --------------------------------------------
#' Ku(suc = seq(1, 1000, by = 1), FUN.shp = 'vGM',
#' par.shp = list(Ks = 10, ths = 0.5, thr = 0, alfa = 0.02,
#' n = 1.5, tau = 0.5, w2 = 0.1, alfa2 = 0.1, n2 = 3),
#' modality = 'bi', suc.negativ = FALSE)
#' # --------------------------------------------
#' # Unimodal Peters-Durner-Iden (PDI)
#' # --------------------------------------------
#' Ku(suc = seq(1, 1000, by = 1), FUN.shp = 'PDI', modality = 'uni',
#' par.shp = list(Ks = 10, ths = 0.5, thr = 0, alfa = 0.02, n = 1.5, tau = 0.5, omega = 0.001),
#' suc.negativ = FALSE)
#' # --------------------------------------------
#' # Brooks and Corey (BC) (only unimodal)
#' # --------------------------------------------
#' Ku(suc = seq(1, 1000, by = 1), FUN.shp = 'bc', modality = 'uni',
#' par.shp = list(ths = 0.4, thr = 0, lambda = 0.211, alfa = 0.1, tau = 0.5, ks = 10),
#' suc.negativ = FALSE)
#' # --------------------------------------------
#' @references Van Genuchten, M. T. (1980). A closed-form equation for predicting the hydraulic conductivity of unsaturated soils. Soil science society of America journal, 44(5), 892-898.
#' @references Mualem, Y. (1976). A new model for predicting the hydraulic conductivity of unsaturated porous media. Water resources research, 12(3), 513-522.
#' @references Peters, A. (2013). Simple consistent models for water retention and hydraulic conductivity in the complete moisture range. Water Resour. Res. 49, 6765–6780. physics-a review. Vadose Zone J. http://dx.doi.org/10.2136/vzj2012.0163.
#' @references Iden, S., Durner, W. (2014). Comment to Simple consistent models for water retention and hydraulic conductivity in the complete moisture range by A. Peters. Water Resour. Res. 50, 7530–7534.
#' @references Peters, A. (2014). Reply to comment by S. Iden and W. Durner on Simple consistent models for water retention and hydraulic conductivity in the complete moisture range. Water Resour. Res. 50, 7535–7539.
#' @references Tokunaga, T. K. (2009), Hydraulic properties of adsorbed water films in unsaturated porous media, Water Resour. Res., 45, W06415, doi: 10.1029/2009WR007734.
#' @references Priesack, E., Durner, W., 2006. Closed-form expression for the multi-modal unsaturated conductivity function. Vadose Zone J. 5, 121–124.
#' @references Durner, W. (1994). Hydraulic conductivity estimation for soils with heterogeneous pore structure. Water Resources Research, 30(2), 211-223.
#' @references Schneider, M., & Goss, K. U. (2012). Prediction of the water sorption isotherm in air dry soils. Geoderma, 170, 64-69.
#' @references Brooks, R.H., and A.T. Corey (1964): Hydraulic properties of porous media. Hydrol. Paper 3. Colorado State Univ., Fort Collins, CO, USA.
#' @author Ullrich Dettmann
#' @seealso \code{\link{SWC}} and \code{\link{Sat}}
#' @export
Ku <- function(suc, FUN.shp = 'vG', par.shp, modality = 'uni', suc.negativ = TRUE) {
if (!is.list(par.shp)) { par.shp <- as.list(par.shp) }
# tolower input
names(par.shp) <- tolower(names(par.shp))
modality <- tolower(modality)
FUN.shp <- tolower(FUN.shp)
if(modality == 'bimodal') { modality = 'bi'}
if(modality == 'unimodal') { modality = 'uni'}
if (FUN.shp == 'vgm') {FUN.shp <- 'vg'}
# prepare input
if(suc.negativ == FALSE) { suc <- suc * -1 }
suc <- ifelse(suc > 0, 0, suc)
# check if all necessary parameter are given in input
stopifnot(any(names(par.shp) == 'alfa'))
stopifnot(any(names(par.shp) == 'thr'))
stopifnot(any(names(par.shp) == 'ths'))
stopifnot(any(names(par.shp) == 'ks'))
stopifnot(any(names(par.shp) == 'tau'))
# add m if missing
if(!any(names(par.shp) %in% 'm')) { par.shp$m <- 1 - (1/par.shp$n) }
# --------------------------------------------------------------------------------------------
## pdi
if (FUN.shp == 'pdi') {
# add h0 if missing
stopifnot(any(names(par.shp) == 'n'))
if(!any(names(par.shp) %in% 'h0')) { par.shp$h0 <- 10^6.8 }
if(!any(names(par.shp) %in% 'a')) { par.shp$a <- -1.5 }
# stop if a parameter is missing in par.shp
stopifnot(any(names(par.shp) == 'omega'))
suc[suc < -par.shp$h0] <- -par.shp$h0
kfilm <- Kfilm(suc, par.shp = par.shp, modality = modality, suc.negativ = TRUE)
kcap <- Kcap(suc, par.shp = par.shp, modality = modality, suc.negativ = TRUE)
K <- ((par.shp$ks*(1 - par.shp$omega)) * kcap) +
((par.shp$ks* par.shp$omega) * kfilm)
K[suc == 0] <- par.shp$ks
}
if (FUN.shp == 'vg') {
stopifnot(any(names(par.shp) == 'n'))
if (modality == 'uni'){
Se1<-(1+(par.shp$alfa*-suc)^par.shp$n)^(-par.shp$m)
K <- par.shp$ks * Se1^par.shp$tau*((1-((1 - (Se1^(1/par.shp$m)))^par.shp$m))^2)
}
if (modality == 'bi') {
# check if all necessary parameter are given in input
stopifnot(any(names(par.shp) == 'alfa2'))
stopifnot(any(names(par.shp) == 'n2'))
stopifnot(any(names(par.shp) == 'w2'))
if(!any(names(par.shp) %in% 'm2')) { par.shp$m2 <- 1 - (1/par.shp$n2) }
Se1<-(1+(par.shp$alfa*-suc)^par.shp$n)^(-par.shp$m)
Se2<-(1+(par.shp$alfa2*-suc)^par.shp$n2)^(-par.shp$m2)
wSe1<- (1 - par.shp$w2) *(1 + (par.shp$alfa*-suc)^par.shp$n)^(-par.shp$m)
wSe2<- par.shp$w2 *(1+(par.shp$alfa2*-suc)^par.shp$n2)^(-par.shp$m2)
term1_oben<-(wSe1+wSe2)^par.shp$tau;
w1 <- (1 -par.shp$w2)
temp_w1<- (w1) * par.shp$alfa *(1-(1- Se1 ^(1/par.shp$m))^par.shp$m)
temp_w2<- (par.shp$w2) * par.shp$alfa2 *(1-(1- Se2 ^(1/par.shp$m2))^par.shp$m2)
t_o<- (temp_w1 + temp_w2)^2
temp_u<- ((w1 *par.shp$alfa)+(par.shp$w2*par.shp$alfa2))^2
K <- par.shp$ks * ((term1_oben * t_o) / temp_u)
}
}
if (FUN.shp == 'bc') {
# check if all necessary parameter are given in input
stopifnot(any(names(par.shp) == 'alfa'))
stopifnot(any(names(par.shp) == 'lambda'))
stopifnot(modality == 'uni')
K <- par.shp$ks * (Sat(suc = suc, par.shp = par.shp, FUN.shp = FUN.shp, modality = 'uni', suc.negativ = TRUE))^((2/par.shp$lambda) + par.shp$tau + 2)
}
K
}
|
##' @include guiContainer.R
##' Class for tabbed notebook container
setClass("gNotebook",
contains="guiContainer",
prototype=prototype(new("guiContainer"))
)
##' Constructor for a tabbed notebook container
##'
##' @export
gnotebook <- function(
tab.pos = 3, closebuttons = FALSE, dontCloseThese = NULL,
container = NULL, ... ,
toolkit=guiToolkit()){
widget <- .gnotebook (toolkit,
tab.pos=tab.pos, closebuttons=closebuttons, dontCloseThese=dontCloseThese,
container=container ,...
)
obj <- new( 'gNotebook', widget=widget,toolkit=toolkit)
return(obj)
}
##' generic for toolkit dispatch
##' @alias gnotebook
setGeneric( '.gnotebook' ,
function(toolkit,
tab.pos = 3, closebuttons = FALSE, dontCloseThese = NULL,
container = NULL, ... )
standardGeneric( '.gnotebook' ))
| /R/gnotebook.R | no_license | plantarum/gWidgets | R | false | false | 1,004 | r | ##' @include guiContainer.R
##' Class for tabbed notebook container
setClass("gNotebook",
contains="guiContainer",
prototype=prototype(new("guiContainer"))
)
##' Constructor for a tabbed notebook container
##'
##' @export
gnotebook <- function(
tab.pos = 3, closebuttons = FALSE, dontCloseThese = NULL,
container = NULL, ... ,
toolkit=guiToolkit()){
widget <- .gnotebook (toolkit,
tab.pos=tab.pos, closebuttons=closebuttons, dontCloseThese=dontCloseThese,
container=container ,...
)
obj <- new( 'gNotebook', widget=widget,toolkit=toolkit)
return(obj)
}
##' generic for toolkit dispatch
##' @alias gnotebook
setGeneric( '.gnotebook' ,
function(toolkit,
tab.pos = 3, closebuttons = FALSE, dontCloseThese = NULL,
container = NULL, ... )
standardGeneric( '.gnotebook' ))
|
get_QB_Names <- function(){
url <- paste0("https://www.pro-football-reference.com/play-index/draft-finder.cgi?request=1&year_min=1990&year_max=2017&draft_slot_min=1&draft_slot_max=500&pick_type=overall&pos%5B%5D=qb&conference=any&show=p&order_by=default")
linkbase <- read_html(url) %>% html_nodes("table tbody a") %>% html_attr('href')
linkname <- read_html(url) %>% html_nodes("table tbody a") %>% html_text()
link_logic <- linkbase %>% grepl("^/players/",.)
linkbase <- linkbase[link_logic]
linkname <- linkname[link_logic]
links <- paste0("https://pro-football-reference.com", linkbase)
data <- data.frame(linkname,links, stringsAsFactors = FALSE)
return(data)
}
get_NFL_Passing <- function(link, name) {
print(paste0("Getting NFL stats for: ", name, " at: ", link))
length <- read_html(link) %>% html_nodes("#passing") %>% length()
if(length == 1) {
passing_table <- read_html(link) %>% html_nodes("#passing") %>% html_table() %>% .[[1]] %>% as.data.frame()
if(length(names(passing_table)) > 30){
passing_table <- passing_table[,-23]
}
names(passing_table)[24] <- "Sk_Yds"
passing_table$Player <- name
passing_table <- passing_table %>% filter(Year == "Career")
passing_table <- passing_table %>% mutate_at(vars(No.:GS), as.numeric)
passing_table <- passing_table %>% mutate_at(vars(Cmp:AV), as.numeric)
}
else {
passing_table <- data.frame()
}
return(passing_table)
}
get_NCAA_fumbles <- function(name){
fox_link <- paste0("https://www.foxsports.com/college-football/", gsub(" ", "-",name), "-player-game-log")
seasons <- read_html(fox_link) %>% html_nodes("select") %>% html_text() %>% regmatches(.,gregexpr(".{4}",.)) %>% .[[1]]
season_table <- read_html("foxqb.html") %>% html_nodes(".wisbb_standardTable") %>% html_table() %>% as.data.frame(stringsAsFactors = FALSE)
season_table$season <- seasons[1]
season_table$Player <- name
if(length(seasons) > 1) {
seasons <- seasons[-1]
fox_link <- paste0(fox_link, "?season=", seasons[1])
next_season_table <- read_html(fox_link) %>% html_nodes(".wisbb_standardTable") %>% html_table() %>% as.data.frame(stringsAsFactors = FALSE)
next_season_table$season <- seasons[1]
next_season_table$Player <- name
season_table <- rbind(season_table, next_season_table)
}
else{
return(season_table)
}
return(season_table)
}
get_Browser_Session <- function(){
library(RSelenium)
rD <- rsDriver()
remDr <- rD[["client"]]
return(remDr)
}
get_NFL_Fumbles <- function(link, player) {
print(paste0("Getting NFL stats for: ", player, " at: ", link))
# remDriver <- get_Browser_Session()
# remDriver$navigate(link)
# page_source <-remDriver$getPageSource()
# defense <- read_xml(page_source[[1]]) %>% html_node(xpath='//*[@id="defense"]') %>% length()
defense <- read_html(link) %>% html_nodes(xpath = '//comment()') %>% html_text() %>% paste(collapse = '') %>% read_html() %>% html_node("#div_defense tfoot") %>% length()
if(defense > 0){
values <- read_html(link) %>% html_nodes(xpath = '//comment()') %>% html_text() %>% paste(collapse = '') %>% read_html() %>% html_node("#div_defense tfoot") %>% html_nodes(".right") %>% html_text() %>% .[1:17]
values <- c(values, player)
values <- data.frame(t(values), stringsAsFactors = FALSE)
column_names <- c('No', 'games', 'games_started', 'int', 'intyds', 'int_td', 'int_lng', 'intPD', 'FF', 'Fmb', 'FR', 'FmYds', 'TD', 'Sk', 'Tkl', 'Ast', 'Sfty','Player')
names(values) <- column_names
return(values)
values <- values %>% mutate_at(vars(Fmb:FmYds), as.numeric)
return(values)
}
else{
values <- data.frame()
}
return(values)
} | /qbScrape.R | no_license | kjhogan/Coursera | R | false | false | 3,814 | r |
get_QB_Names <- function(){
url <- paste0("https://www.pro-football-reference.com/play-index/draft-finder.cgi?request=1&year_min=1990&year_max=2017&draft_slot_min=1&draft_slot_max=500&pick_type=overall&pos%5B%5D=qb&conference=any&show=p&order_by=default")
linkbase <- read_html(url) %>% html_nodes("table tbody a") %>% html_attr('href')
linkname <- read_html(url) %>% html_nodes("table tbody a") %>% html_text()
link_logic <- linkbase %>% grepl("^/players/",.)
linkbase <- linkbase[link_logic]
linkname <- linkname[link_logic]
links <- paste0("https://pro-football-reference.com", linkbase)
data <- data.frame(linkname,links, stringsAsFactors = FALSE)
return(data)
}
get_NFL_Passing <- function(link, name) {
print(paste0("Getting NFL stats for: ", name, " at: ", link))
length <- read_html(link) %>% html_nodes("#passing") %>% length()
if(length == 1) {
passing_table <- read_html(link) %>% html_nodes("#passing") %>% html_table() %>% .[[1]] %>% as.data.frame()
if(length(names(passing_table)) > 30){
passing_table <- passing_table[,-23]
}
names(passing_table)[24] <- "Sk_Yds"
passing_table$Player <- name
passing_table <- passing_table %>% filter(Year == "Career")
passing_table <- passing_table %>% mutate_at(vars(No.:GS), as.numeric)
passing_table <- passing_table %>% mutate_at(vars(Cmp:AV), as.numeric)
}
else {
passing_table <- data.frame()
}
return(passing_table)
}
get_NCAA_fumbles <- function(name){
fox_link <- paste0("https://www.foxsports.com/college-football/", gsub(" ", "-",name), "-player-game-log")
seasons <- read_html(fox_link) %>% html_nodes("select") %>% html_text() %>% regmatches(.,gregexpr(".{4}",.)) %>% .[[1]]
season_table <- read_html("foxqb.html") %>% html_nodes(".wisbb_standardTable") %>% html_table() %>% as.data.frame(stringsAsFactors = FALSE)
season_table$season <- seasons[1]
season_table$Player <- name
if(length(seasons) > 1) {
seasons <- seasons[-1]
fox_link <- paste0(fox_link, "?season=", seasons[1])
next_season_table <- read_html(fox_link) %>% html_nodes(".wisbb_standardTable") %>% html_table() %>% as.data.frame(stringsAsFactors = FALSE)
next_season_table$season <- seasons[1]
next_season_table$Player <- name
season_table <- rbind(season_table, next_season_table)
}
else{
return(season_table)
}
return(season_table)
}
get_Browser_Session <- function(){
library(RSelenium)
rD <- rsDriver()
remDr <- rD[["client"]]
return(remDr)
}
get_NFL_Fumbles <- function(link, player) {
print(paste0("Getting NFL stats for: ", player, " at: ", link))
# remDriver <- get_Browser_Session()
# remDriver$navigate(link)
# page_source <-remDriver$getPageSource()
# defense <- read_xml(page_source[[1]]) %>% html_node(xpath='//*[@id="defense"]') %>% length()
defense <- read_html(link) %>% html_nodes(xpath = '//comment()') %>% html_text() %>% paste(collapse = '') %>% read_html() %>% html_node("#div_defense tfoot") %>% length()
if(defense > 0){
values <- read_html(link) %>% html_nodes(xpath = '//comment()') %>% html_text() %>% paste(collapse = '') %>% read_html() %>% html_node("#div_defense tfoot") %>% html_nodes(".right") %>% html_text() %>% .[1:17]
values <- c(values, player)
values <- data.frame(t(values), stringsAsFactors = FALSE)
column_names <- c('No', 'games', 'games_started', 'int', 'intyds', 'int_td', 'int_lng', 'intPD', 'FF', 'Fmb', 'FR', 'FmYds', 'TD', 'Sk', 'Tkl', 'Ast', 'Sfty','Player')
names(values) <- column_names
return(values)
values <- values %>% mutate_at(vars(Fmb:FmYds), as.numeric)
return(values)
}
else{
values <- data.frame()
}
return(values)
} |
# Do not modify this file by hand.
#
# It is automatically generated by src/api_wrappers/generateRAPIWrappers.py.
# (Run make api_wrappers to update it.)
##' analysisAddTags API wrapper
##'
##' This function makes an API call to the \code{/analysis-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-analysis-xxxx-addtags}
analysisAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' analysisDescribe API wrapper
##'
##' This function makes an API call to the \code{/analysis-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-analysis-xxxx-describe}
analysisDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' analysisRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/analysis-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-analysis-xxxx-removetags}
analysisRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' analysisSetProperties API wrapper
##'
##' This function makes an API call to the \code{/analysis-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-analysis-xxxx-setproperties}
analysisSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' analysisTerminate API wrapper
##'
##' This function makes an API call to the \code{/analysis-xxxx/terminate} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-analysis-xxxx-terminate}
analysisTerminate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'terminate', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appAddAuthorizedUsers API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/addAuthorizedUsers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-addauthorizedusers}
appAddAuthorizedUsers <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'addAuthorizedUsers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appAddCategories API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/addCategories} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-addcategories}
appAddCategories <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'addCategories', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appAddDevelopers API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/addDevelopers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-adddevelopers}
appAddDevelopers <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'addDevelopers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appAddTags API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-addtags}
appAddTags <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appDelete API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/delete} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-delete}
appDelete <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'delete', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appDescribe API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-describe}
appDescribe <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appGet API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/get} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-get}
appGet <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'get', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appInstall API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/install} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-install}
appInstall <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'install', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appListAuthorizedUsers API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/listAuthorizedUsers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-listauthorizedusers}
appListAuthorizedUsers <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'listAuthorizedUsers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appListCategories API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/listCategories} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-listcategories}
appListCategories <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'listCategories', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appListDevelopers API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/listDevelopers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-listdevelopers}
appListDevelopers <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'listDevelopers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appPublish API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/publish} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-publish}
appPublish <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'publish', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appRemoveAuthorizedUsers API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/removeAuthorizedUsers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-removeauthorizedusers}
appRemoveAuthorizedUsers <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'removeAuthorizedUsers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appRemoveCategories API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/removeCategories} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-removecategories}
appRemoveCategories <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'removeCategories', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appRemoveDevelopers API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/removeDevelopers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-removedevelopers}
appRemoveDevelopers <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'removeDevelopers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-removetags}
appRemoveTags <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appRun API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/run} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-run}
appRun <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=FALSE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'run', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appValidateBatch API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/validateBatch} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-validatebatch}
appValidateBatch <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'validateBatch', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appUninstall API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/uninstall} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-uninstall}
appUninstall <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'uninstall', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appUpdate API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/update} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-update}
appUpdate <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'update', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appNew API wrapper
##'
##' This function makes an API call to the \code{/app/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-new}
appNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/app/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' appletAddTags API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-addtags}
appletAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletDescribe API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-applet-xxxx-describe}
appletDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletGet API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/get} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-applet-xxxx-get}
appletGet <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'get', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletGetDetails API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/getDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-getdetails}
appletGetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'getDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletListProjects API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/listProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/cloning#api-method-class-xxxx-listprojects}
appletListProjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listProjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-removetags}
appletRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletRename API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/rename} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/name#api-method-class-xxxx-rename}
appletRename <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'rename', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletValidateBatch API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/validateBatch} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-applet-xxxx-validatebatch}
appletValidateBatch <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'validateBatch', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletRun API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/run} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-applet-xxxx-run}
appletRun <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'run', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletSetProperties API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/properties#api-method-class-xxxx-setproperties}
appletSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletNew API wrapper
##'
##' This function makes an API call to the \code{/applet/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-applet-new}
appletNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/applet/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' containerClone API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/clone} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/cloning#api-method-class-xxxx-clone}
containerClone <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'clone', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerDescribe API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/containers-for-execution#api-method-container-xxxx-describe}
containerDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerDestroy API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/destroy} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
containerDestroy <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'destroy', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerListFolder API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/listFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-listfolder}
containerListFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerMove API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/move} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-move}
containerMove <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'move', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerNewFolder API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/newFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-newfolder}
containerNewFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'newFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerRemoveFolder API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/removeFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-removefolder}
containerRemoveFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'removeFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerRemoveObjects API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/removeObjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-removeobjects}
containerRemoveObjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'removeObjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerRenameFolder API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/renameFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-renamefolder}
containerRenameFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'renameFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseAddTags API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-addtags}
databaseAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseAddTypes API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/addTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-addtypes}
databaseAddTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseClose API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/close} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle#api-method-class-xxxx-close}
databaseClose <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'close', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseDescribe API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/databases#api-method-database-xxxx-describe}
databaseDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseGetDetails API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/getDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-getdetails}
databaseGetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'getDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseListProjects API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/listProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/cloning#api-method-class-xxxx-listprojects}
databaseListProjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listProjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseRelocate API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/relocate} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/databases#api-method-database-xxxx-relocate}
databaseRelocate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'relocate', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-removetags}
databaseRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseRemoveTypes API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/removeTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-removetypes}
databaseRemoveTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseRename API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/rename} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/name#api-method-class-xxxx-rename}
databaseRename <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'rename', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseSetDetails API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/setDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-setdetails}
databaseSetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseSetProperties API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/properties#api-method-class-xxxx-setproperties}
databaseSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseSetVisibility API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/setVisibility} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/visibility#api-method-class-xxxx-setvisibility}
databaseSetVisibility <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setVisibility', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseDownloadFile API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/downloadFile} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{}
databaseDownloadFile <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'downloadFile', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseListFolder API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/listFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-listfolder}
databaseListFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterAddTags API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-addtags}
dbclusterAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterAddTypes API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/addTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-addtypes}
dbclusterAddTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterDescribe API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/dbclusters#api-method-dbcluster-xxxx-describe}
dbclusterDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterGetDetails API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/getDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-getdetails}
dbclusterGetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'getDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterNew API wrapper
##'
##' This function makes an API call to the \code{/dbcluster/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/dbclusters#api-method-dbcluster-new}
dbclusterNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/dbcluster/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' dbclusterRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-removetags}
dbclusterRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterRemoveTypes API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/removeTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-removetypes}
dbclusterRemoveTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterRename API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/rename} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/name#api-method-class-xxxx-rename}
dbclusterRename <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'rename', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterSetDetails API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/setDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-setdetails}
dbclusterSetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterSetProperties API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/properties#api-method-class-xxxx-setproperties}
dbclusterSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterSetVisibility API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/setVisibility} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/visibility#api-method-class-xxxx-setvisibility}
dbclusterSetVisibility <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setVisibility', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterStart API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/start} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/dbclusters#api-method-dbcluster-xxxx-start}
dbclusterStart <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'start', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterStop API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/stop} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/dbclusters#api-method-dbcluster-xxxx-stop}
dbclusterStop <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'stop', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterTerminate API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/terminate} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/dbclusters#api-method-dbcluster-xxxx-terminate}
dbclusterTerminate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'terminate', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileAddTags API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-addtags}
fileAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileAddTypes API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/addTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-addtypes}
fileAddTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileClose API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/close} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/files#api-method-file-xxxx-close}
fileClose <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'close', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileDescribe API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/files#api-method-file-xxxx-describe}
fileDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileDownload API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/download} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/files#api-method-file-xxxx-download}
fileDownload <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'download', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileGetDetails API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/getDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-getdetails}
fileGetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'getDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileListProjects API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/listProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/cloning#api-method-class-xxxx-listprojects}
fileListProjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listProjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-removetags}
fileRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileRemoveTypes API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/removeTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-removetypes}
fileRemoveTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileRename API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/rename} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/name#api-method-class-xxxx-rename}
fileRename <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'rename', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileSetDetails API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/setDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-setdetails}
fileSetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileSetProperties API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/properties#api-method-class-xxxx-setproperties}
fileSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileSetVisibility API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/setVisibility} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/visibility#api-method-class-xxxx-setvisibility}
fileSetVisibility <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setVisibility', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileUpload API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/upload} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/files#api-method-file-xxxx-upload}
fileUpload <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'upload', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileNew API wrapper
##'
##' This function makes an API call to the \code{/file/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/files#api-method-file-new}
fileNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/file/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' globalWorkflowAddAuthorizedUsers API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/addAuthorizedUsers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-addauthorizedusers}
globalWorkflowAddAuthorizedUsers <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addAuthorizedUsers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowAddCategories API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/addCategories} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-addcategories}
globalWorkflowAddCategories <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addCategories', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowAddDevelopers API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/addDevelopers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-adddevelopers}
globalWorkflowAddDevelopers <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addDevelopers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowAddTags API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-addtags}
globalWorkflowAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowDelete API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/delete} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-delete}
globalWorkflowDelete <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'delete', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowDescribe API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-describe}
globalWorkflowDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowListAuthorizedUsers API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/listAuthorizedUsers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-listauthorizedusers}
globalWorkflowListAuthorizedUsers <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listAuthorizedUsers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowListCategories API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/listCategories} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-listcategories}
globalWorkflowListCategories <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listCategories', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowListDevelopers API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/listDevelopers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-listdevelopers}
globalWorkflowListDevelopers <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listDevelopers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowPublish API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/publish} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-publish}
globalWorkflowPublish <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'publish', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowRemoveAuthorizedUsers API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/removeAuthorizedUsers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-removeauthorizedusers}
globalWorkflowRemoveAuthorizedUsers <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeAuthorizedUsers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowRemoveCategories API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/removeCategories} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-removecategories}
globalWorkflowRemoveCategories <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeCategories', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowRemoveDevelopers API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/removeDevelopers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-removedevelopers}
globalWorkflowRemoveDevelopers <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeDevelopers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-removetags}
globalWorkflowRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowRun API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/run} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-run}
globalWorkflowRun <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'run', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowUpdate API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/update} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-update}
globalWorkflowUpdate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'update', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowNew API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-new}
globalWorkflowNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/globalworkflow/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' jobAddTags API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-addtags}
jobAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' jobDescribe API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-describe}
jobDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' jobGetLog API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/getLog} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-getlog}
jobGetLog <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'getLog', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' jobRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-removetags}
jobRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' jobSetProperties API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-setproperties}
jobSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' jobTerminate API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/terminate} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-terminate}
jobTerminate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'terminate', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' jobUpdate API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/update} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-update}
jobUpdate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'update', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' jobNew API wrapper
##'
##' This function makes an API call to the \code{/job/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-new}
jobNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/job/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' notificationsGet API wrapper
##'
##' This function makes an API call to the \code{/notifications/get} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
notificationsGet <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/notifications/get', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' notificationsMarkRead API wrapper
##'
##' This function makes an API call to the \code{/notifications/markRead} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
notificationsMarkRead <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/notifications/markRead', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' orgDescribe API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-describe}
orgDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgFindMembers API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/findMembers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-findmembers}
orgFindMembers <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'findMembers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgFindProjects API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/findProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-findprojects}
orgFindProjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'findProjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgFindApps API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/findApps} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-findapps}
orgFindApps <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'findApps', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgInvite API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/invite} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-invite}
orgInvite <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'invite', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgRemoveMember API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/removeMember} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-removemember}
orgRemoveMember <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeMember', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgSetMemberAccess API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/setMemberAccess} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-setmemberaccess}
orgSetMemberAccess <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setMemberAccess', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgUpdate API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/update} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-update}
orgUpdate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'update', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgNew API wrapper
##'
##' This function makes an API call to the \code{/org/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-new}
orgNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/org/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' projectAddTags API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-addtags}
projectAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectArchive API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/archive} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-archive}
projectArchive <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'archive', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectUnarchive API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/unarchive} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-unarchive}
projectUnarchive <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'unarchive', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectClone API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/clone} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/cloning#api-method-class-xxxx-clone}
projectClone <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'clone', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectDecreasePermissions API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/decreasePermissions} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/project-permissions-and-sharing#api-method-project-xxxx-decreasepermissions}
projectDecreasePermissions <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'decreasePermissions', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectDescribe API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-describe}
projectDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectDestroy API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/destroy} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-destroy}
projectDestroy <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'destroy', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectInvite API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/invite} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/project-permissions-and-sharing#api-method-project-xxxx-invite}
projectInvite <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'invite', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectLeave API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/leave} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/project-permissions-and-sharing#api-method-project-xxxx-leave}
projectLeave <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'leave', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectListFolder API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/listFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-listfolder}
projectListFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectMove API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/move} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-move}
projectMove <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'move', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectNewFolder API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/newFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-newfolder}
projectNewFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'newFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectRemoveFolder API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/removeFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-removefolder}
projectRemoveFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'removeFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectRemoveObjects API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/removeObjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-removeobjects}
projectRemoveObjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'removeObjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-removetags}
projectRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectRenameFolder API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/renameFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-renamefolder}
projectRenameFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'renameFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectSetProperties API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-setproperties}
projectSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectTransfer API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/transfer} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/project-permissions-and-sharing#api-method-project-xxxx-transfer}
projectTransfer <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'transfer', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectUpdate API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/update} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-update}
projectUpdate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'update', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectUpdateSponsorship API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/updateSponsorship} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-updatesponsorship}
projectUpdateSponsorship <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'updateSponsorship', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectNew API wrapper
##'
##' This function makes an API call to the \code{/project/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-new}
projectNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/project/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' recordAddTags API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-addtags}
recordAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordAddTypes API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/addTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-addtypes}
recordAddTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordClose API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/close} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle#api-method-class-xxxx-close}
recordClose <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'close', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordDescribe API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/records#api-method-record-xxxx-describe}
recordDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordGetDetails API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/getDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-getdetails}
recordGetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'getDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordListProjects API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/listProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/cloning#api-method-class-xxxx-listprojects}
recordListProjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listProjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-removetags}
recordRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordRemoveTypes API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/removeTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-removetypes}
recordRemoveTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordRename API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/rename} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/name#api-method-class-xxxx-rename}
recordRename <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'rename', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordSetDetails API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/setDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-setdetails}
recordSetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordSetProperties API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/properties#api-method-class-xxxx-setproperties}
recordSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordSetVisibility API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/setVisibility} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/visibility#api-method-class-xxxx-setvisibility}
recordSetVisibility <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setVisibility', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordNew API wrapper
##'
##' This function makes an API call to the \code{/record/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/records#api-method-record-new}
recordNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/record/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemDescribeDataObjects API wrapper
##'
##' This function makes an API call to the \code{/system/describeDataObjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/system-methods#api-method-system-describedataobjects}
systemDescribeDataObjects <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/describeDataObjects', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemDescribeExecutions API wrapper
##'
##' This function makes an API call to the \code{/system/describeExecutions} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/system-methods#api-method-system-describeexecutions}
systemDescribeExecutions <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/describeExecutions', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemDescribeProjects API wrapper
##'
##' This function makes an API call to the \code{/system/describeProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/system-methods#api-method-system-describeprojects}
systemDescribeProjects <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/describeProjects', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindAffiliates API wrapper
##'
##' This function makes an API call to the \code{/system/findAffiliates} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
systemFindAffiliates <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findAffiliates', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindApps API wrapper
##'
##' This function makes an API call to the \code{/system/findApps} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-findapps}
systemFindApps <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findApps', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindDataObjects API wrapper
##'
##' This function makes an API call to the \code{/system/findDataObjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-finddataobjects}
systemFindDataObjects <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findDataObjects', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindGlobalWorkflows API wrapper
##'
##' This function makes an API call to the \code{/system/findGlobalWorkflows} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
systemFindGlobalWorkflows <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findGlobalWorkflows', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemResolveDataObjects API wrapper
##'
##' This function makes an API call to the \code{/system/resolveDataObjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/system-methods#api-method-system-resolvedataobjects}
systemResolveDataObjects <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/resolveDataObjects', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindExecutions API wrapper
##'
##' This function makes an API call to the \code{/system/findExecutions} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-findexecutions}
systemFindExecutions <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findExecutions', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindAnalyses API wrapper
##'
##' This function makes an API call to the \code{/system/findAnalyses} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-findanalyses}
systemFindAnalyses <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findAnalyses', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindDatabases API wrapper
##'
##' This function makes an API call to the \code{/system/findDatabases} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-finddatabases}
systemFindDatabases <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findDatabases', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindJobs API wrapper
##'
##' This function makes an API call to the \code{/system/findJobs} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-findjobs}
systemFindJobs <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findJobs', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindProjects API wrapper
##'
##' This function makes an API call to the \code{/system/findProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-findprojects}
systemFindProjects <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findProjects', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindUsers API wrapper
##'
##' This function makes an API call to the \code{/system/findUsers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
systemFindUsers <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findUsers', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindProjectMembers API wrapper
##'
##' This function makes an API call to the \code{/system/findProjectMembers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-findprojectmembers}
systemFindProjectMembers <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findProjectMembers', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindOrgs API wrapper
##'
##' This function makes an API call to the \code{/system/findOrgs} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-findorgs}
systemFindOrgs <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findOrgs', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemGenerateBatchInputs API wrapper
##'
##' This function makes an API call to the \code{/system/generateBatchInputs} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/system-methods#api-method-system-generatebatchinputs}
systemGenerateBatchInputs <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/generateBatchInputs', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemGlobalSearch API wrapper
##'
##' This function makes an API call to the \code{/system/globalSearch} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
systemGlobalSearch <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/globalSearch', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemGreet API wrapper
##'
##' This function makes an API call to the \code{/system/greet} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
systemGreet <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/greet', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemHeaders API wrapper
##'
##' This function makes an API call to the \code{/system/headers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
systemHeaders <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/headers', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemShortenURL API wrapper
##'
##' This function makes an API call to the \code{/system/shortenURL} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
systemShortenURL <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/shortenURL', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemWhoami API wrapper
##'
##' This function makes an API call to the \code{/system/whoami} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/system-methods#api-method-system-whoamiwiki.}
systemWhoami <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/whoami', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' userDescribe API wrapper
##'
##' This function makes an API call to the \code{/user-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/users#api-method-user-xxxx-describe}
userDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' userUpdate API wrapper
##'
##' This function makes an API call to the \code{/user-xxxx/update} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/users#api-method-user-xxxx-update}
userUpdate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'update', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowAddStage API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/addStage} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-addstage}
workflowAddStage <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addStage', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowAddTags API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-addtags}
workflowAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowAddTypes API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/addTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-addtypes}
workflowAddTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowClose API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/close} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle#api-method-class-xxxx-close}
workflowClose <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'close', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowDescribe API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-describe}
workflowDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowDryRun API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/dryRun} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-dryrun}
workflowDryRun <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'dryRun', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowGetDetails API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/getDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-getdetails}
workflowGetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'getDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowIsStageCompatible API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/isStageCompatible} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-isstagecompatible}
workflowIsStageCompatible <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'isStageCompatible', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowListProjects API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/listProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/cloning#api-method-class-xxxx-listprojects}
workflowListProjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listProjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowMoveStage API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/moveStage} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-movestage}
workflowMoveStage <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'moveStage', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowOverwrite API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/overwrite} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-overwrite}
workflowOverwrite <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'overwrite', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowRemoveStage API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/removeStage} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-removestage}
workflowRemoveStage <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeStage', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-removetags}
workflowRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowRemoveTypes API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/removeTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-removetypes}
workflowRemoveTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowRename API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/rename} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/name#api-method-class-xxxx-rename}
workflowRename <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'rename', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowRun API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/run} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-run}
workflowRun <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'run', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowValidateBatch API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/validateBatch} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-validatebatch}
workflowValidateBatch <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'validateBatch', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowSetDetails API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/setDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-setdetails}
workflowSetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowSetProperties API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/properties#api-method-class-xxxx-setproperties}
workflowSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowSetVisibility API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/setVisibility} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/visibility#api-method-class-xxxx-setvisibility}
workflowSetVisibility <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setVisibility', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowUpdate API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/update} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-update}
workflowUpdate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'update', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowUpdateStageExecutable API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/updateStageExecutable} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-updatestageexecutable}
workflowUpdateStageExecutable <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'updateStageExecutable', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowNew API wrapper
##'
##' This function makes an API call to the \code{/workflow/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-new}
workflowNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/workflow/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
| /src/R/dxR/R/api.R | permissive | dnanexus/dx-toolkit | R | false | false | 331,785 | r | # Do not modify this file by hand.
#
# It is automatically generated by src/api_wrappers/generateRAPIWrappers.py.
# (Run make api_wrappers to update it.)
##' analysisAddTags API wrapper
##'
##' This function makes an API call to the \code{/analysis-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-analysis-xxxx-addtags}
analysisAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' analysisDescribe API wrapper
##'
##' This function makes an API call to the \code{/analysis-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-analysis-xxxx-describe}
analysisDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' analysisRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/analysis-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-analysis-xxxx-removetags}
analysisRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' analysisSetProperties API wrapper
##'
##' This function makes an API call to the \code{/analysis-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-analysis-xxxx-setproperties}
analysisSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' analysisTerminate API wrapper
##'
##' This function makes an API call to the \code{/analysis-xxxx/terminate} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-analysis-xxxx-terminate}
analysisTerminate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'terminate', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appAddAuthorizedUsers API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/addAuthorizedUsers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-addauthorizedusers}
appAddAuthorizedUsers <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'addAuthorizedUsers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appAddCategories API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/addCategories} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-addcategories}
appAddCategories <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'addCategories', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appAddDevelopers API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/addDevelopers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-adddevelopers}
appAddDevelopers <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'addDevelopers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appAddTags API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-addtags}
appAddTags <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appDelete API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/delete} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-delete}
appDelete <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'delete', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appDescribe API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-describe}
appDescribe <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appGet API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/get} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-get}
appGet <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'get', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appInstall API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/install} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-install}
appInstall <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'install', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appListAuthorizedUsers API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/listAuthorizedUsers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-listauthorizedusers}
appListAuthorizedUsers <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'listAuthorizedUsers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appListCategories API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/listCategories} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-listcategories}
appListCategories <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'listCategories', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appListDevelopers API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/listDevelopers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-listdevelopers}
appListDevelopers <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'listDevelopers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appPublish API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/publish} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-publish}
appPublish <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'publish', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appRemoveAuthorizedUsers API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/removeAuthorizedUsers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-removeauthorizedusers}
appRemoveAuthorizedUsers <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'removeAuthorizedUsers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appRemoveCategories API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/removeCategories} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-removecategories}
appRemoveCategories <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'removeCategories', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appRemoveDevelopers API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/removeDevelopers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-removedevelopers}
appRemoveDevelopers <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'removeDevelopers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-removetags}
appRemoveTags <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appRun API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/run} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-run}
appRun <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=FALSE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'run', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appValidateBatch API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/validateBatch} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-validatebatch}
appValidateBatch <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'validateBatch', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appUninstall API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/uninstall} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-uninstall}
appUninstall <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'uninstall', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appUpdate API wrapper
##'
##' This function makes an API call to the \code{/app-xxxx/update} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param appNameOrID An app identifier using either the name of an app
##' ("app-name") or its full ID ("app-xxxx")
##' @param alias If an app name is given for \code{appNameOrID}, this can be
##' provided to specify a version or tag (if not provided, the "default" tag is
##' used).
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-xxxx-yyyy-update}
appUpdate <- function(appNameOrID, alias=NULL,
inputParams=emptyNamedList, jsonifyData=TRUE,
alwaysRetry=TRUE) {
if (is.null(alias)) {
fullyQualifiedVersion <- paste('/', appNameOrID, sep='')
} else {
fullyQualifiedVersion <- paste('/', appNameOrID, '/', alias, sep='')
}
resource <- paste(fullyQualifiedVersion, '/', 'update', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appNew API wrapper
##'
##' This function makes an API call to the \code{/app/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/apps#api-method-app-new}
appNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/app/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' appletAddTags API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-addtags}
appletAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletDescribe API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-applet-xxxx-describe}
appletDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletGet API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/get} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-applet-xxxx-get}
appletGet <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'get', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletGetDetails API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/getDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-getdetails}
appletGetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'getDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletListProjects API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/listProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/cloning#api-method-class-xxxx-listprojects}
appletListProjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listProjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-removetags}
appletRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletRename API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/rename} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/name#api-method-class-xxxx-rename}
appletRename <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'rename', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletValidateBatch API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/validateBatch} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-applet-xxxx-validatebatch}
appletValidateBatch <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'validateBatch', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletRun API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/run} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-applet-xxxx-run}
appletRun <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'run', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletSetProperties API wrapper
##'
##' This function makes an API call to the \code{/applet-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/properties#api-method-class-xxxx-setproperties}
appletSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' appletNew API wrapper
##'
##' This function makes an API call to the \code{/applet/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-applet-new}
appletNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/applet/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' containerClone API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/clone} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/cloning#api-method-class-xxxx-clone}
containerClone <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'clone', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerDescribe API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/containers-for-execution#api-method-container-xxxx-describe}
containerDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerDestroy API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/destroy} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
containerDestroy <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'destroy', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerListFolder API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/listFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-listfolder}
containerListFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerMove API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/move} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-move}
containerMove <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'move', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerNewFolder API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/newFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-newfolder}
containerNewFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'newFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerRemoveFolder API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/removeFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-removefolder}
containerRemoveFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'removeFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerRemoveObjects API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/removeObjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-removeobjects}
containerRemoveObjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'removeObjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' containerRenameFolder API wrapper
##'
##' This function makes an API call to the \code{/container-xxxx/renameFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-renamefolder}
containerRenameFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'renameFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseAddTags API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-addtags}
databaseAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseAddTypes API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/addTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-addtypes}
databaseAddTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseClose API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/close} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle#api-method-class-xxxx-close}
databaseClose <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'close', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseDescribe API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/databases#api-method-database-xxxx-describe}
databaseDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseGetDetails API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/getDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-getdetails}
databaseGetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'getDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseListProjects API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/listProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/cloning#api-method-class-xxxx-listprojects}
databaseListProjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listProjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseRelocate API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/relocate} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/databases#api-method-database-xxxx-relocate}
databaseRelocate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'relocate', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-removetags}
databaseRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseRemoveTypes API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/removeTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-removetypes}
databaseRemoveTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseRename API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/rename} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/name#api-method-class-xxxx-rename}
databaseRename <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'rename', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseSetDetails API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/setDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-setdetails}
databaseSetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseSetProperties API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/properties#api-method-class-xxxx-setproperties}
databaseSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseSetVisibility API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/setVisibility} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/visibility#api-method-class-xxxx-setvisibility}
databaseSetVisibility <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setVisibility', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseDownloadFile API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/downloadFile} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{}
databaseDownloadFile <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'downloadFile', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' databaseListFolder API wrapper
##'
##' This function makes an API call to the \code{/database-xxxx/listFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-listfolder}
databaseListFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterAddTags API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-addtags}
dbclusterAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterAddTypes API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/addTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-addtypes}
dbclusterAddTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterDescribe API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/dbclusters#api-method-dbcluster-xxxx-describe}
dbclusterDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterGetDetails API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/getDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-getdetails}
dbclusterGetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'getDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterNew API wrapper
##'
##' This function makes an API call to the \code{/dbcluster/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/dbclusters#api-method-dbcluster-new}
dbclusterNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/dbcluster/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' dbclusterRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-removetags}
dbclusterRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterRemoveTypes API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/removeTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-removetypes}
dbclusterRemoveTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterRename API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/rename} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/name#api-method-class-xxxx-rename}
dbclusterRename <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'rename', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterSetDetails API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/setDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-setdetails}
dbclusterSetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterSetProperties API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/properties#api-method-class-xxxx-setproperties}
dbclusterSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterSetVisibility API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/setVisibility} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/visibility#api-method-class-xxxx-setvisibility}
dbclusterSetVisibility <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setVisibility', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterStart API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/start} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/dbclusters#api-method-dbcluster-xxxx-start}
dbclusterStart <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'start', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterStop API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/stop} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/dbclusters#api-method-dbcluster-xxxx-stop}
dbclusterStop <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'stop', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' dbclusterTerminate API wrapper
##'
##' This function makes an API call to the \code{/dbcluster-xxxx/terminate} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/dbclusters#api-method-dbcluster-xxxx-terminate}
dbclusterTerminate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'terminate', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileAddTags API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-addtags}
fileAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileAddTypes API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/addTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-addtypes}
fileAddTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileClose API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/close} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/files#api-method-file-xxxx-close}
fileClose <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'close', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileDescribe API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/files#api-method-file-xxxx-describe}
fileDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileDownload API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/download} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/files#api-method-file-xxxx-download}
fileDownload <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'download', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileGetDetails API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/getDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-getdetails}
fileGetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'getDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileListProjects API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/listProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/cloning#api-method-class-xxxx-listprojects}
fileListProjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listProjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-removetags}
fileRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileRemoveTypes API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/removeTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-removetypes}
fileRemoveTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileRename API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/rename} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/name#api-method-class-xxxx-rename}
fileRename <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'rename', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileSetDetails API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/setDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-setdetails}
fileSetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileSetProperties API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/properties#api-method-class-xxxx-setproperties}
fileSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileSetVisibility API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/setVisibility} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/visibility#api-method-class-xxxx-setvisibility}
fileSetVisibility <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setVisibility', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileUpload API wrapper
##'
##' This function makes an API call to the \code{/file-xxxx/upload} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/files#api-method-file-xxxx-upload}
fileUpload <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'upload', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' fileNew API wrapper
##'
##' This function makes an API call to the \code{/file/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/files#api-method-file-new}
fileNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/file/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' globalWorkflowAddAuthorizedUsers API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/addAuthorizedUsers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-addauthorizedusers}
globalWorkflowAddAuthorizedUsers <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addAuthorizedUsers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowAddCategories API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/addCategories} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-addcategories}
globalWorkflowAddCategories <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addCategories', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowAddDevelopers API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/addDevelopers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-adddevelopers}
globalWorkflowAddDevelopers <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addDevelopers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowAddTags API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-addtags}
globalWorkflowAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowDelete API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/delete} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-delete}
globalWorkflowDelete <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'delete', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowDescribe API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-describe}
globalWorkflowDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowListAuthorizedUsers API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/listAuthorizedUsers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-listauthorizedusers}
globalWorkflowListAuthorizedUsers <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listAuthorizedUsers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowListCategories API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/listCategories} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-listcategories}
globalWorkflowListCategories <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listCategories', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowListDevelopers API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/listDevelopers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-listdevelopers}
globalWorkflowListDevelopers <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listDevelopers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowPublish API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/publish} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-publish}
globalWorkflowPublish <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'publish', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowRemoveAuthorizedUsers API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/removeAuthorizedUsers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-removeauthorizedusers}
globalWorkflowRemoveAuthorizedUsers <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeAuthorizedUsers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowRemoveCategories API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/removeCategories} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-removecategories}
globalWorkflowRemoveCategories <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeCategories', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowRemoveDevelopers API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/removeDevelopers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-removedevelopers}
globalWorkflowRemoveDevelopers <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeDevelopers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-removetags}
globalWorkflowRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowRun API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/run} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-run}
globalWorkflowRun <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'run', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowUpdate API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow-xxxx/update} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-xxxx-yyyy-update}
globalWorkflowUpdate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'update', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' globalWorkflowNew API wrapper
##'
##' This function makes an API call to the \code{/globalworkflow/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/global-workflows#api-method-globalworkflow-new}
globalWorkflowNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/globalworkflow/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' jobAddTags API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-addtags}
jobAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' jobDescribe API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-describe}
jobDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' jobGetLog API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/getLog} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-getlog}
jobGetLog <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'getLog', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' jobRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-removetags}
jobRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' jobSetProperties API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-setproperties}
jobSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' jobTerminate API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/terminate} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-terminate}
jobTerminate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'terminate', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' jobUpdate API wrapper
##'
##' This function makes an API call to the \code{/job-xxxx/update} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-xxxx-update}
jobUpdate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'update', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' jobNew API wrapper
##'
##' This function makes an API call to the \code{/job/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/applets-and-entry-points#api-method-job-new}
jobNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/job/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' notificationsGet API wrapper
##'
##' This function makes an API call to the \code{/notifications/get} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
notificationsGet <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/notifications/get', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' notificationsMarkRead API wrapper
##'
##' This function makes an API call to the \code{/notifications/markRead} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
notificationsMarkRead <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/notifications/markRead', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' orgDescribe API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-describe}
orgDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgFindMembers API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/findMembers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-findmembers}
orgFindMembers <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'findMembers', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgFindProjects API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/findProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-findprojects}
orgFindProjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'findProjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgFindApps API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/findApps} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-findapps}
orgFindApps <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'findApps', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgInvite API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/invite} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-invite}
orgInvite <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'invite', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgRemoveMember API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/removeMember} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-removemember}
orgRemoveMember <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeMember', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgSetMemberAccess API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/setMemberAccess} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-setmemberaccess}
orgSetMemberAccess <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setMemberAccess', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgUpdate API wrapper
##'
##' This function makes an API call to the \code{/org-xxxx/update} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-xxxx-update}
orgUpdate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'update', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' orgNew API wrapper
##'
##' This function makes an API call to the \code{/org/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/organizations#api-method-org-new}
orgNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/org/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' projectAddTags API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-addtags}
projectAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectArchive API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/archive} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-archive}
projectArchive <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'archive', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectUnarchive API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/unarchive} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-unarchive}
projectUnarchive <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'unarchive', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectClone API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/clone} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/cloning#api-method-class-xxxx-clone}
projectClone <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'clone', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectDecreasePermissions API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/decreasePermissions} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/project-permissions-and-sharing#api-method-project-xxxx-decreasepermissions}
projectDecreasePermissions <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'decreasePermissions', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectDescribe API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-describe}
projectDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectDestroy API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/destroy} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-destroy}
projectDestroy <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'destroy', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectInvite API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/invite} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/project-permissions-and-sharing#api-method-project-xxxx-invite}
projectInvite <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'invite', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectLeave API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/leave} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/project-permissions-and-sharing#api-method-project-xxxx-leave}
projectLeave <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'leave', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectListFolder API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/listFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-listfolder}
projectListFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectMove API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/move} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-move}
projectMove <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'move', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectNewFolder API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/newFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-newfolder}
projectNewFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'newFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectRemoveFolder API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/removeFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-removefolder}
projectRemoveFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'removeFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectRemoveObjects API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/removeObjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-removeobjects}
projectRemoveObjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'removeObjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-removetags}
projectRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectRenameFolder API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/renameFolder} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/folders-and-deletion#api-method-class-xxxx-renamefolder}
projectRenameFolder <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'renameFolder', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectSetProperties API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-setproperties}
projectSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectTransfer API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/transfer} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/project-permissions-and-sharing#api-method-project-xxxx-transfer}
projectTransfer <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'transfer', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectUpdate API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/update} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-update}
projectUpdate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'update', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectUpdateSponsorship API wrapper
##'
##' This function makes an API call to the \code{/project-xxxx/updateSponsorship} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-updatesponsorship}
projectUpdateSponsorship <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'updateSponsorship', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' projectNew API wrapper
##'
##' This function makes an API call to the \code{/project/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-new}
projectNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/project/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' recordAddTags API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-addtags}
recordAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordAddTypes API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/addTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-addtypes}
recordAddTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordClose API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/close} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle#api-method-class-xxxx-close}
recordClose <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'close', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordDescribe API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/records#api-method-record-xxxx-describe}
recordDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordGetDetails API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/getDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-getdetails}
recordGetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'getDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordListProjects API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/listProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/cloning#api-method-class-xxxx-listprojects}
recordListProjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listProjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-removetags}
recordRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordRemoveTypes API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/removeTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-removetypes}
recordRemoveTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordRename API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/rename} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/name#api-method-class-xxxx-rename}
recordRename <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'rename', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordSetDetails API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/setDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-setdetails}
recordSetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordSetProperties API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/properties#api-method-class-xxxx-setproperties}
recordSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordSetVisibility API wrapper
##'
##' This function makes an API call to the \code{/record-xxxx/setVisibility} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/visibility#api-method-class-xxxx-setvisibility}
recordSetVisibility <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setVisibility', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' recordNew API wrapper
##'
##' This function makes an API call to the \code{/record/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-classes/records#api-method-record-new}
recordNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/record/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemDescribeDataObjects API wrapper
##'
##' This function makes an API call to the \code{/system/describeDataObjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/system-methods#api-method-system-describedataobjects}
systemDescribeDataObjects <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/describeDataObjects', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemDescribeExecutions API wrapper
##'
##' This function makes an API call to the \code{/system/describeExecutions} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/system-methods#api-method-system-describeexecutions}
systemDescribeExecutions <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/describeExecutions', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemDescribeProjects API wrapper
##'
##' This function makes an API call to the \code{/system/describeProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/system-methods#api-method-system-describeprojects}
systemDescribeProjects <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/describeProjects', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindAffiliates API wrapper
##'
##' This function makes an API call to the \code{/system/findAffiliates} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
systemFindAffiliates <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findAffiliates', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindApps API wrapper
##'
##' This function makes an API call to the \code{/system/findApps} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-findapps}
systemFindApps <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findApps', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindDataObjects API wrapper
##'
##' This function makes an API call to the \code{/system/findDataObjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-finddataobjects}
systemFindDataObjects <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findDataObjects', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindGlobalWorkflows API wrapper
##'
##' This function makes an API call to the \code{/system/findGlobalWorkflows} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
systemFindGlobalWorkflows <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findGlobalWorkflows', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemResolveDataObjects API wrapper
##'
##' This function makes an API call to the \code{/system/resolveDataObjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/system-methods#api-method-system-resolvedataobjects}
systemResolveDataObjects <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/resolveDataObjects', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindExecutions API wrapper
##'
##' This function makes an API call to the \code{/system/findExecutions} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-findexecutions}
systemFindExecutions <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findExecutions', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindAnalyses API wrapper
##'
##' This function makes an API call to the \code{/system/findAnalyses} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-findanalyses}
systemFindAnalyses <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findAnalyses', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindDatabases API wrapper
##'
##' This function makes an API call to the \code{/system/findDatabases} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-finddatabases}
systemFindDatabases <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findDatabases', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindJobs API wrapper
##'
##' This function makes an API call to the \code{/system/findJobs} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-findjobs}
systemFindJobs <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findJobs', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindProjects API wrapper
##'
##' This function makes an API call to the \code{/system/findProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-findprojects}
systemFindProjects <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findProjects', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindUsers API wrapper
##'
##' This function makes an API call to the \code{/system/findUsers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
systemFindUsers <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findUsers', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindProjectMembers API wrapper
##'
##' This function makes an API call to the \code{/system/findProjectMembers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-findprojectmembers}
systemFindProjectMembers <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findProjectMembers', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemFindOrgs API wrapper
##'
##' This function makes an API call to the \code{/system/findOrgs} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/search#api-method-system-findorgs}
systemFindOrgs <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/findOrgs', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemGenerateBatchInputs API wrapper
##'
##' This function makes an API call to the \code{/system/generateBatchInputs} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/system-methods#api-method-system-generatebatchinputs}
systemGenerateBatchInputs <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/generateBatchInputs', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemGlobalSearch API wrapper
##'
##' This function makes an API call to the \code{/system/globalSearch} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
systemGlobalSearch <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/globalSearch', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemGreet API wrapper
##'
##' This function makes an API call to the \code{/system/greet} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
systemGreet <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/greet', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemHeaders API wrapper
##'
##' This function makes an API call to the \code{/system/headers} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
systemHeaders <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/headers', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemShortenURL API wrapper
##'
##' This function makes an API call to the \code{/system/shortenURL} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
systemShortenURL <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/shortenURL', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' systemWhoami API wrapper
##'
##' This function makes an API call to the \code{/system/whoami} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/system-methods#api-method-system-whoamiwiki.}
systemWhoami <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
dxHTTPRequest('/system/whoami', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
##' userDescribe API wrapper
##'
##' This function makes an API call to the \code{/user-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/users#api-method-user-xxxx-describe}
userDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' userUpdate API wrapper
##'
##' This function makes an API call to the \code{/user-xxxx/update} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/users#api-method-user-xxxx-update}
userUpdate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'update', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowAddStage API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/addStage} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-addstage}
workflowAddStage <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addStage', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowAddTags API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/addTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-addtags}
workflowAddTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowAddTypes API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/addTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-addtypes}
workflowAddTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'addTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowClose API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/close} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle#api-method-class-xxxx-close}
workflowClose <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'close', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowDescribe API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/describe} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-describe}
workflowDescribe <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'describe', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowDryRun API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/dryRun} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-dryrun}
workflowDryRun <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'dryRun', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowGetDetails API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/getDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-getdetails}
workflowGetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'getDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowIsStageCompatible API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/isStageCompatible} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-isstagecompatible}
workflowIsStageCompatible <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'isStageCompatible', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowListProjects API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/listProjects} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-containers/cloning#api-method-class-xxxx-listprojects}
workflowListProjects <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'listProjects', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowMoveStage API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/moveStage} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-movestage}
workflowMoveStage <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'moveStage', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowOverwrite API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/overwrite} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-overwrite}
workflowOverwrite <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'overwrite', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowRemoveStage API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/removeStage} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-removestage}
workflowRemoveStage <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeStage', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowRemoveTags API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/removeTags} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/tags#api-method-class-xxxx-removetags}
workflowRemoveTags <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTags', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowRemoveTypes API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/removeTypes} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types#api-method-class-xxxx-removetypes}
workflowRemoveTypes <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'removeTypes', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowRename API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/rename} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/name#api-method-class-xxxx-rename}
workflowRename <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'rename', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowRun API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/run} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-run}
workflowRun <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
resource <- paste('/', objectID, '/', 'run', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowValidateBatch API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/validateBatch} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-validatebatch}
workflowValidateBatch <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'validateBatch', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowSetDetails API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/setDetails} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links#api-method-class-xxxx-setdetails}
workflowSetDetails <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setDetails', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowSetProperties API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/setProperties} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata/properties#api-method-class-xxxx-setproperties}
workflowSetProperties <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setProperties', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowSetVisibility API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/setVisibility} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/data-object-lifecycle/visibility#api-method-class-xxxx-setvisibility}
workflowSetVisibility <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'setVisibility', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowUpdate API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/update} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-update}
workflowUpdate <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'update', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowUpdateStageExecutable API wrapper
##'
##' This function makes an API call to the \code{/workflow-xxxx/updateStageExecutable} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param objectID DNAnexus object ID
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-xxxx-updatestageexecutable}
workflowUpdateStageExecutable <- function(objectID,
inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=TRUE) {
resource <- paste('/', objectID, '/', 'updateStageExecutable', sep='')
dxHTTPRequest(resource,
inputParams,
jsonifyData=jsonifyData,
alwaysRetry=alwaysRetry)
}
##' workflowNew API wrapper
##'
##' This function makes an API call to the \code{/workflow/new} API
##' method; it is a simple wrapper around the \code{\link{dxHTTPRequest}}
##' function which makes POST HTTP requests to the API server.
##'
##'
##' @param inputParams Either an R object that will be converted into JSON
##' using \code{RJSONIO::toJSON} to be used as the input to the API call. If
##' providing the JSON string directly, you must set \code{jsonifyData} to
##' \code{FALSE}.
##' @param jsonifyData Whether to call \code{RJSONIO::toJSON} on
##' \code{inputParams} to create the JSON string or pass through the value of
##' \code{inputParams} directly. (Default is \code{TRUE}.)
##' @param alwaysRetry Whether to always retry even when no response is
##' received from the API server
##' @return If the API call is successful, the parsed JSON of the API server
##' response is returned (using \code{RJSONIO::fromJSON}).
##' @export
##' @seealso \code{\link{dxHTTPRequest}}
##' @references API spec documentation: \url{https://documentation.dnanexus.com/developer/api/running-analyses/workflows-and-analyses#api-method-workflow-new}
workflowNew <- function(inputParams=emptyNamedList,
jsonifyData=TRUE,
alwaysRetry=FALSE) {
dxHTTPRequest('/workflow/new', inputParams, jsonifyData=jsonifyData, alwaysRetry=alwaysRetry)
}
|
# Stormap | server.R
######################
library(shiny)
source('stormap-core.R')
shinyServer(function(input, output, session) {
# Input section
observe({
updateSelectInput(session = session,
inputId = 'period',
choices = periods$label)
})
observe({
updateSelectInput(session = session,
inputId = 'event.type',
choices = event.type.labels$label)
})
observe({
updateCheckboxGroupInput(session = session,
inputId = 'impact.types',
choices = impact.types,
selected = impact.types)
})
# Reactively update the subset of events the user is selecting
datasetInput <- reactive({
period <- select.period(ifelse(input$period == 'Loading...',
ALL,
input$period))
event.types <- select.event.types(
ifelse(input$event.type == 'Loading...',
ALL,
input$event.type))
impact.types <- input$impact.types
events <- events.subset(period, event.types, impact.types)
list(period = period,
event.types = event.types,
impact.types = impact.types,
events = events)
})
# Map section
output$map <- renderPlot({
events.plot(datasetInput())
})
output$top.fatalities <- renderTable({
top.fatalities.table(datasetInput()) },
include.rownames = FALSE,
align = c('c', 'l', 'l', 'r', 'l'))
# Table section
output$top.injuries <- renderTable({
top.injuries.table(datasetInput()) },
include.rownames = FALSE,
align = c('c', 'l', 'l', 'r', 'l'))
output$top.property.damages <- renderTable({
top.property.damages.table(datasetInput()) },
include.rownames = FALSE,
align = c('c', 'l', 'l', 'r', 'l'))
output$top.crop.damages <- renderTable({
top.crop.damages.table(datasetInput()) },
include.rownames = FALSE,
align = c('c', 'l', 'l', 'r', 'l'))
})
| /stormap-shiny/server.R | no_license | paspeur/Stormap | R | false | false | 1,735 | r | # Stormap | server.R
######################
library(shiny)
source('stormap-core.R')
shinyServer(function(input, output, session) {
# Input section
observe({
updateSelectInput(session = session,
inputId = 'period',
choices = periods$label)
})
observe({
updateSelectInput(session = session,
inputId = 'event.type',
choices = event.type.labels$label)
})
observe({
updateCheckboxGroupInput(session = session,
inputId = 'impact.types',
choices = impact.types,
selected = impact.types)
})
# Reactively update the subset of events the user is selecting
datasetInput <- reactive({
period <- select.period(ifelse(input$period == 'Loading...',
ALL,
input$period))
event.types <- select.event.types(
ifelse(input$event.type == 'Loading...',
ALL,
input$event.type))
impact.types <- input$impact.types
events <- events.subset(period, event.types, impact.types)
list(period = period,
event.types = event.types,
impact.types = impact.types,
events = events)
})
# Map section
output$map <- renderPlot({
events.plot(datasetInput())
})
output$top.fatalities <- renderTable({
top.fatalities.table(datasetInput()) },
include.rownames = FALSE,
align = c('c', 'l', 'l', 'r', 'l'))
# Table section
output$top.injuries <- renderTable({
top.injuries.table(datasetInput()) },
include.rownames = FALSE,
align = c('c', 'l', 'l', 'r', 'l'))
output$top.property.damages <- renderTable({
top.property.damages.table(datasetInput()) },
include.rownames = FALSE,
align = c('c', 'l', 'l', 'r', 'l'))
output$top.crop.damages <- renderTable({
top.crop.damages.table(datasetInput()) },
include.rownames = FALSE,
align = c('c', 'l', 'l', 'r', 'l'))
})
|
df <- data.frame(row.names = years)
#for(y in seq(121,150, by =10)){
int <- 9
stuff <- c(seq(121,150, by = 10), seq(201,260, by = 10))
for (y in stuff){
index <- seq(y, y+int)
day <- paste("day",y,sep="")
daymn <- paste("meanday",y,sep="")
df[[day]] <- extract_anoms(index) - mean(extract_anoms(index))
df[[daymn]] <- mean(extract_anoms(index))
} | /anoms2df.R | no_license | jedman/meiyu-jet-data | R | false | false | 347 | r | df <- data.frame(row.names = years)
#for(y in seq(121,150, by =10)){
int <- 9
stuff <- c(seq(121,150, by = 10), seq(201,260, by = 10))
for (y in stuff){
index <- seq(y, y+int)
day <- paste("day",y,sep="")
daymn <- paste("meanday",y,sep="")
df[[day]] <- extract_anoms(index) - mean(extract_anoms(index))
df[[daymn]] <- mean(extract_anoms(index))
} |
##############################
##############################
## US HUPO 2018 Short course - Section 7 : Protein siginificance analysis with MSstats
## Date: March 11, 2018
## Created by Meena Choi
##############################
##############################
##############################
## 0. Load MSstats
##############################
library(MSstats)
?MSstats
##############################
## 1. Read data
##############################
# set working directory
# read skyline output
raw <- read.csv(file="iPRG_10ppm_2rt_15cut_nosingle.csv")
# read annotation table
annot <- read.csv("iPRG_skyline_annotation.csv", header=TRUE)
annot
# reformating and pre-processing for Skyline output.
quant <- SkylinetoMSstatsFormat(raw, annotation=annot)
head(quant)
##############################
## 2. Processing data
## Transformation = log2
## Normalization = equalize median
## Model-based run-level summarization (TMP) after imputation
##############################
quant.processed <- dataProcess(raw = quant,
logTrans=2,
normalization = 'equalizeMedians',
summaryMethod = 'TMP',
MBimpute=TRUE,
censoredInt='0',
cutoffCensored='minFeature',
maxQuantileforCensored = 0.999)
# show the name of outputs
names(quant.processed)
# show reformated and normalized data.
# 'ABUNDANCE' column has normalized log2 transformed intensities.
head(quant.processed$ProcessedData)
# This table includes run-level summarized log2 intensities. (column : LogIntensities)
# Now one summarized log2 intensities per Protein and Run.
# NumMeasuredFeature : show how many features are used for run-level summarization.
# If there is no missing value, it should be the number of features in certain protein.
# MissingPercentage : the number of missing features / the number of features in certain protein.
head(quant.processed$RunlevelData)
# show which summarization method is used.
head(quant.processed$SummaryMethod)
##############################
## 3. Data visualization
##############################
dataProcessPlots(data = quant.processed,
type="QCplot",
width=7, height=7,
which.Protein = 'allonly',
address='iPRG_skyline_equalizeNorm_')
# It will generate profile plots per protein. It will take a while
# Please run at home. It takes a while.
dataProcessPlots(data = quant.processed,
type="Profileplot",
featureName="NA",
width=7, height=7,
summaryPlot = TRUE,
originalPlot = FALSE,
address="iPRG_skyline_equalizeNorm_")
# Instead, make profile plot for only some.
dataProcessPlots(data = quant.processed,
type="Profileplot",
featureName="NA",
width=7, height=7,
which.Protein = 'sp|P44015|VAC2_YEAST',
address="iPRG_skyline_equalizeNorm_P44015")
# sp|P55752|ISCB_YEAST
# sp|P44374|SFG2_YEAST
# sp|P44983|UTR6_YEAST
# sp|P44683|PGA4_YEAST
# sp|P55249|ZRT4_YEAST
# and first few proteins
# Please run at home. It takes a while.
dataProcessPlots(data = quant.processed,
type="conditionplot",
width=7, height=7,
address="iPRG_skyline_equalizeNorm_")
# Instead, make profile plot for only some.
# sp|P44015|VAC2_YEAST
# sp|P55752|ISCB_YEAST
# sp|P44374|SFG2_YEAST
# sp|P44983|UTR6_YEAST
# sp|P44683|PGA4_YEAST
# sp|P55249|ZRT4_YEAST
# and first few proteins
##############################
## 4. Model-based comparison and adjustment for multiple testing
##############################
unique(quant.processed$ProcessedData$GROUP_ORIGINAL)
comparison1<-matrix(c(-1,1,0,0),nrow=1)
comparison2<-matrix(c(-1,0,1,0),nrow=1)
comparison3<-matrix(c(-1,0,0,1),nrow=1)
comparison4<-matrix(c(0,-1,1,0),nrow=1)
comparison5<-matrix(c(0,-1,0,1),nrow=1)
comparison6<-matrix(c(0,0,-1,1),nrow=1)
comparison<-rbind(comparison1, comparison2, comparison3, comparison4, comparison5, comparison6)
row.names(comparison)<-c("C2-C1","C3-C1","C4-C1","C3-C2","C4-C2","C4-C3")
test <- groupComparison(contrast.matrix=comparison, data=quant.processed)
names(test)
# Show test result
# Label : which comparison is reported.
# log2FC : estimated log2 fold change between conditions.
# adj.pvalue : adjusted p value by BH
# issue : detect whether this protein has any issue for comparison
# such as, there is measurement in certain group, or no measurement at all.
# MissingPercentage : the number of missing intensities/total number of intensities
# in conditions your are interested in for comparison
# ImputationPercentage : the number of imputed intensities/total number of intensities
# in conditions your are interested in for comparison
head(test$ComparisonResult)
# After fitting linear model, residuals and fitted values can be shown.
head(test$ModelQC)
# Fitted model per protein
head(test$fittedmodel)
# save testing result as .csv file
Skyline.intensity.comparison.result <- test$ComparisonResult
write.csv(Skyline.intensity.comparison.result,
file='testResult.iprg.skyline.proteinlevel.csv')
head(Skyline.intensity.comparison.result)
SignificantProteins <- Skyline.intensity.comparison.result[Skyline.intensity.comparison.result$adj.pvalue < 0.05 ,]
nrow(SignificantProteins)
## practice : please find the result for spike-in protein
# sp|P44015|VAC2_YEAST
# sp|P55752|ISCB_YEAST
# sp|P44374|SFG2_YEAST
# sp|P44983|UTR6_YEAST
# sp|P44683|PGA4_YEAST
# sp|P55249|ZRT4_YEAST
##############################
## 5. Visualization for testing result
##############################
groupComparisonPlots(Skyline.intensity.comparison.result,
type="VolcanoPlot",
address="testResult_iprg_skyline_")
groupComparisonPlots(data = Skyline.intensity.comparison.result,
type = 'VolcanoPlot',
sig = 0.05,
FCcutoff = 2^2,
address = 'testResult_iprg_skyline_FCcutoff4_')
groupComparisonPlots(Skyline.intensity.comparison.result,
type="Heatmap",
address="testResult_iprg_skyline_")
# Please run at home. It takes a while.
groupComparisonPlots(Skyline.intensity.comparison.result,
type="ComparisonPlot",
address="testResult_iprg_skyline_")
##############################
## 6. Verify the model assumption
##############################
# normal quantile-quantile plots
# Please run at home. It takes a while.
modelBasedQCPlots(data=test, type="QQPlots",
width=5, height=5,
address="iPRG_skyline_equalizeNorm_testResult_")
# residual plots
# Please run at home. It takes a while.
modelBasedQCPlots(data=test, type="ResidualPlots",
width=5, height=5,
address="iPRG_skyline_equalizeNorm_testResult_")
##############################
## 7. Power calculation
##############################
test.power <- designSampleSize(data = test$fittedmodel,
desiredFC = c(1.1, 1.6),
FDR = 0.05,
power = TRUE,
numSample = 3)
test.power
designSampleSizePlots(data = test.power)
##############################
## 8. Sample size calculation
##############################
samplesize <- designSampleSize(data = test$fittedmodel,
desiredFC = c(1.1, 1.6),
FDR = 0.05,
power = 0.9,
numSample = TRUE)
samplesize
designSampleSizePlots(data = samplesize)
##############################
## 9. sample quantification
##############################
sampleQuant <- quantification(quant.processed)
head(sampleQuant)
##############################
##############################
## Extra practice
##############################
##############################
##############################
## quantile normalization
##############################
quant.processed.quantile <- dataProcess(raw = quant,
logTrans=2,
normalization = 'quantile',
summaryMethod = 'TMP',
MBimpute=TRUE,
censoredInt='0',
cutoffCensored='minFeature',
maxQuantileforCensored = 0.999)
dataProcessPlots(data = quant.processed.quantile,
type="QCplot",
width=7, height=7,
which.Protein = 1,
address='iPRG_skyline_quantile_')
dataProcessPlots(data = quant.processed.quantile,
type="Profileplot",
featureName="NA",
width=7, height=7,
which.Protein = 1,
address="iPRG_skyline_quantile_1_")
##############################
##############################
## Extra : peptide-level analysis
##############################
##############################
head(quant)
quant.pep <- quant
head(quant.pep)
##############################
## 1. Replace 'ProteinName' with combination of 'ProteinName' and 'PeptideSequence'
##############################
quant.pep$ProteinName <- paste(quant.pep$ProteinName,
quant.pep$PeptideSequence,
sep = '_')
length(unique(quant.pep$ProteinName)) # 30500 peptides
save(quant.pep, file='quant.pep.RData')
##############################
## 2. Process the data
##############################
# Please run at home. It takes a while.
quant.pep.processed <- dataProcess(raw = quant.pep,
logTrans=2,
normalization = 'equalizeMedians',
summaryMethod = 'TMP',
MBimpute=TRUE,
censoredInt='0',
cutoffCensored='minFeature',
maxQuantileforCensored = 0.999)
save(quant.pep.processed, file='quant.pep.processed.RData')
##############################
## 3. Data visualization
##############################
dataProcessPlots(data = quant.pep.processed, type="QCplot",
width=7, height=7,
which.Protein = 1,
address='iPRG_skyline_equalizeNorm_Peptidelevel_')
# Please run at home. It takes a while.
dataProcessPlots(data = quant.pep.processed, type="Profileplot",
featureName="NA",
width=7, height=7,
summaryPlot = FALSE,
address="iPRG_skyline_equalizeNorm_Peptidelevel_")
# Please run at home. It takes a while.
dataProcessPlots(data = quant.pep.processed, type="conditionplot",
address="iPRG_skyline_equalizeNorm_Peptidelevel_")
##############################
## 4. Model-based comparison and adjustment for multiple testing
##############################
unique(quant.pep.processed$ProcessedData$GROUP_ORIGINAL)
comparison1<-matrix(c(-1,1,0,0),nrow=1)
comparison2<-matrix(c(-1,0,1,0),nrow=1)
comparison3<-matrix(c(-1,0,0,1),nrow=1)
comparison4<-matrix(c(0,-1,1,0),nrow=1)
comparison5<-matrix(c(0,-1,0,1),nrow=1)
comparison6<-matrix(c(0,0,-1,1),nrow=1)
comparison<-rbind(comparison1, comparison2, comparison3, comparison4, comparison5, comparison6)
row.names(comparison)<-c("C2-C1","C3-C1","C4-C1","C3-C2","C4-C2","C4-C3")
# Please run at home. It takes a while.
test.Peptidelevel <- groupComparison(contrast.matrix=comparison,
data=quant.pep.processed)
testResult.iprg.skyline.Peptidelevel <- test.Peptidelevel$ComparisonResult
save(testResult.iprg.skyline.Peptidelevel, file='testResult.iprg.skyline.Peptidelevel.RData')
write.csv(testResult.iprg.skyline.Peptidelevel , file='testResult.iprg.skyline.Peptidelevel.csv')
head(testResult.iprg.skyline.Peptidelevel)
SignificantProteins <- testResult.iprg.skyline.Peptidelevel[testResult.iprg.skyline.Peptidelevel$adj.pvalue < 0.05 , ]
nrow(testResult.iprg.skyline.Peptidelevel)
## let's check one peptide. Check profile plot (page 6693)
testResult.iprg.skyline.Peptidelevel[testResult.iprg.skyline.Peptidelevel$Protein=='sp|P22146|GAS1_YEAST_ALNDADIYVIADLAAPATSINR', ]
| /Day2/section7/USHUPO2018_section7_MSstats.R | no_license | MeenaChoi/USHUPO2018_shortcourse | R | false | false | 12,647 | r | ##############################
##############################
## US HUPO 2018 Short course - Section 7 : Protein siginificance analysis with MSstats
## Date: March 11, 2018
## Created by Meena Choi
##############################
##############################
##############################
## 0. Load MSstats
##############################
library(MSstats)
?MSstats
##############################
## 1. Read data
##############################
# set working directory
# read skyline output
raw <- read.csv(file="iPRG_10ppm_2rt_15cut_nosingle.csv")
# read annotation table
annot <- read.csv("iPRG_skyline_annotation.csv", header=TRUE)
annot
# reformating and pre-processing for Skyline output.
quant <- SkylinetoMSstatsFormat(raw, annotation=annot)
head(quant)
##############################
## 2. Processing data
## Transformation = log2
## Normalization = equalize median
## Model-based run-level summarization (TMP) after imputation
##############################
quant.processed <- dataProcess(raw = quant,
logTrans=2,
normalization = 'equalizeMedians',
summaryMethod = 'TMP',
MBimpute=TRUE,
censoredInt='0',
cutoffCensored='minFeature',
maxQuantileforCensored = 0.999)
# show the name of outputs
names(quant.processed)
# show reformated and normalized data.
# 'ABUNDANCE' column has normalized log2 transformed intensities.
head(quant.processed$ProcessedData)
# This table includes run-level summarized log2 intensities. (column : LogIntensities)
# Now one summarized log2 intensities per Protein and Run.
# NumMeasuredFeature : show how many features are used for run-level summarization.
# If there is no missing value, it should be the number of features in certain protein.
# MissingPercentage : the number of missing features / the number of features in certain protein.
head(quant.processed$RunlevelData)
# show which summarization method is used.
head(quant.processed$SummaryMethod)
##############################
## 3. Data visualization
##############################
dataProcessPlots(data = quant.processed,
type="QCplot",
width=7, height=7,
which.Protein = 'allonly',
address='iPRG_skyline_equalizeNorm_')
# It will generate profile plots per protein. It will take a while
# Please run at home. It takes a while.
dataProcessPlots(data = quant.processed,
type="Profileplot",
featureName="NA",
width=7, height=7,
summaryPlot = TRUE,
originalPlot = FALSE,
address="iPRG_skyline_equalizeNorm_")
# Instead, make profile plot for only some.
dataProcessPlots(data = quant.processed,
type="Profileplot",
featureName="NA",
width=7, height=7,
which.Protein = 'sp|P44015|VAC2_YEAST',
address="iPRG_skyline_equalizeNorm_P44015")
# sp|P55752|ISCB_YEAST
# sp|P44374|SFG2_YEAST
# sp|P44983|UTR6_YEAST
# sp|P44683|PGA4_YEAST
# sp|P55249|ZRT4_YEAST
# and first few proteins
# Please run at home. It takes a while.
dataProcessPlots(data = quant.processed,
type="conditionplot",
width=7, height=7,
address="iPRG_skyline_equalizeNorm_")
# Instead, make profile plot for only some.
# sp|P44015|VAC2_YEAST
# sp|P55752|ISCB_YEAST
# sp|P44374|SFG2_YEAST
# sp|P44983|UTR6_YEAST
# sp|P44683|PGA4_YEAST
# sp|P55249|ZRT4_YEAST
# and first few proteins
##############################
## 4. Model-based comparison and adjustment for multiple testing
##############################
unique(quant.processed$ProcessedData$GROUP_ORIGINAL)
comparison1<-matrix(c(-1,1,0,0),nrow=1)
comparison2<-matrix(c(-1,0,1,0),nrow=1)
comparison3<-matrix(c(-1,0,0,1),nrow=1)
comparison4<-matrix(c(0,-1,1,0),nrow=1)
comparison5<-matrix(c(0,-1,0,1),nrow=1)
comparison6<-matrix(c(0,0,-1,1),nrow=1)
comparison<-rbind(comparison1, comparison2, comparison3, comparison4, comparison5, comparison6)
row.names(comparison)<-c("C2-C1","C3-C1","C4-C1","C3-C2","C4-C2","C4-C3")
test <- groupComparison(contrast.matrix=comparison, data=quant.processed)
names(test)
# Show test result
# Label : which comparison is reported.
# log2FC : estimated log2 fold change between conditions.
# adj.pvalue : adjusted p value by BH
# issue : detect whether this protein has any issue for comparison
# such as, there is measurement in certain group, or no measurement at all.
# MissingPercentage : the number of missing intensities/total number of intensities
# in conditions your are interested in for comparison
# ImputationPercentage : the number of imputed intensities/total number of intensities
# in conditions your are interested in for comparison
head(test$ComparisonResult)
# After fitting linear model, residuals and fitted values can be shown.
head(test$ModelQC)
# Fitted model per protein
head(test$fittedmodel)
# save testing result as .csv file
Skyline.intensity.comparison.result <- test$ComparisonResult
write.csv(Skyline.intensity.comparison.result,
file='testResult.iprg.skyline.proteinlevel.csv')
head(Skyline.intensity.comparison.result)
SignificantProteins <- Skyline.intensity.comparison.result[Skyline.intensity.comparison.result$adj.pvalue < 0.05 ,]
nrow(SignificantProteins)
## practice : please find the result for spike-in protein
# sp|P44015|VAC2_YEAST
# sp|P55752|ISCB_YEAST
# sp|P44374|SFG2_YEAST
# sp|P44983|UTR6_YEAST
# sp|P44683|PGA4_YEAST
# sp|P55249|ZRT4_YEAST
##############################
## 5. Visualization for testing result
##############################
groupComparisonPlots(Skyline.intensity.comparison.result,
type="VolcanoPlot",
address="testResult_iprg_skyline_")
groupComparisonPlots(data = Skyline.intensity.comparison.result,
type = 'VolcanoPlot',
sig = 0.05,
FCcutoff = 2^2,
address = 'testResult_iprg_skyline_FCcutoff4_')
groupComparisonPlots(Skyline.intensity.comparison.result,
type="Heatmap",
address="testResult_iprg_skyline_")
# Please run at home. It takes a while.
groupComparisonPlots(Skyline.intensity.comparison.result,
type="ComparisonPlot",
address="testResult_iprg_skyline_")
##############################
## 6. Verify the model assumption
##############################
# normal quantile-quantile plots
# Please run at home. It takes a while.
modelBasedQCPlots(data=test, type="QQPlots",
width=5, height=5,
address="iPRG_skyline_equalizeNorm_testResult_")
# residual plots
# Please run at home. It takes a while.
modelBasedQCPlots(data=test, type="ResidualPlots",
width=5, height=5,
address="iPRG_skyline_equalizeNorm_testResult_")
##############################
## 7. Power calculation
##############################
test.power <- designSampleSize(data = test$fittedmodel,
desiredFC = c(1.1, 1.6),
FDR = 0.05,
power = TRUE,
numSample = 3)
test.power
designSampleSizePlots(data = test.power)
##############################
## 8. Sample size calculation
##############################
samplesize <- designSampleSize(data = test$fittedmodel,
desiredFC = c(1.1, 1.6),
FDR = 0.05,
power = 0.9,
numSample = TRUE)
samplesize
designSampleSizePlots(data = samplesize)
##############################
## 9. sample quantification
##############################
sampleQuant <- quantification(quant.processed)
head(sampleQuant)
##############################
##############################
## Extra practice
##############################
##############################
##############################
## quantile normalization
##############################
quant.processed.quantile <- dataProcess(raw = quant,
logTrans=2,
normalization = 'quantile',
summaryMethod = 'TMP',
MBimpute=TRUE,
censoredInt='0',
cutoffCensored='minFeature',
maxQuantileforCensored = 0.999)
dataProcessPlots(data = quant.processed.quantile,
type="QCplot",
width=7, height=7,
which.Protein = 1,
address='iPRG_skyline_quantile_')
dataProcessPlots(data = quant.processed.quantile,
type="Profileplot",
featureName="NA",
width=7, height=7,
which.Protein = 1,
address="iPRG_skyline_quantile_1_")
##############################
##############################
## Extra : peptide-level analysis
##############################
##############################
head(quant)
quant.pep <- quant
head(quant.pep)
##############################
## 1. Replace 'ProteinName' with combination of 'ProteinName' and 'PeptideSequence'
##############################
quant.pep$ProteinName <- paste(quant.pep$ProteinName,
quant.pep$PeptideSequence,
sep = '_')
length(unique(quant.pep$ProteinName)) # 30500 peptides
save(quant.pep, file='quant.pep.RData')
##############################
## 2. Process the data
##############################
# Please run at home. It takes a while.
quant.pep.processed <- dataProcess(raw = quant.pep,
logTrans=2,
normalization = 'equalizeMedians',
summaryMethod = 'TMP',
MBimpute=TRUE,
censoredInt='0',
cutoffCensored='minFeature',
maxQuantileforCensored = 0.999)
save(quant.pep.processed, file='quant.pep.processed.RData')
##############################
## 3. Data visualization
##############################
dataProcessPlots(data = quant.pep.processed, type="QCplot",
width=7, height=7,
which.Protein = 1,
address='iPRG_skyline_equalizeNorm_Peptidelevel_')
# Please run at home. It takes a while.
dataProcessPlots(data = quant.pep.processed, type="Profileplot",
featureName="NA",
width=7, height=7,
summaryPlot = FALSE,
address="iPRG_skyline_equalizeNorm_Peptidelevel_")
# Please run at home. It takes a while.
dataProcessPlots(data = quant.pep.processed, type="conditionplot",
address="iPRG_skyline_equalizeNorm_Peptidelevel_")
##############################
## 4. Model-based comparison and adjustment for multiple testing
##############################
unique(quant.pep.processed$ProcessedData$GROUP_ORIGINAL)
comparison1<-matrix(c(-1,1,0,0),nrow=1)
comparison2<-matrix(c(-1,0,1,0),nrow=1)
comparison3<-matrix(c(-1,0,0,1),nrow=1)
comparison4<-matrix(c(0,-1,1,0),nrow=1)
comparison5<-matrix(c(0,-1,0,1),nrow=1)
comparison6<-matrix(c(0,0,-1,1),nrow=1)
comparison<-rbind(comparison1, comparison2, comparison3, comparison4, comparison5, comparison6)
row.names(comparison)<-c("C2-C1","C3-C1","C4-C1","C3-C2","C4-C2","C4-C3")
# Please run at home. It takes a while.
test.Peptidelevel <- groupComparison(contrast.matrix=comparison,
data=quant.pep.processed)
testResult.iprg.skyline.Peptidelevel <- test.Peptidelevel$ComparisonResult
save(testResult.iprg.skyline.Peptidelevel, file='testResult.iprg.skyline.Peptidelevel.RData')
write.csv(testResult.iprg.skyline.Peptidelevel , file='testResult.iprg.skyline.Peptidelevel.csv')
head(testResult.iprg.skyline.Peptidelevel)
SignificantProteins <- testResult.iprg.skyline.Peptidelevel[testResult.iprg.skyline.Peptidelevel$adj.pvalue < 0.05 , ]
nrow(testResult.iprg.skyline.Peptidelevel)
## let's check one peptide. Check profile plot (page 6693)
testResult.iprg.skyline.Peptidelevel[testResult.iprg.skyline.Peptidelevel$Protein=='sp|P22146|GAS1_YEAST_ALNDADIYVIADLAAPATSINR', ]
|
library(rstan)
num_obs = 100
num_non_zeros = 20
y = rep(0,num_obs)
true_beta = rnorm(num_non_zeros) * 5
y[1:num_non_zeros] = true_beta
y = y + rnorm(num_obs)
print(true_beta)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/horseshoe_toy.stan"
model_hs = stan_model(file=address)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/rhorseshoe_toy.stan"
model_rhs = stan_model(file=address)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/linear_regression_horseshoe.stan"
model_lr_hs = stan_model(file=address)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/linear_regression_rhorseshoe.stan"
model_lr_rhs = stan_model(file=address)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/linear_regression_student_t.stan"
model_lr_student = stan_model(file=address)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/logistic_regression_horseshoe.stan"
model_logit_horseshoe = stan_model(file=address)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/logistic_regression_rhorseshoe.stan"
model_logit_rhorseshoe = stan_model(file=address)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/logistic_regression_student_t.stan"
model_logit_student = stan_model(file=address)
options(mc.cores = parallel::detectCores())
data = list(y=y,N=num_obs)
o1 = sampling(model_hs,data=data,control=list("metric"="diag_e",adapt_delta = 0.9))
print(o1)
beta_summary <- summary(o1, pars = c("beta"))$summary
lp_summary = summary(o1,pars=c("lp__"))$summary
tau_summary = summary(o1,pars=c("tau"))$summary
print(beta_summary[1:non_zero_dim,])
print(true_beta[1:non_zero_dim])
print(tau_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o1, inc_warmup = TRUE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
####################################################################################################################################
o2 = sampling(model_hs,data=data,control=list("metric"="dense_e",adapt_delta = 0.99,max_treedepth=15))
beta_summary <- summary(o2, pars = c("beta"))$summary
lp_summary = summary(o2,pars=c("lp__"))$summary
tau_summary = summary(o2,pars=c("tau"))$summary
print(beta_summary)
print(tau_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o2, inc_warmup = TRUE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
#######################################################################################################################################
o3 = sampling(model_rhs,data=data,control=list("metric"="diag_e",adapt_delta = 0.9,max_treedepth=10))
beta_summary <- summary(o3, pars = c("beta"))$summary
lp_summary = summary(o3,pars=c("lp__"))$summary
tau_summary = summary(o3,pars=c("tau"))$summary
print(beta_summary)
print(tau_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o3, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
###################################################################################################################################
o4 = sampling(model_rhs,data=data,control=list("metric"="dense_e",adapt_delta = 0.9,max_treedepth=10))
beta_summary <- summary(o4, pars = c("beta"))$summary
lp_summary = summary(o4,pars=c("lp__"))$summary
tau_summary = summary(o4,pars=c("tau"))$summary
print(beta_summary)
print(tau_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o4, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
################################################################################################################################
num_obs = 400
non_zero_dim = 20
full_p = 100
X = matrix(rnorm(num_obs*full_p),nrow=num_obs,ncol=full_p)
library(Matrix)
rankMatrix(X)
true_beta = rnorm(full_p)
true_beta[1:non_zero_dim] = rnorm(non_zero_dim)*5
print(true_beta[1:non_zero_dim])
y = X%*%true_beta + rnorm(num_obs)
y = drop(y)
data = list(y=y,X=X,N=num_obs,K=full_p)
o5 = sampling(model_lr_hs,data=data,control=list("metric"="diag_e",adapt_delta = 0.9,max_treedepth=10))
beta_summary <- summary(o5, pars = c("beta"))$summary
lp_summary = summary(o5,pars=c("lp__"))$summary
tau_summary = summary(o5,pars=c("tau"))$summary
print(beta_summary)
print(tau_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o5, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
##################################################################################################################################
o6 = sampling(model_lr_rhs,data=data,control=list("metric"="diag_e",adapt_delta = 0.9,max_treedepth=15))
beta_summary <- summary(o6, pars = c("beta"))$summary
lp_summary = summary(o6,pars=c("lp__"))$summary
tau_summary = summary(o6,pars=c("tau"))$summary
c_summary <- summary(o6, pars = c("c"))$summary
print(beta_summary[1:non_zero_dim,])
print(true_beta[1:non_zero_dim])
print(tau_summary)
print(c_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o6, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
#########################################################################################################################################
library(glmnet)
lambda <- 10^seq(10, -2, length = 100)
lasso.mod = glmnet(X, y, alpha = 1, lambda = lambda)
bestlam <- lasso.mod$lambda.min
lasso.coef <- predict(lasso.mod, type = 'coefficients', s = bestlam)
out = glmnet(X, y, alpha = 1, lambda = 1)
print(coef(out))
##########################################################################################################################################
o7 = sampling(model_lr_student,data=data,control=list("metric"="diag_e",adapt_delta = 0.9,max_treedepth=15))
beta_summary <- summary(o7, pars = c("beta"))$summary
lp_summary = summary(o7,pars=c("lp__"))$summary
tau_summary = summary(o7,pars=c("tau"))$summary
c_summary <- summary(o7, pars = c("c"))$summary
print(beta_summary[1:non_zero_dim,])
print(true_beta[1:non_zero_dim])
print(tau_summary)
print(c_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o7, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
#############################################################################################################################
# logistic
n = 30
dim = 100
X = matrix(rnorm(n*dim),nrow=n,ncol=dim)
y = rep(0,n)
for(i in 1:n){
y[i] = rbinom(n=1,size=1,prob=0.5)
if(y[i]>0){
X[i,1:2] = rnorm(2)*0.5 + 1
}
else{
X[i,1:2] = rnorm(2)*0.5 -1
}
}
data = list(X=X,y=y,N=n,K=dim)
o8 = sampling(model_logit_horseshoe,data=data,control=list("metric"="diag_e",adapt_delta = 0.9,max_treedepth=15))
beta_summary <- summary(o8, pars = c("beta"))$summary
lp_summary = summary(o8,pars=c("lp__"))$summary
tau_summary = summary(o8,pars=c("tau"))$summary
c_summary <- summary(o8, pars = c("c"))$summary
print(beta_summary[1:non_zero_dim,])
print(true_beta[1:non_zero_dim])
print(tau_summary)
print(c_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o8, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
#######################################################################################################
o9 = sampling(model_logit_rhorseshoe,data=data,control=list("metric"="diag_e",adapt_delta = 0.99,max_treedepth=15))
beta_summary <- summary(o9, pars = c("beta"))$summary
lp_summary = summary(o9,pars=c("lp__"))$summary
tau_summary = summary(o9,pars=c("tau"))$summary
c_summary <- summary(o9, pars = c("c"))$summary
print(beta_summary[1:non_zero_dim,])
print(true_beta[1:non_zero_dim])
print(tau_summary)
print(c_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o9, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
####################################################################################################
o10 = sampling(model_logit_student,data=data,control=list("metric"="diag_e",adapt_delta = 0.9,max_treedepth=15))
beta_summary <- summary(o10, pars = c("beta"))$summary
lp_summary = summary(o10,pars=c("lp__"))$summary
tau_summary = summary(o10,pars=c("tau"))$summary
c_summary <- summary(o10, pars = c("c"))$summary
print(beta_summary[1:non_zero_dim,])
print(true_beta[1:non_zero_dim])
print(tau_summary)
print(c_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o10, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
############################################################################################################ | /pystan_examples/stan_toy.R | no_license | yiulau/all_code | R | false | false | 12,188 | r | library(rstan)
num_obs = 100
num_non_zeros = 20
y = rep(0,num_obs)
true_beta = rnorm(num_non_zeros) * 5
y[1:num_non_zeros] = true_beta
y = y + rnorm(num_obs)
print(true_beta)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/horseshoe_toy.stan"
model_hs = stan_model(file=address)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/rhorseshoe_toy.stan"
model_rhs = stan_model(file=address)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/linear_regression_horseshoe.stan"
model_lr_hs = stan_model(file=address)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/linear_regression_rhorseshoe.stan"
model_lr_rhs = stan_model(file=address)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/linear_regression_student_t.stan"
model_lr_student = stan_model(file=address)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/logistic_regression_horseshoe.stan"
model_logit_horseshoe = stan_model(file=address)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/logistic_regression_rhorseshoe.stan"
model_logit_rhorseshoe = stan_model(file=address)
address = "/home/yiulau/PycharmProjects/all_code/stan_code/logistic_regression_student_t.stan"
model_logit_student = stan_model(file=address)
options(mc.cores = parallel::detectCores())
data = list(y=y,N=num_obs)
o1 = sampling(model_hs,data=data,control=list("metric"="diag_e",adapt_delta = 0.9))
print(o1)
beta_summary <- summary(o1, pars = c("beta"))$summary
lp_summary = summary(o1,pars=c("lp__"))$summary
tau_summary = summary(o1,pars=c("tau"))$summary
print(beta_summary[1:non_zero_dim,])
print(true_beta[1:non_zero_dim])
print(tau_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o1, inc_warmup = TRUE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
####################################################################################################################################
o2 = sampling(model_hs,data=data,control=list("metric"="dense_e",adapt_delta = 0.99,max_treedepth=15))
beta_summary <- summary(o2, pars = c("beta"))$summary
lp_summary = summary(o2,pars=c("lp__"))$summary
tau_summary = summary(o2,pars=c("tau"))$summary
print(beta_summary)
print(tau_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o2, inc_warmup = TRUE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
#######################################################################################################################################
o3 = sampling(model_rhs,data=data,control=list("metric"="diag_e",adapt_delta = 0.9,max_treedepth=10))
beta_summary <- summary(o3, pars = c("beta"))$summary
lp_summary = summary(o3,pars=c("lp__"))$summary
tau_summary = summary(o3,pars=c("tau"))$summary
print(beta_summary)
print(tau_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o3, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
###################################################################################################################################
o4 = sampling(model_rhs,data=data,control=list("metric"="dense_e",adapt_delta = 0.9,max_treedepth=10))
beta_summary <- summary(o4, pars = c("beta"))$summary
lp_summary = summary(o4,pars=c("lp__"))$summary
tau_summary = summary(o4,pars=c("tau"))$summary
print(beta_summary)
print(tau_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o4, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
################################################################################################################################
num_obs = 400
non_zero_dim = 20
full_p = 100
X = matrix(rnorm(num_obs*full_p),nrow=num_obs,ncol=full_p)
library(Matrix)
rankMatrix(X)
true_beta = rnorm(full_p)
true_beta[1:non_zero_dim] = rnorm(non_zero_dim)*5
print(true_beta[1:non_zero_dim])
y = X%*%true_beta + rnorm(num_obs)
y = drop(y)
data = list(y=y,X=X,N=num_obs,K=full_p)
o5 = sampling(model_lr_hs,data=data,control=list("metric"="diag_e",adapt_delta = 0.9,max_treedepth=10))
beta_summary <- summary(o5, pars = c("beta"))$summary
lp_summary = summary(o5,pars=c("lp__"))$summary
tau_summary = summary(o5,pars=c("tau"))$summary
print(beta_summary)
print(tau_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o5, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
##################################################################################################################################
o6 = sampling(model_lr_rhs,data=data,control=list("metric"="diag_e",adapt_delta = 0.9,max_treedepth=15))
beta_summary <- summary(o6, pars = c("beta"))$summary
lp_summary = summary(o6,pars=c("lp__"))$summary
tau_summary = summary(o6,pars=c("tau"))$summary
c_summary <- summary(o6, pars = c("c"))$summary
print(beta_summary[1:non_zero_dim,])
print(true_beta[1:non_zero_dim])
print(tau_summary)
print(c_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o6, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
#########################################################################################################################################
library(glmnet)
lambda <- 10^seq(10, -2, length = 100)
lasso.mod = glmnet(X, y, alpha = 1, lambda = lambda)
bestlam <- lasso.mod$lambda.min
lasso.coef <- predict(lasso.mod, type = 'coefficients', s = bestlam)
out = glmnet(X, y, alpha = 1, lambda = 1)
print(coef(out))
##########################################################################################################################################
o7 = sampling(model_lr_student,data=data,control=list("metric"="diag_e",adapt_delta = 0.9,max_treedepth=15))
beta_summary <- summary(o7, pars = c("beta"))$summary
lp_summary = summary(o7,pars=c("lp__"))$summary
tau_summary = summary(o7,pars=c("tau"))$summary
c_summary <- summary(o7, pars = c("c"))$summary
print(beta_summary[1:non_zero_dim,])
print(true_beta[1:non_zero_dim])
print(tau_summary)
print(c_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o7, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
#############################################################################################################################
# logistic
n = 30
dim = 100
X = matrix(rnorm(n*dim),nrow=n,ncol=dim)
y = rep(0,n)
for(i in 1:n){
y[i] = rbinom(n=1,size=1,prob=0.5)
if(y[i]>0){
X[i,1:2] = rnorm(2)*0.5 + 1
}
else{
X[i,1:2] = rnorm(2)*0.5 -1
}
}
data = list(X=X,y=y,N=n,K=dim)
o8 = sampling(model_logit_horseshoe,data=data,control=list("metric"="diag_e",adapt_delta = 0.9,max_treedepth=15))
beta_summary <- summary(o8, pars = c("beta"))$summary
lp_summary = summary(o8,pars=c("lp__"))$summary
tau_summary = summary(o8,pars=c("tau"))$summary
c_summary <- summary(o8, pars = c("c"))$summary
print(beta_summary[1:non_zero_dim,])
print(true_beta[1:non_zero_dim])
print(tau_summary)
print(c_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o8, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
#######################################################################################################
o9 = sampling(model_logit_rhorseshoe,data=data,control=list("metric"="diag_e",adapt_delta = 0.99,max_treedepth=15))
beta_summary <- summary(o9, pars = c("beta"))$summary
lp_summary = summary(o9,pars=c("lp__"))$summary
tau_summary = summary(o9,pars=c("tau"))$summary
c_summary <- summary(o9, pars = c("c"))$summary
print(beta_summary[1:non_zero_dim,])
print(true_beta[1:non_zero_dim])
print(tau_summary)
print(c_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o9, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
####################################################################################################
o10 = sampling(model_logit_student,data=data,control=list("metric"="diag_e",adapt_delta = 0.9,max_treedepth=15))
beta_summary <- summary(o10, pars = c("beta"))$summary
lp_summary = summary(o10,pars=c("lp__"))$summary
tau_summary = summary(o10,pars=c("tau"))$summary
c_summary <- summary(o10, pars = c("c"))$summary
print(beta_summary[1:non_zero_dim,])
print(true_beta[1:non_zero_dim])
print(tau_summary)
print(c_summary)
print(lp_summary)
sampler_params <- get_sampler_params(o10, inc_warmup = FALSE)
sampler_params_chain1 <- sampler_params[[1]]
mean_accept_stat_by_chain <- sapply(sampler_params, function(x) mean(x[, "accept_stat__"]))
print(mean_accept_stat_by_chain)
print(sampler_params_chain1[1:900,"stepsize__"])
print(sampler_params_chain1[1:900,"n_leapfrog__"])
print(sampler_params_chain1[1000:1900,"n_leapfrog__"])
num_divergent = sapply(sampler_params, function(x) sum(x[, "divergent__"]))
print(num_divergent)
############################################################################################################ |
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/remeshList.r
\name{remeshList}
\alias{remeshList}
\title{Remesh a list of registered meshes (with corresponding vertices)}
\usage{
remeshList(matchlist, reference = 1, random = FALSE, voxelSize = NULL,
discretize = FALSE, multiSample = FALSE, absDist = FALSE,
mergeClost = FALSE, silent = FALSE)
}
\arguments{
\item{matchlist}{a list of meshes with corresponding vertices (same amount and pseudo-homologous positions), e.g. registered with \code{\link{gaussMatch}}. Meshes do not need to be aligned.}
\item{reference}{integer: select the specimen the to which the decimation is to applied initially.}
\item{random}{if TRUE, a random specimen is selected for initial decimation}
\item{voxelSize}{voxel size for space discretization}
\item{discretize}{If TRUE, the position of the intersected edge of the marching cube grid is not computed by linear interpolation, but it is placed in fixed middle position. As a consequence the resampled object will look severely aliased by a stairstep appearance.}
\item{multiSample}{If TRUE, the distance field is more accurately compute by multisampling the volume (7 sample for each voxel). Much slower but less artifacts.}
\item{absDist}{If TRUE, an unsigned distance field is computed. In this case you have to choose a not zero Offset and a double surface is built around the original surface, inside and outside.}
\item{mergeClost}{logical: merge close vertices}
\item{silent}{logical: suppress messages}
}
\value{
a list of remeshed meshes with correspondences preserved.
}
\description{
Remesh a list of registered meshes (with corresponding vertices), preserving correspondences using Quadric Edge Collapse decimation
}
\details{
The remeshing is applied to a reference and then the barycentric coordinates of the new vertices on the original surface are calculated. These are used to extract the corresponding positions of the remeshed versions on all meshes in the sample. The remeshing is performed by the function \code{vcgUniformRemesh} from the Rvcg-package.
}
| /man/remeshList.Rd | no_license | Celli119/mesheR | R | false | true | 2,102 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/remeshList.r
\name{remeshList}
\alias{remeshList}
\title{Remesh a list of registered meshes (with corresponding vertices)}
\usage{
remeshList(matchlist, reference = 1, random = FALSE, voxelSize = NULL,
discretize = FALSE, multiSample = FALSE, absDist = FALSE,
mergeClost = FALSE, silent = FALSE)
}
\arguments{
\item{matchlist}{a list of meshes with corresponding vertices (same amount and pseudo-homologous positions), e.g. registered with \code{\link{gaussMatch}}. Meshes do not need to be aligned.}
\item{reference}{integer: select the specimen the to which the decimation is to applied initially.}
\item{random}{if TRUE, a random specimen is selected for initial decimation}
\item{voxelSize}{voxel size for space discretization}
\item{discretize}{If TRUE, the position of the intersected edge of the marching cube grid is not computed by linear interpolation, but it is placed in fixed middle position. As a consequence the resampled object will look severely aliased by a stairstep appearance.}
\item{multiSample}{If TRUE, the distance field is more accurately compute by multisampling the volume (7 sample for each voxel). Much slower but less artifacts.}
\item{absDist}{If TRUE, an unsigned distance field is computed. In this case you have to choose a not zero Offset and a double surface is built around the original surface, inside and outside.}
\item{mergeClost}{logical: merge close vertices}
\item{silent}{logical: suppress messages}
}
\value{
a list of remeshed meshes with correspondences preserved.
}
\description{
Remesh a list of registered meshes (with corresponding vertices), preserving correspondences using Quadric Edge Collapse decimation
}
\details{
The remeshing is applied to a reference and then the barycentric coordinates of the new vertices on the original surface are calculated. These are used to extract the corresponding positions of the remeshed versions on all meshes in the sample. The remeshing is performed by the function \code{vcgUniformRemesh} from the Rvcg-package.
}
|
library(igraph)
BuildGraph <- function(filename = "../../results/TimeSeriesExperiments/results_2017-10-30_23-22-06_unity.csv") {
globalInfluence <- read.csv(filename)
g <- graph(directed = TRUE, edges = as.vector(t(globalInfluence[,1:2])))
g
}
| /scripts/global_influence_ranking/BuildGraph.R | permissive | trzytematyczna/influence-citation-network | R | false | false | 251 | r | library(igraph)
BuildGraph <- function(filename = "../../results/TimeSeriesExperiments/results_2017-10-30_23-22-06_unity.csv") {
globalInfluence <- read.csv(filename)
g <- graph(directed = TRUE, edges = as.vector(t(globalInfluence[,1:2])))
g
}
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/formatting_functions.r
\name{as_percentage}
\alias{as_percentage}
\title{Changes Excel column to percent type}
\usage{
as_percentage(x)
}
\description{
Changes Excel column to percent type
}
\author{
Sean Brunson
}
| /man/as_percentage.Rd | permissive | SeanBrunson/easyresearch | R | false | true | 293 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/formatting_functions.r
\name{as_percentage}
\alias{as_percentage}
\title{Changes Excel column to percent type}
\usage{
as_percentage(x)
}
\description{
Changes Excel column to percent type
}
\author{
Sean Brunson
}
|
library(Rcpp)
library(surveillance)
library(rstan)
library(lubridate)
library(tidyverse)
library(nleqslv)
library(scoringRules)
library(R0)
library(future)
library(future.apply)
# Load data
load("../../../data_public/evaluation/dat_bavaria_persspec_synth.RData")
# Load model
mod = readRDS("../stan_models/poisson_rWalk_cp.rds")
# Load functions to estimate nowcast
source("../eval_fun.R")
# Define dates for which to estimate nowcast
eval_dates = seq(ymd("2020-02-24") + 22, ymd("2020-06-30"), by = 1)
# Restrict to fewer dates for faster computation
eval_dates = eval_dates[1:2]
# Setup cluster to perform estimation
# Library Path
libs <- .libPaths()[1]
libs_cmd <- sprintf(".libPaths(c(%s))", paste(sprintf('"%s"', libs), collapse = ", "))
# Define number of workers
# Note that each call to estimate_nowcast starts four parallel chains of MCMC sampling
# (Available number of cores has to be 4 times the number of workers in cluster)
cl <- future::makeClusterPSOCK(2, rscript_args = c("-e", shQuote(libs_cmd)))
plan(cluster, workers = cl)
# Apply over dates to perform nowcasting based on data available until 'now'
res_list = future_lapply(sample(eval_dates), FUN = function(x) {
print(paste0("Start nowcast: ",x))
tryCatch(estimate_nowcast(now=x,
data = dat_mod,
begin_date = ymd("2020-02-24"),
D=21,
predLag = 2,
model = mod,
mod_name = "poisson_rW_cp2W"),
error = function(e) e)
})
save(res_list, file = "../../../results_public/2_evaluation/bavaria/poiss_rW_cp_2w_synthetic.RData")
| /code_public/2_evaluation/est_bavarian_data/est_poiss_rW_cp_2w.R | no_license | luk05/nc_covid19_bavaria | R | false | false | 1,686 | r | library(Rcpp)
library(surveillance)
library(rstan)
library(lubridate)
library(tidyverse)
library(nleqslv)
library(scoringRules)
library(R0)
library(future)
library(future.apply)
# Load data
load("../../../data_public/evaluation/dat_bavaria_persspec_synth.RData")
# Load model
mod = readRDS("../stan_models/poisson_rWalk_cp.rds")
# Load functions to estimate nowcast
source("../eval_fun.R")
# Define dates for which to estimate nowcast
eval_dates = seq(ymd("2020-02-24") + 22, ymd("2020-06-30"), by = 1)
# Restrict to fewer dates for faster computation
eval_dates = eval_dates[1:2]
# Setup cluster to perform estimation
# Library Path
libs <- .libPaths()[1]
libs_cmd <- sprintf(".libPaths(c(%s))", paste(sprintf('"%s"', libs), collapse = ", "))
# Define number of workers
# Note that each call to estimate_nowcast starts four parallel chains of MCMC sampling
# (Available number of cores has to be 4 times the number of workers in cluster)
cl <- future::makeClusterPSOCK(2, rscript_args = c("-e", shQuote(libs_cmd)))
plan(cluster, workers = cl)
# Apply over dates to perform nowcasting based on data available until 'now'
res_list = future_lapply(sample(eval_dates), FUN = function(x) {
print(paste0("Start nowcast: ",x))
tryCatch(estimate_nowcast(now=x,
data = dat_mod,
begin_date = ymd("2020-02-24"),
D=21,
predLag = 2,
model = mod,
mod_name = "poisson_rW_cp2W"),
error = function(e) e)
})
save(res_list, file = "../../../results_public/2_evaluation/bavaria/poiss_rW_cp_2w_synthetic.RData")
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data_jen.R
\docType{data}
\name{cand_events_20150114}
\alias{cand_events_20150114}
\title{Looking For Clues: Who Is Going To Run For President In 2016?}
\format{A data frame with 42 rows representing events attended in Iowa and New Hampshire by potential presidential primary candidates and 8 variables:
\describe{
\item{person}{Potential presidential candidate}
\item{party}{Political party}
\item{state}{State of event}
\item{event}{Name of event}
\item{type}{Type of event}
\item{date}{Date of event}
\item{link}{Link to event}
\item{snippet}{Snippet of event description}
}}
\source{
See \url{https://github.com/fivethirtyeight/data/tree/master/potential-candidates}
}
\usage{
cand_events_20150114
}
\description{
The raw data behind the story
"Looking For Clues: Who Is Going To Run For President In 2016?"
\url{http://fivethirtyeight.com/datalab/2016-president-who-is-going-to-run/}.
}
\seealso{
\code{\link{cand_state_20150114}}, \code{\link{cand_events_20150130}}, and \code{\link{cand_state_20150130}}
}
\keyword{datasets}
| /man/cand_events_20150114.Rd | no_license | nnsc-ott-k/fivethirtyeight | R | false | true | 1,127 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data_jen.R
\docType{data}
\name{cand_events_20150114}
\alias{cand_events_20150114}
\title{Looking For Clues: Who Is Going To Run For President In 2016?}
\format{A data frame with 42 rows representing events attended in Iowa and New Hampshire by potential presidential primary candidates and 8 variables:
\describe{
\item{person}{Potential presidential candidate}
\item{party}{Political party}
\item{state}{State of event}
\item{event}{Name of event}
\item{type}{Type of event}
\item{date}{Date of event}
\item{link}{Link to event}
\item{snippet}{Snippet of event description}
}}
\source{
See \url{https://github.com/fivethirtyeight/data/tree/master/potential-candidates}
}
\usage{
cand_events_20150114
}
\description{
The raw data behind the story
"Looking For Clues: Who Is Going To Run For President In 2016?"
\url{http://fivethirtyeight.com/datalab/2016-president-who-is-going-to-run/}.
}
\seealso{
\code{\link{cand_state_20150114}}, \code{\link{cand_events_20150130}}, and \code{\link{cand_state_20150130}}
}
\keyword{datasets}
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/euclidean.R
\name{euclidean}
\alias{euclidean}
\title{Title}
\usage{
euclidean(x1, x2)
}
\arguments{
\item{x1}{first number}
\item{x2}{second number}
}
\value{
returns greater common divisor of two value
}
\description{
Title
}
\examples{
euclidean(100, 1000)
}
\references{
\href{https://en.wikipedia.org/wiki/Euclidean_algorithm}{wikipedia page}
}
| /man/euclidean.Rd | permissive | Malma831/lab3Rpackage | R | false | true | 429 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/euclidean.R
\name{euclidean}
\alias{euclidean}
\title{Title}
\usage{
euclidean(x1, x2)
}
\arguments{
\item{x1}{first number}
\item{x2}{second number}
}
\value{
returns greater common divisor of two value
}
\description{
Title
}
\examples{
euclidean(100, 1000)
}
\references{
\href{https://en.wikipedia.org/wiki/Euclidean_algorithm}{wikipedia page}
}
|
# Tema 3 PS Oloieri Alexandru
#C1
vol = function(a, n)
{
cnt = 0;
sq = sqrt(a);
for (i in 1:n)
{
u = runif(1,-sq,sq);
v = runif(1,-sq,sq);
w = (u*u)+(v*v);
if (w<=a)
cnt = cnt + 1;
}
inm = (2*sq)*(2*sq);
#cat(a," ",n," ",inm," ",sq," ",cnt,"\n");
return (inm*cnt/n);
}
computeAns = function(a)
{
pi = 3.141592653589793;
rez = (pi * (a*a)) / 2;
val = c(10000,20000,50000);
for (n in val)
{
ans = vol(a, n);
err = abs(ans - rez);
cat("Volumul este ",ans," pentru esantionul curent\n");
cat("Eroarea relativa pentru n=",n," este ",err,"\n");
}
}
computeAns(2);
#C2
h = function(n)
{
cnt = 0;
for (i in 1:n)
{
x = runif(1,0,1.5);
y = runif(1,0,1);
if ((x-2*y<=0) & (2*x-3*y>=0) & (3*x+2*y<=6))
cnt = cnt + 1;
#cat(x," ",y," ",cnt,"\n");
}
#cat(cnt,"\n");
inm = 1.5 * 1;
return (1.5 * cnt / n);
}
h(10000);
#C3
#a
integrala1 = function()
{
n = 10000;
#ans = ((3*sqrt(3))/8 + 13/24);
ans = 0.8578523861716623;
sum = 0;
for (i in 1:n)
{
x = runif(1,0,pi/3);
s = sin(x);
c = cos(x);
sum = sum + s*s*s + c*c*c;
}
sum = sum*(pi/3) / n;
cat("Valoarea integralei: ",ans,", rezultatul aproximat: ",sum,"\n");
cat("Eroarea absoluta: ", abs(ans-sum),"\n");
}
integrala1();
#b
computeSecondI = function(n)
{
sum = 0;
for (i in 1:n)
{
x = rexp(1,1);
sum = sum + (1/(2*x^2+1))/exp(-x);
}
sum = sum/n;
return (sum);
}
integrala2 = function(n,k)
{
pi = 3.141592653589793;
ans = pi/(2*sqrt(2));
estimate = vector();
for (i in 1:k)
estimate[i] = computeSecondI(n);
sum = mean(estimate);
cat("Valoarea integralei: ",ans,", rezultatul aproximat: ",sum,"\n");
cat("Eroarea absoluta: ", abs(ans-sum),"\n");
}
integrala2(50000,50);
#C5
#Helper function
goodP = function(p)
{
pb = runif(1,0,1);
if (pb <= p)
return (TRUE);
return (FALSE);
}
c5aSimulation = function(p1,p2)
{
days = 1;
pc = vector();
for (i in 1:25)
pc[i] = FALSE;
pc[sample(1:25,1)] = TRUE;
while (TRUE)
{
cnt = sum(pc);
if (cnt == 0)
break;
days = days + 1;
if (goodP(p1) && cnt < 25) # mai infectez unul in ziua curenta
{
now = sample(1:25,1);
while(pc[now] == TRUE)
now = sample(1:25,1);
pc[now] = TRUE;
}
if (goodP(p2)) # curata calculatoare
{
perm = sample(1:25,25,replace = FALSE);
rem = 2;
rm = 0;
if (sum(pc) == 1) rem = 1;
for (i in 1:25)
{
if (pc[perm[i]] == FALSE) next;
if (rm == rem) break;
rm = rm + 1;
pc[perm[i]] = FALSE;
}
}
}
return (days);
}
c5a = function(n, p1, p2)
{
sum = 0;
for (i in 1:n)
{
sum = sum + c5aSimulation(p1,p2);
}
sum = sum / n;
return (sum);
}
c5a(10000,0.25,0.15)
c5bSimulation = function(p1,p2)
{
pc = vector();
for (i in 1:25)
pc[i] = FALSE;
pc[sample(1:25,1)] = TRUE;
while (TRUE)
{
cnt = sum(pc);
if (cnt == 0)
break;
if (goodP(p1) && cnt < 25) # mai infectez unul in ziua curenta
{
now = sample(1:25,1);
while(pc[now] == TRUE)
now = sample(1:25,1);
pc[now] = TRUE;
}
if (sum(pc)>=5)
return (TRUE);
if (goodP(p2)) # curata calculatoare
{
perm = sample(1:25,25,replace = FALSE);
rem = 2;
rm = 0;
if (sum(pc) == 1) rem = 1;
for (i in 1:25)
{
if (pc[perm[i]] == FALSE) next;
if (rm == rem) break;
rm = rm + 1;
pc[perm[i]] = FALSE;
}
}
}
return (FALSE);
}
c5b = function(n,p1,p2)
{
nr = 0;
for (i in 1:n)
{
if (c5bSimulation(p1,p2))
nr = nr + 1;
}
nr = nr / n;
return(nr);
}
c5b(10000,0.25,0.15);
#C7
#Helper function
goodP = function(p)
{
pb = runif(1,0,1);
if (pb <= p)
return (TRUE);
return (FALSE);
}
c7aSimulation = function(p)
{
pc = vector();
once = vector();
for (i in 1:25)
{
pc[i] = FALSE;
once[i] = FALSE;
}
first = sample(1:25,1);
pc[first] = TRUE;
once[first] = TRUE;
while (TRUE)
{
cnt = sum(pc);
if (cnt == 0)
break;
for (i in 1:25)
{
if (pc[i] == TRUE)
next;
if (goodP(p) == TRUE) # este infectat
{
pc[i] = TRUE;
once[i] = TRUE;
}
}
if (sum(once) == 25)
return (TRUE);
rnd = sample(1:25, size = 25);
nr = 0;
for (i in 1:25)
{
if (pc[rnd[i]] == FALSE)
next;
if (nr == 4)
break;
nr = nr + 1;
pc[rnd[i]] = FALSE;
}
}
return (FALSE);
}
c7a = function(n)
{
sum = 0;
for (i in 1:n)
{
if (c7aSimulation(0.3))
sum = sum + 1;
}
sum = sum / n;
return (sum);
}
c7a(3152);
c7bSimulation = function(p)
{
pc = vector();
for (i in 1:25)
pc[i] = FALSE;
pc[sample(1:25,1)] = TRUE;
while (TRUE)
{
cnt = sum(pc);
if (cnt == 0)
break;
for (i in 1:25)
{
if (pc[i] == TRUE)
next;
if (goodP(p) == TRUE) # este infectat
{
pc[i] = TRUE;
cnt= cnt + 1;
}
}
if (cnt == 25)
return (TRUE);
rnd = sample(1:25, size = 25);
nr = 0;
for (i in 1:25)
{
if (pc[rnd[i]] == FALSE)
next;
if (nr == 4)
break;
nr = nr + 1;
pc[rnd[i]] = FALSE;
}
}
return (FALSE);
}
c7b = function(n, p)
{
sum = 0;
for (i in 1:n)
{
if (c7bSimulation(p) == TRUE)
sum = sum + 1;
}
sum = sum / n;
return (sum);
}
c7b(20,0.3)
c7c = function(epsilon, p, p_stelat)
{
alfa = 1 - p;
z = qnorm(alfa/2);
nMin = p_stelat * (1 - p_stelat) * ((z/epsilon)^2);
return (nMin);
}
c7c(0.01,0.99,0.95);
# Exercitii rezolvate, dar pe care nu le prezint
#C4
calculTimpServire = function(n) # pentru un esantion de marime n
{
ans = 0;
for (i in 1:n)
{
ansClientActual = 0;
v1 = rgamma(1,6,4);
v2 = rgamma(1,5,3);
latenta = rexp(1,1);
p = runif(1,0,1);
if (p<=0.35){
ansClientActual = ansClientActual + v1/1000;
}
else {
ansClientActual = ansClientActual + v2/1000;
}
ansClientActual = ansClientActual + latenta;
ans = ans + ansClientActual;
}
return (ans / n);
}
n=50000;
cat("Timpul mediu necesar servirii unui client: ",calculTimpServire(n),"\n");
cat("Aceasta valoare a fost calculata pe un esantion n=",n)
| /Probabilities and Statistics/lab3tema/tema3.R | no_license | andreihaivas6/University | R | false | false | 6,379 | r | # Tema 3 PS Oloieri Alexandru
#C1
vol = function(a, n)
{
cnt = 0;
sq = sqrt(a);
for (i in 1:n)
{
u = runif(1,-sq,sq);
v = runif(1,-sq,sq);
w = (u*u)+(v*v);
if (w<=a)
cnt = cnt + 1;
}
inm = (2*sq)*(2*sq);
#cat(a," ",n," ",inm," ",sq," ",cnt,"\n");
return (inm*cnt/n);
}
computeAns = function(a)
{
pi = 3.141592653589793;
rez = (pi * (a*a)) / 2;
val = c(10000,20000,50000);
for (n in val)
{
ans = vol(a, n);
err = abs(ans - rez);
cat("Volumul este ",ans," pentru esantionul curent\n");
cat("Eroarea relativa pentru n=",n," este ",err,"\n");
}
}
computeAns(2);
#C2
h = function(n)
{
cnt = 0;
for (i in 1:n)
{
x = runif(1,0,1.5);
y = runif(1,0,1);
if ((x-2*y<=0) & (2*x-3*y>=0) & (3*x+2*y<=6))
cnt = cnt + 1;
#cat(x," ",y," ",cnt,"\n");
}
#cat(cnt,"\n");
inm = 1.5 * 1;
return (1.5 * cnt / n);
}
h(10000);
#C3
#a
integrala1 = function()
{
n = 10000;
#ans = ((3*sqrt(3))/8 + 13/24);
ans = 0.8578523861716623;
sum = 0;
for (i in 1:n)
{
x = runif(1,0,pi/3);
s = sin(x);
c = cos(x);
sum = sum + s*s*s + c*c*c;
}
sum = sum*(pi/3) / n;
cat("Valoarea integralei: ",ans,", rezultatul aproximat: ",sum,"\n");
cat("Eroarea absoluta: ", abs(ans-sum),"\n");
}
integrala1();
#b
computeSecondI = function(n)
{
sum = 0;
for (i in 1:n)
{
x = rexp(1,1);
sum = sum + (1/(2*x^2+1))/exp(-x);
}
sum = sum/n;
return (sum);
}
integrala2 = function(n,k)
{
pi = 3.141592653589793;
ans = pi/(2*sqrt(2));
estimate = vector();
for (i in 1:k)
estimate[i] = computeSecondI(n);
sum = mean(estimate);
cat("Valoarea integralei: ",ans,", rezultatul aproximat: ",sum,"\n");
cat("Eroarea absoluta: ", abs(ans-sum),"\n");
}
integrala2(50000,50);
#C5
#Helper function
goodP = function(p)
{
pb = runif(1,0,1);
if (pb <= p)
return (TRUE);
return (FALSE);
}
c5aSimulation = function(p1,p2)
{
days = 1;
pc = vector();
for (i in 1:25)
pc[i] = FALSE;
pc[sample(1:25,1)] = TRUE;
while (TRUE)
{
cnt = sum(pc);
if (cnt == 0)
break;
days = days + 1;
if (goodP(p1) && cnt < 25) # mai infectez unul in ziua curenta
{
now = sample(1:25,1);
while(pc[now] == TRUE)
now = sample(1:25,1);
pc[now] = TRUE;
}
if (goodP(p2)) # curata calculatoare
{
perm = sample(1:25,25,replace = FALSE);
rem = 2;
rm = 0;
if (sum(pc) == 1) rem = 1;
for (i in 1:25)
{
if (pc[perm[i]] == FALSE) next;
if (rm == rem) break;
rm = rm + 1;
pc[perm[i]] = FALSE;
}
}
}
return (days);
}
c5a = function(n, p1, p2)
{
sum = 0;
for (i in 1:n)
{
sum = sum + c5aSimulation(p1,p2);
}
sum = sum / n;
return (sum);
}
c5a(10000,0.25,0.15)
c5bSimulation = function(p1,p2)
{
pc = vector();
for (i in 1:25)
pc[i] = FALSE;
pc[sample(1:25,1)] = TRUE;
while (TRUE)
{
cnt = sum(pc);
if (cnt == 0)
break;
if (goodP(p1) && cnt < 25) # mai infectez unul in ziua curenta
{
now = sample(1:25,1);
while(pc[now] == TRUE)
now = sample(1:25,1);
pc[now] = TRUE;
}
if (sum(pc)>=5)
return (TRUE);
if (goodP(p2)) # curata calculatoare
{
perm = sample(1:25,25,replace = FALSE);
rem = 2;
rm = 0;
if (sum(pc) == 1) rem = 1;
for (i in 1:25)
{
if (pc[perm[i]] == FALSE) next;
if (rm == rem) break;
rm = rm + 1;
pc[perm[i]] = FALSE;
}
}
}
return (FALSE);
}
c5b = function(n,p1,p2)
{
nr = 0;
for (i in 1:n)
{
if (c5bSimulation(p1,p2))
nr = nr + 1;
}
nr = nr / n;
return(nr);
}
c5b(10000,0.25,0.15);
#C7
#Helper function
goodP = function(p)
{
pb = runif(1,0,1);
if (pb <= p)
return (TRUE);
return (FALSE);
}
c7aSimulation = function(p)
{
pc = vector();
once = vector();
for (i in 1:25)
{
pc[i] = FALSE;
once[i] = FALSE;
}
first = sample(1:25,1);
pc[first] = TRUE;
once[first] = TRUE;
while (TRUE)
{
cnt = sum(pc);
if (cnt == 0)
break;
for (i in 1:25)
{
if (pc[i] == TRUE)
next;
if (goodP(p) == TRUE) # este infectat
{
pc[i] = TRUE;
once[i] = TRUE;
}
}
if (sum(once) == 25)
return (TRUE);
rnd = sample(1:25, size = 25);
nr = 0;
for (i in 1:25)
{
if (pc[rnd[i]] == FALSE)
next;
if (nr == 4)
break;
nr = nr + 1;
pc[rnd[i]] = FALSE;
}
}
return (FALSE);
}
c7a = function(n)
{
sum = 0;
for (i in 1:n)
{
if (c7aSimulation(0.3))
sum = sum + 1;
}
sum = sum / n;
return (sum);
}
c7a(3152);
c7bSimulation = function(p)
{
pc = vector();
for (i in 1:25)
pc[i] = FALSE;
pc[sample(1:25,1)] = TRUE;
while (TRUE)
{
cnt = sum(pc);
if (cnt == 0)
break;
for (i in 1:25)
{
if (pc[i] == TRUE)
next;
if (goodP(p) == TRUE) # este infectat
{
pc[i] = TRUE;
cnt= cnt + 1;
}
}
if (cnt == 25)
return (TRUE);
rnd = sample(1:25, size = 25);
nr = 0;
for (i in 1:25)
{
if (pc[rnd[i]] == FALSE)
next;
if (nr == 4)
break;
nr = nr + 1;
pc[rnd[i]] = FALSE;
}
}
return (FALSE);
}
c7b = function(n, p)
{
sum = 0;
for (i in 1:n)
{
if (c7bSimulation(p) == TRUE)
sum = sum + 1;
}
sum = sum / n;
return (sum);
}
c7b(20,0.3)
c7c = function(epsilon, p, p_stelat)
{
alfa = 1 - p;
z = qnorm(alfa/2);
nMin = p_stelat * (1 - p_stelat) * ((z/epsilon)^2);
return (nMin);
}
c7c(0.01,0.99,0.95);
# Exercitii rezolvate, dar pe care nu le prezint
#C4
calculTimpServire = function(n) # pentru un esantion de marime n
{
ans = 0;
for (i in 1:n)
{
ansClientActual = 0;
v1 = rgamma(1,6,4);
v2 = rgamma(1,5,3);
latenta = rexp(1,1);
p = runif(1,0,1);
if (p<=0.35){
ansClientActual = ansClientActual + v1/1000;
}
else {
ansClientActual = ansClientActual + v2/1000;
}
ansClientActual = ansClientActual + latenta;
ans = ans + ansClientActual;
}
return (ans / n);
}
n=50000;
cat("Timpul mediu necesar servirii unui client: ",calculTimpServire(n),"\n");
cat("Aceasta valoare a fost calculata pe un esantion n=",n)
|
# Add a column in between in a matrix
add.rowcol <- function(M, v, index, row=FALSE){
if (row){
M <- rbind(M, v)
M[c(index, nrow(M)), ] <- M[c(nrow(M), index), ]
} else {
M <- cbind(M, v)
M[, c(index, ncol(M))] <- M[, c(ncol(M), index)]
}
return(M)
}
A <- matrix(c(1, 2, 3), 3, 3, bycol=TRUE)
v <- c(0, 0, 0)
add.rowcol(A, v, 2, row=FALSE)
| /exercises/add_rowcol_in_betwen.R | no_license | abhi8893/Intensive-R | R | false | false | 370 | r | # Add a column in between in a matrix
add.rowcol <- function(M, v, index, row=FALSE){
if (row){
M <- rbind(M, v)
M[c(index, nrow(M)), ] <- M[c(nrow(M), index), ]
} else {
M <- cbind(M, v)
M[, c(index, ncol(M))] <- M[, c(ncol(M), index)]
}
return(M)
}
A <- matrix(c(1, 2, 3), 3, 3, bycol=TRUE)
v <- c(0, 0, 0)
add.rowcol(A, v, 2, row=FALSE)
|
# Beware. Here lie meta-tests.
context("test_engine")
library(testthatsomemore)
bag_of_objects <- list(force, 1, NULL, "foo", list(), new.env())
describe("invalid inputs", {
lapply(Filter(Negate(is.character), bag_of_objects), function(object) {
test_that(paste("it fails when test_engine is called with a", class(object)), {
expect_error(test_engine(object), "Please pass a")
})
})
})
describe("missing tests", {
test_that("it fails due to missing tests for the engines1 project", {
expect_error(test_engine("projects/engines1/main"), "Tests are missing")
expect_error(test_engine("projects/engines1/main"), "main_resource")
})
})
describe("missing tests can be overwritten using optional tests", {
test_that("it does not fail due to missing tests for the optional_tests project", {
testthatsomemore::assert(test_engine("projects/optional_tests"))
})
})
describe("passing tests", {
test_that("it passes with a simple example test", {
testthatsomemore::assert(test_engine("projects/test_simple_find"))
})
test_that("it passes with a calculation of pi", {
testthatsomemore::assert(test_engine("projects/test_calculation_pi"))
})
})
describe("failing tests", {
has_failed_test <- function(test_summary) {
any(vapply(test_summary, function(summand) {
any(vapply(summand[[1L]]$results, function(result) {
# The former condition is backwards-compatible with older versions of testthat
identical(result$passed, FALSE) ||
is(result, "expectation_failure")
}, logical(1)))
}, logical(1)))
}
test_that("it fails with a simple example test", {
# TODO: (RK) Prevent test suite reporter mangling.
sink(tempfile()); on.exit(sink())
expect_true(has_failed_test(test_engine("projects/simple_test_failure",
error_on_failure = FALSE)))
})
})
describe("setup hook", {
test_that("it fails with a setup hook failure", {
expect_error(test_engine("projects/test_simple_setup_failure"), "setup test hook failed")
})
})
describe("teardown hook", {
test_that("it fails with a teardown hook failure", {
expect_error(test_engine("projects/test_simple_teardown_failure"), "teardown test hook failed")
})
})
| /tests/testthat/test-engine_tests.R | permissive | Chicago-R-User-Group/2017-n4-Meetup-Syberia | R | false | false | 2,268 | r | # Beware. Here lie meta-tests.
context("test_engine")
library(testthatsomemore)
bag_of_objects <- list(force, 1, NULL, "foo", list(), new.env())
describe("invalid inputs", {
lapply(Filter(Negate(is.character), bag_of_objects), function(object) {
test_that(paste("it fails when test_engine is called with a", class(object)), {
expect_error(test_engine(object), "Please pass a")
})
})
})
describe("missing tests", {
test_that("it fails due to missing tests for the engines1 project", {
expect_error(test_engine("projects/engines1/main"), "Tests are missing")
expect_error(test_engine("projects/engines1/main"), "main_resource")
})
})
describe("missing tests can be overwritten using optional tests", {
test_that("it does not fail due to missing tests for the optional_tests project", {
testthatsomemore::assert(test_engine("projects/optional_tests"))
})
})
describe("passing tests", {
test_that("it passes with a simple example test", {
testthatsomemore::assert(test_engine("projects/test_simple_find"))
})
test_that("it passes with a calculation of pi", {
testthatsomemore::assert(test_engine("projects/test_calculation_pi"))
})
})
describe("failing tests", {
has_failed_test <- function(test_summary) {
any(vapply(test_summary, function(summand) {
any(vapply(summand[[1L]]$results, function(result) {
# The former condition is backwards-compatible with older versions of testthat
identical(result$passed, FALSE) ||
is(result, "expectation_failure")
}, logical(1)))
}, logical(1)))
}
test_that("it fails with a simple example test", {
# TODO: (RK) Prevent test suite reporter mangling.
sink(tempfile()); on.exit(sink())
expect_true(has_failed_test(test_engine("projects/simple_test_failure",
error_on_failure = FALSE)))
})
})
describe("setup hook", {
test_that("it fails with a setup hook failure", {
expect_error(test_engine("projects/test_simple_setup_failure"), "setup test hook failed")
})
})
describe("teardown hook", {
test_that("it fails with a teardown hook failure", {
expect_error(test_engine("projects/test_simple_teardown_failure"), "teardown test hook failed")
})
})
|
% Generated by roxygen2 (4.0.1): do not edit by hand
\name{ipairwise}
\alias{ipairwise}
\title{Iterator that returns elements of an object in pairs}
\usage{
ipairwise(object)
}
\arguments{
\item{object}{an iterable object}
}
\value{
an iterator that returns pairwise elements
}
\description{
Constructs an iterator of an iterable \code{object} that returns its elements
in pairs.
}
\examples{
it <- ipairwise(iterators::iter(letters[1:4]))
iterators::nextElem(it) # list("a", "b")
iterators::nextElem(it) # list("b", "c")
iterators::nextElem(it) # list("c", "d")
it2 <- ipairwise(1:5)
iterators::nextElem(it2) # list(1, 2)
iterators::nextElem(it2) # list(2, 3)
iterators::nextElem(it2) # list(3, 4)
iterators::nextElem(it2) # list(4, 5)
}
| /man/ipairwise.Rd | permissive | cran/itertools2 | R | false | false | 741 | rd | % Generated by roxygen2 (4.0.1): do not edit by hand
\name{ipairwise}
\alias{ipairwise}
\title{Iterator that returns elements of an object in pairs}
\usage{
ipairwise(object)
}
\arguments{
\item{object}{an iterable object}
}
\value{
an iterator that returns pairwise elements
}
\description{
Constructs an iterator of an iterable \code{object} that returns its elements
in pairs.
}
\examples{
it <- ipairwise(iterators::iter(letters[1:4]))
iterators::nextElem(it) # list("a", "b")
iterators::nextElem(it) # list("b", "c")
iterators::nextElem(it) # list("c", "d")
it2 <- ipairwise(1:5)
iterators::nextElem(it2) # list(1, 2)
iterators::nextElem(it2) # list(2, 3)
iterators::nextElem(it2) # list(3, 4)
iterators::nextElem(it2) # list(4, 5)
}
|
library(vanddraabe)
### Name: names.sidechain.atoms
### Title: Sidechain Atom Names
### Aliases: names.sidechain.atoms
### Keywords: datasets
### ** Examples
names.sidechain.atoms
# [1] "CB" "CG" "CD" "NE" "CZ" "NH1" "NH2" "OD1" "ND2" "OD2" "SG"
# "OE1" "NE2" "OE2" "CD2" "ND1" "CE1" "CG1" "CG2" "CD1" "CE" "NZ"
# "SD" "CE2" "OG" "OG1" "NE1" "CE3" "CZ2" "CZ3" "CH2" "OH"
| /data/genthat_extracted_code/vanddraabe/examples/names.sidechain.atoms.Rd.R | no_license | surayaaramli/typeRrh | R | false | false | 403 | r | library(vanddraabe)
### Name: names.sidechain.atoms
### Title: Sidechain Atom Names
### Aliases: names.sidechain.atoms
### Keywords: datasets
### ** Examples
names.sidechain.atoms
# [1] "CB" "CG" "CD" "NE" "CZ" "NH1" "NH2" "OD1" "ND2" "OD2" "SG"
# "OE1" "NE2" "OE2" "CD2" "ND1" "CE1" "CG1" "CG2" "CD1" "CE" "NZ"
# "SD" "CE2" "OG" "OG1" "NE1" "CE3" "CZ2" "CZ3" "CH2" "OH"
|
#' Open dataframe using visidata
#'
#' @export
#' @param dat dataframe to open in visidata
vd <- function(dat) {
file_ext <- ".csv"
serialize_fun <- write.csv
# Prefer to use json over CSV format
if (require("jsonlite")) {
file_ext <- ".json"
serialize_fun <- jsonlite::write_json
}
# R gives us a temporary file
temp_file <- tempfile("dat", fileext = file_ext)
# Write input to the temporary file
serialize_fun(dat, temp_file)
# Check if we should use vd directly or a tmux wrapper
vd_cmd <- get_vd_cmd()
# Invoke visidata
system2(vd_cmd, args = temp_file)
# We do not delete the temporary file, as if tmux is used,
# vd will run asynchronously, and we can't guarantee that it's opened
# the file yet.
# We can rely on R to clean it up when the session ends
invisible(dat)
}
| /R/main.r | permissive | paulklemm/rvisidata | R | false | false | 824 | r | #' Open dataframe using visidata
#'
#' @export
#' @param dat dataframe to open in visidata
vd <- function(dat) {
file_ext <- ".csv"
serialize_fun <- write.csv
# Prefer to use json over CSV format
if (require("jsonlite")) {
file_ext <- ".json"
serialize_fun <- jsonlite::write_json
}
# R gives us a temporary file
temp_file <- tempfile("dat", fileext = file_ext)
# Write input to the temporary file
serialize_fun(dat, temp_file)
# Check if we should use vd directly or a tmux wrapper
vd_cmd <- get_vd_cmd()
# Invoke visidata
system2(vd_cmd, args = temp_file)
# We do not delete the temporary file, as if tmux is used,
# vd will run asynchronously, and we can't guarantee that it's opened
# the file yet.
# We can rely on R to clean it up when the session ends
invisible(dat)
}
|
library(knnIndep)
### Name: power.plot
### Title: Plot power of benchmarked tests of independence
### Aliases: power.plot
### ** Examples
mycor = function(...) cor(...)^2
noises = cbind(c(.3,.4,6),c(.3,.5,4))
colnames(noises) = c("1",".2") #mutual information of the noise levels
vals = run.tests(mycor,list(),1:2,noises,100)
power.cor = drop(calculate.power(vals))
power.plot(list(cor=power.cor),t(noises))
| /data/genthat_extracted_code/knnIndep/examples/power.plot.Rd.R | no_license | surayaaramli/typeRrh | R | false | false | 415 | r | library(knnIndep)
### Name: power.plot
### Title: Plot power of benchmarked tests of independence
### Aliases: power.plot
### ** Examples
mycor = function(...) cor(...)^2
noises = cbind(c(.3,.4,6),c(.3,.5,4))
colnames(noises) = c("1",".2") #mutual information of the noise levels
vals = run.tests(mycor,list(),1:2,noises,100)
power.cor = drop(calculate.power(vals))
power.plot(list(cor=power.cor),t(noises))
|
# Script to import salmon transcript abundance files through DESeq analysis
###### Necessary libraries to run script #######
library(DESeq2)
library(readr)
library(tximport)
#### Directory for abundance files ######
dir1 <- "/Volumes/scRNAseq_1/p1p2p3vsGSE957+CLR2097/"
#### To load sample metadata and search for related salmon files #####
samples <- read.csv(file.path(dir1, "p1p2p3vsGSE113957+CLR2097.csv"), header = TRUE)
files <- file.path(dir1, samples$Well.number,"quant.sf")
#### Annotation from transcripts to genes #####
txdb <- makeTxDbFromGFF("/Volumes/scRNAseq_1/Homo_sapiens/ENSEMBL/Homo_sapiens.GRCh38.95.gtf")
k <- keys(txdb, keytype ="TXNAME")
tx2gene <- select(txdb, k, "GENEID", "TXNAME")
names(files) <- paste0(samples$Well.number, "_sample", 1:151)
all(file.exists(files))
#### Actual importation step ####
txi <- tximport(files, type = "salmon", tx2gene = tx2gene, ignoreTxVersion = TRUE)
ddsTxi <- DESeqDataSetFromTximport(txi,colData = samples, design = ~ Condition)
#### Runs DESeq and saves results as res ######
dds <- DESeq(ddsTxi)
res <- results(dds)
res
write.csv(res, file = "/Volumes/scRNAseq_1/p1p2p3vsGSE957+CLR2097/Analysis/deseq_full.csv")
| /Scripts/tximport_DEseq_p1p2p3vsGSE957+CLR2097.R | no_license | boeydaryl/scRNAseq-analysis-for-understanding-alternative-pathways-in-Pompe-Disease | R | false | false | 1,183 | r | # Script to import salmon transcript abundance files through DESeq analysis
###### Necessary libraries to run script #######
library(DESeq2)
library(readr)
library(tximport)
#### Directory for abundance files ######
dir1 <- "/Volumes/scRNAseq_1/p1p2p3vsGSE957+CLR2097/"
#### To load sample metadata and search for related salmon files #####
samples <- read.csv(file.path(dir1, "p1p2p3vsGSE113957+CLR2097.csv"), header = TRUE)
files <- file.path(dir1, samples$Well.number,"quant.sf")
#### Annotation from transcripts to genes #####
txdb <- makeTxDbFromGFF("/Volumes/scRNAseq_1/Homo_sapiens/ENSEMBL/Homo_sapiens.GRCh38.95.gtf")
k <- keys(txdb, keytype ="TXNAME")
tx2gene <- select(txdb, k, "GENEID", "TXNAME")
names(files) <- paste0(samples$Well.number, "_sample", 1:151)
all(file.exists(files))
#### Actual importation step ####
txi <- tximport(files, type = "salmon", tx2gene = tx2gene, ignoreTxVersion = TRUE)
ddsTxi <- DESeqDataSetFromTximport(txi,colData = samples, design = ~ Condition)
#### Runs DESeq and saves results as res ######
dds <- DESeq(ddsTxi)
res <- results(dds)
res
write.csv(res, file = "/Volumes/scRNAseq_1/p1p2p3vsGSE957+CLR2097/Analysis/deseq_full.csv")
|
## Put comments here that give an overall description of what your
## functions do
# the functions cache's the inverse and calculates the inverse of a square matrix
## Write a short comment describing this function
# makeCacheMatrix: creates a special "matrix" object that can cache its inverse
makeCacheMatrix <- function(x = matrix()) {
m <- NULL
set <- function(y) {
x <<- y
m <<- NULL
}
get <- function() x
setmatrix <- function(solve) m <<- solve
getmatrix <- function() m
list(set = set, get = get,
setmatrix = setmatrix,
getmatrix = getmatrix)
}
## Write a short comment describing this function
# cacheSolve: computes the inverse of the special "matrix" returned by makeCacheMatrix
cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
m <- x$getmatrix()
if(!is.null(m)) {
message("getting cached data")
return(m)
}
data <- x$get()
m <- solve(data, ...)
x$setmatrix(m)
m
}
| /cachematrix.R | no_license | Capa04/ProgrammingAssignment2 | R | false | false | 1,025 | r | ## Put comments here that give an overall description of what your
## functions do
# the functions cache's the inverse and calculates the inverse of a square matrix
## Write a short comment describing this function
# makeCacheMatrix: creates a special "matrix" object that can cache its inverse
makeCacheMatrix <- function(x = matrix()) {
m <- NULL
set <- function(y) {
x <<- y
m <<- NULL
}
get <- function() x
setmatrix <- function(solve) m <<- solve
getmatrix <- function() m
list(set = set, get = get,
setmatrix = setmatrix,
getmatrix = getmatrix)
}
## Write a short comment describing this function
# cacheSolve: computes the inverse of the special "matrix" returned by makeCacheMatrix
cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
m <- x$getmatrix()
if(!is.null(m)) {
message("getting cached data")
return(m)
}
data <- x$get()
m <- solve(data, ...)
x$setmatrix(m)
m
}
|
#cleaning environnement
rm(list=objects())
# STEP 1
# Merges the training and the test sets to create one data set.
# set the working directory where the dataset reside (change it accordingly)
setwd("~/Documents/polasoft/R/datascience/project/UCI HAR Dataset")
# loading each set of data
X1 = read.table("train/X_train.txt",colClasses="numeric")
X2 = read.table("test/X_test.txt",colClasses="numeric")
# merging
X = rbind(X1,X2)
#removing unneeded variables
rm(X1,X2)
# idem for activities
y1 = read.table("train/y_train.txt",colClasses="numeric")
y2 = read.table("test/y_test.txt",colClasses="numeric")
y = rbind(y1,y2)
rm(y1,y2)
# idem for subjects
S1 = read.table("train/subject_train.txt",colClasses="numeric")
S2 = read.table("test/subject_test.txt",colClasses="numeric")
S = rbind(S1,S2)
names(S)<-'Subject'
rm(S1,S2)
# STEP 2
# Extracts only the measurements on the mean and standard deviation for each measurement
# Searching for '-mean(' or '-std(' in the features names
features = read.table("features.txt",colClasses=c("numeric","character"))
# get the indices
indices = grep("/*-std\\(|-mean\\(",features[,'V2'],perl=TRUE)
extracted = X[,indices]
rm(X);
# STEP 3
# Uses descriptive activity names to name the activities in the data set
activities = read.table("activity_labels.txt",colClasses=c("numeric","character"))
activityNames = factor(activities[,'V2'],levels=activities[,'V2'])
namedY = factor(y$V1)
levels(namedY)=levels(activityNames)
# adding activities and subjects to the main data set
X = cbind(S,namedY,extracted)
rm(S,namedY,extracted)
# STEP 4
# Appropriately labels the data set with descriptive variable names.
labels = grep("/*-std\\(|-mean\\(",features[,'V2'],perl=TRUE,value=TRUE)
names(X)<-c('Subject','Activity',labels)
# STEP 5
# From the data set in step 4, creates a second, independent tidy data set with the
# average of each variable for each activity and each subject.
# with the help from the site at:
# https://github.com/dgrapov/TeachingDemos/blob/master/Demos/dplyr/hands_on_with_dplyr.md
library(dplyr)
XAvrg <- group_by(X,Subject,Activity) %>%
select(one_of(labels)) %>%
summarise_each(funs(mean(.,na.rm=TRUE)))
# writing the text file to upload in the current working dir
write.table(XAvrg,"XAvrg.txt",row.names=FALSE)
| /Getting and Cleaning Data/run_analysis.R | no_license | Polatouche/datasciencecoursera | R | false | false | 2,302 | r | #cleaning environnement
rm(list=objects())
# STEP 1
# Merges the training and the test sets to create one data set.
# set the working directory where the dataset reside (change it accordingly)
setwd("~/Documents/polasoft/R/datascience/project/UCI HAR Dataset")
# loading each set of data
X1 = read.table("train/X_train.txt",colClasses="numeric")
X2 = read.table("test/X_test.txt",colClasses="numeric")
# merging
X = rbind(X1,X2)
#removing unneeded variables
rm(X1,X2)
# idem for activities
y1 = read.table("train/y_train.txt",colClasses="numeric")
y2 = read.table("test/y_test.txt",colClasses="numeric")
y = rbind(y1,y2)
rm(y1,y2)
# idem for subjects
S1 = read.table("train/subject_train.txt",colClasses="numeric")
S2 = read.table("test/subject_test.txt",colClasses="numeric")
S = rbind(S1,S2)
names(S)<-'Subject'
rm(S1,S2)
# STEP 2
# Extracts only the measurements on the mean and standard deviation for each measurement
# Searching for '-mean(' or '-std(' in the features names
features = read.table("features.txt",colClasses=c("numeric","character"))
# get the indices
indices = grep("/*-std\\(|-mean\\(",features[,'V2'],perl=TRUE)
extracted = X[,indices]
rm(X);
# STEP 3
# Uses descriptive activity names to name the activities in the data set
activities = read.table("activity_labels.txt",colClasses=c("numeric","character"))
activityNames = factor(activities[,'V2'],levels=activities[,'V2'])
namedY = factor(y$V1)
levels(namedY)=levels(activityNames)
# adding activities and subjects to the main data set
X = cbind(S,namedY,extracted)
rm(S,namedY,extracted)
# STEP 4
# Appropriately labels the data set with descriptive variable names.
labels = grep("/*-std\\(|-mean\\(",features[,'V2'],perl=TRUE,value=TRUE)
names(X)<-c('Subject','Activity',labels)
# STEP 5
# From the data set in step 4, creates a second, independent tidy data set with the
# average of each variable for each activity and each subject.
# with the help from the site at:
# https://github.com/dgrapov/TeachingDemos/blob/master/Demos/dplyr/hands_on_with_dplyr.md
library(dplyr)
XAvrg <- group_by(X,Subject,Activity) %>%
select(one_of(labels)) %>%
summarise_each(funs(mean(.,na.rm=TRUE)))
# writing the text file to upload in the current working dir
write.table(XAvrg,"XAvrg.txt",row.names=FALSE)
|
library(zoo)
library(grid)
library(scales)
library(xtable)
library(ggplot2)
library(gridExtra)
library(data.table)
setwd("~/Desktop/CSML/project/msc-project/uk_web_application")
##--------------------- Find unique fraction of URLs that the crawler got
## UK reward URLs (451)
dt_reward <- data.table(read.csv("../rl_toy_implementation/new_data/company_urls.csv"))
dt_reward$domain <- sapply(dt_reward$url, function(x) sub("www.","", x))
dt_reward$domain <- sapply(dt_reward$domain, function(x) sub("http://","", x))
dt_reward$domain <- sapply(dt_reward$domain, function(x) sub("https://","", x))
dt_reward <- dt_reward[grepl(".uk", url)]
setkey(dt_reward, "domain")
## Held out UK reward URLs (1422)
df_reward_ho <- data.table(read.csv("../data/domains_clean.csv"))
df_reward_ho <- subset(df_reward_ho, select=c('vert_code', 'url'))
df_reward_ho <- df_reward_ho[vert_code <= 69203 & vert_code >= 69101]
df_reward_ho <- df_reward_ho[complete.cases(df_reward)]
dt_reward_ho <- data.table(df_reward_ho)
dt_reward_ho$domain <- sapply(dt_reward_ho$url, function(x) sub("www.","", x))
dt_reward_ho$domain <- sapply(dt_reward_ho$domain, function(x) sub("http://","", x))
dt_reward_ho$domain <- sapply(dt_reward_ho$domain, function(x) sub("https://","", x))
dt_reward_ho <- dt_reward_ho[grepl('.uk', url)]
setkey(dt_reward_ho, "domain")
dt_reward_ho <- merge(dt_reward_ho, dt_reward, all.x=TRUE) # left join the data tables
dt_reward_ho <- dt_reward_ho[is.na(url.y)]
dt_reward_ho <- subset(dt_reward_ho, select=c(domain, url.x))
setnames(dt_reward_ho, 'url.x', 'url')
## File paths
path_ending <- "all_urls.csv"
results_datatable <- function(folder, filename) {
df <- data.table(read.csv(paste0(folder, filename), header=FALSE))
if (grepl("classifier", folder) | grepl("async", folder) | grepl("random", folder))
names(df) <- c('url', 'reward', 'is_terminal', 'run')
else
names(df) <- c('url', 'reward', 'is_terminal', 'run')
df$step <- 1:nrow(df)
df$domain <- sapply(df$url, function(x) sub("/.*$","", x))
df$domain <- sapply(df$domain, function(x) sub("www.","", x))
df$domain <- sapply(df$domain, function(x) sub("http://","", x))
df$domain <- sapply(df$domain, function(x) sub("https://","", x))
df[grepl("}", df$domain)]$domain <- ""
df <- merge(df, dt_reward, by="domain", all.x=TRUE)
df[is.na(url.y)]$reward <- 0
df <- subset(df, select=-c(url.y))
setkey(df, step)
unique_rewards <- subset(df[reward==1], select=c(step, domain))
unique_rewards <- unique_rewards[!duplicated(subset(unique_rewards, select=domain))]
unique_rewards$unique_reward_count <- 1:nrow(unique_rewards)
unique_rewards$domain <- NULL
setkey(unique_rewards, step)
df <- merge(df, unique_rewards, all.x=TRUE)
df[1]$unique_reward_count <- ifelse(is.na(df[1]$unique_reward_count), 0, 1)
df$unique_reward_count <- na.locf(df$unique_reward_count)
df$cum_reward <- cumsum(df$reward)
return(df)
}
r_all_urls <- results_datatable("results/random_results/", 'all_urls_1m.csv')
r_all_urls$type <- "Random"
async <- results_datatable("results/async/", "all_urls_1m.csv")
async$type <- "Async"
async$loss <- NA
## Combine and plot unique rewards
results <- rbind(async, r_all_urls)
g_uniq <- ggplot(data=results, aes(x=step, y=unique_reward_count, color=type))
g_uniq <- g_uniq + geom_line(size=0.9) + labs(x='Pages Crawled', y='Unique Rewards', color="")
g_uniq <- g_uniq + theme(legend.position="top")
g_uniq <- g_uniq + scale_x_continuous(labels=comma) + scale_y_continuous()
g_uniq
## Number of held out rewards
length(intersect(dt_reward_ho$domain, unique(async[reward!=1]$domain))) # async
length(intersect(dt_reward_ho$domain, unique(r_all_urls[reward!=1]$domain))) # random
##------------------- Multiple runs performance plots
multiple_runs_datatable2 <- function(folder, filename) {
df <- data.table(read.csv(paste0(folder, filename), header=FALSE))
names(df) <- c('url', 'reward', 'is_terminal', 'run')
df$step <- c(1:200000, 1:200000, 1:200000, 1:200000, 1:200000)
df$domain <- sapply(df$url, function(x) sub("/.*$","", x))
df$domain <- sapply(df$domain, function(x) sub("www.","", x))
df$domain <- sapply(df$domain, function(x) sub("http://","", x))
df$domain <- sapply(df$domain, function(x) sub("https://","", x))
df[grepl("}", df$domain)]$domain <- ""
df <- merge(df, dt_reward, by="domain", all.x=TRUE)
df[is.na(url.y)]$reward <- 0
df <- subset(df, select=-c(url.y))
setkeyv(df, c('step', 'run'))
unique_rewards <- subset(df[reward==1], select=c(step, domain, run))
unique_rewards <- unique_rewards[!duplicated(subset(unique_rewards, select=c(domain, run)))]
unique_rewards$simple_count <- 1
unique_rewards$unique_reward_count <- with(unique_rewards, ave(simple_count, simple_count, run, FUN=seq_along))
unique_rewards$domain <- NULL
unique_rewards$simple_count <- NULL
setkeyv(unique_rewards, c('step', 'run'))
df <- merge(df, unique_rewards, all.x=TRUE)
df[step==1]$unique_reward_count <- ifelse(is.na(df[step==1]$unique_reward_count), 0, 1)
df <- df[, unique_r_count := na.locf(unique_reward_count), by=run]
plot_df <- subset(df, select=c(step, run, unique_r_count))
plot_df <- plot_df[, mean_reward := mean(unique_r_count), by=step]
plot_df <- plot_df[, min_reward := min(unique_r_count), by=step]
plot_df <- plot_df[, max_reward := max(unique_r_count), by=step]
plot_df <- plot_df[, stdev := sd(unique_r_count), by=step]
print(paste0(folder, filename))
print(mean(plot_df[step == max(plot_df$step)]$unique_r_count))
print(sd(plot_df[step == max(plot_df$step)]$unique_r_count))
plot_df <- unique(subset(plot_df, select=c(step, mean_reward, min_reward, max_reward, stdev)))
return(plot_df)
}
uk_random_urls <- multiple_runs_datatable2("results/random_results/", 'avg_all_urls.csv')
uk_random_urls$type <- "Random"
uk_async_urls <- multiple_runs_datatable2("results/async/", 'avg_all_urls.csv')
uk_async_urls$type <- "Async"
#
plot_df <- rbind(uk_async_urls, uk_random_urls)
g <- ggplot(data=plot_df, aes(x=step, y=mean_reward, color=type)) + geom_line(size=0.9)
g <- g + geom_ribbon(aes(ymin=min_reward, ymax=max_reward, fill=type), alpha=0.35, color=NA)
g <- g + labs(x='Pages Crawled', y='Unique Rewards Found', color='')
g <- g + theme(legend.position="top") + guides(fill=FALSE)
g <- g + scale_x_continuous(label=comma)
g
## Mean held-out rewards
mean_ho_rewards <- function(path) {
df <- data.table(read.csv(path, header=FALSE))
names(df) <- c('url', 'reward', 'is_terminal', 'run')
df$domain <- sapply(df$url, function(x) sub("/.*$","", x))
df$domain <- sapply(df$domain, function(x) sub("www.","", x))
df$domain <- sapply(df$domain, function(x) sub("http://","", x))
df$domain <- sapply(df$domain, function(x) sub("https://","", x))
df[grepl("}", df$domain)]$domain <- ""
df <- subset(df[reward!=1], select=-c(reward, is_terminal, url))
df <- unique(df[domain %in% dt_reward_ho$domain])
df <- df[, count:=.N, by=run]
print(mean(unique(df$count)))
}
mean_ho_rewards('results/async/avg_all_urls.csv') # async
mean_ho_rewards('results/random_results/avg_all_urls.csv') # random
##-------------------- Distribution of number of links in the web graph
uk_web_links <- data.table(read.csv("../uk_web_application/building_data/test_results/uk_links.csv"))
# rl_web_links <- rl_web_links[num_links<=500]
g_uk_links <- ggplot(data=uk_web_links, aes(x=num_links)) + geom_histogram(color='firebrick', fill='lightblue')
g_uk_links <- g_uk_links + labs(x='Number of Outgoing Links', y='Count')
g_uk_links
summary(uk_web_links$num_links)
##-------------------- Results on full UK web
uk_random <- results_datatable("../uk_web_application/results/random_results/", "all_urls.csv")
uk_random$type <- "Random"
uk_random$is_terminal <- NA; uk_random$loss <- NA
# ##Combine and plot rewards
# uk_results_df <- rbind(async, classifier_urls, embedding, r_all_urls)
## Combine and plot unique rewards
g_uk <- ggplot(data=uk_random, aes(x=step, y=unique_reward_count, color=type))
g_uk <- g_uk + geom_line(size=0.9) + labs(x='Pages Crawled', y='Unique Rewards', color="")
g_uk <- g_uk + theme(legend.position="top")
g_uk <- g_uk + scale_x_continuous(labels=comma) + scale_y_continuous()
g_uk <- g_uk + guides(color=guide_legend(nrow=2,byrow=TRUE))
g_uk | /uk_web_application/uk_plot_results.R | no_license | dannyfriar/msc-project | R | false | false | 8,295 | r | library(zoo)
library(grid)
library(scales)
library(xtable)
library(ggplot2)
library(gridExtra)
library(data.table)
setwd("~/Desktop/CSML/project/msc-project/uk_web_application")
##--------------------- Find unique fraction of URLs that the crawler got
## UK reward URLs (451)
dt_reward <- data.table(read.csv("../rl_toy_implementation/new_data/company_urls.csv"))
dt_reward$domain <- sapply(dt_reward$url, function(x) sub("www.","", x))
dt_reward$domain <- sapply(dt_reward$domain, function(x) sub("http://","", x))
dt_reward$domain <- sapply(dt_reward$domain, function(x) sub("https://","", x))
dt_reward <- dt_reward[grepl(".uk", url)]
setkey(dt_reward, "domain")
## Held out UK reward URLs (1422)
df_reward_ho <- data.table(read.csv("../data/domains_clean.csv"))
df_reward_ho <- subset(df_reward_ho, select=c('vert_code', 'url'))
df_reward_ho <- df_reward_ho[vert_code <= 69203 & vert_code >= 69101]
df_reward_ho <- df_reward_ho[complete.cases(df_reward)]
dt_reward_ho <- data.table(df_reward_ho)
dt_reward_ho$domain <- sapply(dt_reward_ho$url, function(x) sub("www.","", x))
dt_reward_ho$domain <- sapply(dt_reward_ho$domain, function(x) sub("http://","", x))
dt_reward_ho$domain <- sapply(dt_reward_ho$domain, function(x) sub("https://","", x))
dt_reward_ho <- dt_reward_ho[grepl('.uk', url)]
setkey(dt_reward_ho, "domain")
dt_reward_ho <- merge(dt_reward_ho, dt_reward, all.x=TRUE) # left join the data tables
dt_reward_ho <- dt_reward_ho[is.na(url.y)]
dt_reward_ho <- subset(dt_reward_ho, select=c(domain, url.x))
setnames(dt_reward_ho, 'url.x', 'url')
## File paths
path_ending <- "all_urls.csv"
results_datatable <- function(folder, filename) {
df <- data.table(read.csv(paste0(folder, filename), header=FALSE))
if (grepl("classifier", folder) | grepl("async", folder) | grepl("random", folder))
names(df) <- c('url', 'reward', 'is_terminal', 'run')
else
names(df) <- c('url', 'reward', 'is_terminal', 'run')
df$step <- 1:nrow(df)
df$domain <- sapply(df$url, function(x) sub("/.*$","", x))
df$domain <- sapply(df$domain, function(x) sub("www.","", x))
df$domain <- sapply(df$domain, function(x) sub("http://","", x))
df$domain <- sapply(df$domain, function(x) sub("https://","", x))
df[grepl("}", df$domain)]$domain <- ""
df <- merge(df, dt_reward, by="domain", all.x=TRUE)
df[is.na(url.y)]$reward <- 0
df <- subset(df, select=-c(url.y))
setkey(df, step)
unique_rewards <- subset(df[reward==1], select=c(step, domain))
unique_rewards <- unique_rewards[!duplicated(subset(unique_rewards, select=domain))]
unique_rewards$unique_reward_count <- 1:nrow(unique_rewards)
unique_rewards$domain <- NULL
setkey(unique_rewards, step)
df <- merge(df, unique_rewards, all.x=TRUE)
df[1]$unique_reward_count <- ifelse(is.na(df[1]$unique_reward_count), 0, 1)
df$unique_reward_count <- na.locf(df$unique_reward_count)
df$cum_reward <- cumsum(df$reward)
return(df)
}
r_all_urls <- results_datatable("results/random_results/", 'all_urls_1m.csv')
r_all_urls$type <- "Random"
async <- results_datatable("results/async/", "all_urls_1m.csv")
async$type <- "Async"
async$loss <- NA
## Combine and plot unique rewards
results <- rbind(async, r_all_urls)
g_uniq <- ggplot(data=results, aes(x=step, y=unique_reward_count, color=type))
g_uniq <- g_uniq + geom_line(size=0.9) + labs(x='Pages Crawled', y='Unique Rewards', color="")
g_uniq <- g_uniq + theme(legend.position="top")
g_uniq <- g_uniq + scale_x_continuous(labels=comma) + scale_y_continuous()
g_uniq
## Number of held out rewards
length(intersect(dt_reward_ho$domain, unique(async[reward!=1]$domain))) # async
length(intersect(dt_reward_ho$domain, unique(r_all_urls[reward!=1]$domain))) # random
##------------------- Multiple runs performance plots
multiple_runs_datatable2 <- function(folder, filename) {
df <- data.table(read.csv(paste0(folder, filename), header=FALSE))
names(df) <- c('url', 'reward', 'is_terminal', 'run')
df$step <- c(1:200000, 1:200000, 1:200000, 1:200000, 1:200000)
df$domain <- sapply(df$url, function(x) sub("/.*$","", x))
df$domain <- sapply(df$domain, function(x) sub("www.","", x))
df$domain <- sapply(df$domain, function(x) sub("http://","", x))
df$domain <- sapply(df$domain, function(x) sub("https://","", x))
df[grepl("}", df$domain)]$domain <- ""
df <- merge(df, dt_reward, by="domain", all.x=TRUE)
df[is.na(url.y)]$reward <- 0
df <- subset(df, select=-c(url.y))
setkeyv(df, c('step', 'run'))
unique_rewards <- subset(df[reward==1], select=c(step, domain, run))
unique_rewards <- unique_rewards[!duplicated(subset(unique_rewards, select=c(domain, run)))]
unique_rewards$simple_count <- 1
unique_rewards$unique_reward_count <- with(unique_rewards, ave(simple_count, simple_count, run, FUN=seq_along))
unique_rewards$domain <- NULL
unique_rewards$simple_count <- NULL
setkeyv(unique_rewards, c('step', 'run'))
df <- merge(df, unique_rewards, all.x=TRUE)
df[step==1]$unique_reward_count <- ifelse(is.na(df[step==1]$unique_reward_count), 0, 1)
df <- df[, unique_r_count := na.locf(unique_reward_count), by=run]
plot_df <- subset(df, select=c(step, run, unique_r_count))
plot_df <- plot_df[, mean_reward := mean(unique_r_count), by=step]
plot_df <- plot_df[, min_reward := min(unique_r_count), by=step]
plot_df <- plot_df[, max_reward := max(unique_r_count), by=step]
plot_df <- plot_df[, stdev := sd(unique_r_count), by=step]
print(paste0(folder, filename))
print(mean(plot_df[step == max(plot_df$step)]$unique_r_count))
print(sd(plot_df[step == max(plot_df$step)]$unique_r_count))
plot_df <- unique(subset(plot_df, select=c(step, mean_reward, min_reward, max_reward, stdev)))
return(plot_df)
}
uk_random_urls <- multiple_runs_datatable2("results/random_results/", 'avg_all_urls.csv')
uk_random_urls$type <- "Random"
uk_async_urls <- multiple_runs_datatable2("results/async/", 'avg_all_urls.csv')
uk_async_urls$type <- "Async"
#
plot_df <- rbind(uk_async_urls, uk_random_urls)
g <- ggplot(data=plot_df, aes(x=step, y=mean_reward, color=type)) + geom_line(size=0.9)
g <- g + geom_ribbon(aes(ymin=min_reward, ymax=max_reward, fill=type), alpha=0.35, color=NA)
g <- g + labs(x='Pages Crawled', y='Unique Rewards Found', color='')
g <- g + theme(legend.position="top") + guides(fill=FALSE)
g <- g + scale_x_continuous(label=comma)
g
## Mean held-out rewards
mean_ho_rewards <- function(path) {
df <- data.table(read.csv(path, header=FALSE))
names(df) <- c('url', 'reward', 'is_terminal', 'run')
df$domain <- sapply(df$url, function(x) sub("/.*$","", x))
df$domain <- sapply(df$domain, function(x) sub("www.","", x))
df$domain <- sapply(df$domain, function(x) sub("http://","", x))
df$domain <- sapply(df$domain, function(x) sub("https://","", x))
df[grepl("}", df$domain)]$domain <- ""
df <- subset(df[reward!=1], select=-c(reward, is_terminal, url))
df <- unique(df[domain %in% dt_reward_ho$domain])
df <- df[, count:=.N, by=run]
print(mean(unique(df$count)))
}
mean_ho_rewards('results/async/avg_all_urls.csv') # async
mean_ho_rewards('results/random_results/avg_all_urls.csv') # random
##-------------------- Distribution of number of links in the web graph
uk_web_links <- data.table(read.csv("../uk_web_application/building_data/test_results/uk_links.csv"))
# rl_web_links <- rl_web_links[num_links<=500]
g_uk_links <- ggplot(data=uk_web_links, aes(x=num_links)) + geom_histogram(color='firebrick', fill='lightblue')
g_uk_links <- g_uk_links + labs(x='Number of Outgoing Links', y='Count')
g_uk_links
summary(uk_web_links$num_links)
##-------------------- Results on full UK web
uk_random <- results_datatable("../uk_web_application/results/random_results/", "all_urls.csv")
uk_random$type <- "Random"
uk_random$is_terminal <- NA; uk_random$loss <- NA
# ##Combine and plot rewards
# uk_results_df <- rbind(async, classifier_urls, embedding, r_all_urls)
## Combine and plot unique rewards
g_uk <- ggplot(data=uk_random, aes(x=step, y=unique_reward_count, color=type))
g_uk <- g_uk + geom_line(size=0.9) + labs(x='Pages Crawled', y='Unique Rewards', color="")
g_uk <- g_uk + theme(legend.position="top")
g_uk <- g_uk + scale_x_continuous(labels=comma) + scale_y_continuous()
g_uk <- g_uk + guides(color=guide_legend(nrow=2,byrow=TRUE))
g_uk |
library(testthat)
library(testpckg1337)
# test for hello()
expect_equal(hello(), "Hello, world!")
# tests for hello.name()
expect_equal(hello.name("Ann"), "Hello, Ann!")
expect_equal(hello.name("Christian"), "Hello, Christian!")
expect_error(hello.name(1337))
| /tests/tests.R | no_license | MW89/testpckg1337 | R | false | false | 262 | r | library(testthat)
library(testpckg1337)
# test for hello()
expect_equal(hello(), "Hello, world!")
# tests for hello.name()
expect_equal(hello.name("Ann"), "Hello, Ann!")
expect_equal(hello.name("Christian"), "Hello, Christian!")
expect_error(hello.name(1337))
|
#' mlgt: Multi-locus geno-typing
#'
#' \tabular{ll}{
#' Package: \tab mlgt\cr
#' Type: \tab Package\cr
#' Version: \tab 0.18\cr
#' Date: \tab 2012-10-02\cr
#' Author: \tab Dave T. Gerrard <david.gerrard@@manchester.ac.uk>\cr
#' License: \tab GPL (>= 2)\cr
#' LazyLoad: \tab yes\cr
#' }
#'
#' mlgt sorts a batch of sequence by barcode and identity to
#' templates. It makes use of external applications BLAST and
#' MUSCLE. Genotypes are called and alleles can be compared
#' to a reference list of sequences.
#' More information about each function can be found in
#' its help documentation.
#'
#' Some text
#'
#' The main functions are:
#' \code{\link{prepareMlgtRun}}, \code{\link{mlgt}},
#' \code{\link{callGenotypes}}, \code{\link{createKnownAlleleList}},
#'
#' ...
#'
#' @references BLAST - Altschul, S. F., W. Gish, W. Miller, E. W. Myers, and D. J. Lipman (1990). Basic local alignment search tool. Journal of molecular biology 215 (3), 403-410.
#' @references MUSCLE - Robert C. Edgar (2004) MUSCLE: multiple sequence alignment with high accuracy and high throughput. Nucleic Acids Research 32(5), 1792-97.
#' @references IMGT/HLA database - Robinson J, Mistry K, McWilliam H, Lopez R, Parham P, Marsh SGE (2011) The IMGT/HLA Database. Nucleic Acids Research 39 Suppl 1:D1171-6
#' @import seqinr
#' @docType package
#' @name mlgt-package
NULL
# require(seqinr)
# n/b @ slot not currently recognised by roxygen.
# wanted reference to be of SeqFastadna, but unrecognised even with seqinr loaded.
#' An S4 class to hold all unique variants found/known for a marker.
#'
#' @slot reference
#' @slot variantSource
#' @slot variantMap
#' @slot inputVariantCount
#' @slot uniqueSubVariantCount
setClass("variantMap", representation(reference='ANY', variantSource='character',variantMap='list',
inputVariantCount='integer', uniqueSubVariantCount='integer'))
setClass("varCount",
representation(
rawTotal="numeric",
rawUniqueCount ="numeric",
usedRawTotal="numeric",
usedRawUniqueCount="numeric",
subAlignTotal="numeric",
subAlignUniqueCount="numeric",
varCountTable="data.frame"
)
)
#' Create \code{\link{variantMap}} object from allele alignment
#'
#' Create a \code{\link{variantMap}} object to store known alleles for a marker
#'
#' To compare variants produced using \code{\link{mlgt}} the sequences of the known
#' alleles must be aligned to the same marker used to find the variants.
#' The resulting sub-sequence alignment may have identical sequences for different
#' alleles. If that happens, those alleles are condensed into one and their names
#' concatenated.
#' User can supply files with marker sequences pre-aligned to the reference alleles.
#'
#' @param markerName A specific marker name
#' @param markerSeq something
#' @param alignedAlleleFile a sequence alignment
#' @param alignFormat the format of alignedAlleleFile. "msf" (the default) or "fasta"
#' @param sourceName A character string to record the source of the alignment. Defaults to
#' the value of alignedAlleleFile
#' @param userAlignment The specified 'alignedAlleleFile' already includes the marker sequence. Default = FALSE.
#'
#' @return a \code{\link{variantMap}} object named by markerName
#'
#' @export
#' @docType methods
createKnownAlleleList <- function(markerName, markerSeq, alignedAlleleFile, alignFormat="msf", sourceName=alignedAlleleFile, userAlignment=FALSE) {
## The aligned alleles must have unique names and the markerName must be different too. TODO: test for this.
## DONE put default input file format (MSF). Make check for fasta format (can skip first part if already fasta).
## clean up (remove) files. This function probably doesn't need to keep any files
## Use defined class for return object giving marker sequence used as reference.
#alignedAlleles <- read.msf(alignedAlleleFile)
musclePath <- Sys.getenv("MUSCLE_PATH")
if(nchar(musclePath) < 1) {
stop(paste("MUSCLE_PATH","has not been set!"))
}
switch(alignFormat,
"msf" = {
alignedAlleles <- read.alignment(alignedAlleleFile, format="msf")
alignedAlleleFastaFile <- paste(markerName, "alignedAlleles.fasta", sep=".")
write.fasta(alignedAlleles[[3]], alignedAlleles[[2]], file.out=alignedAlleleFastaFile)
},
"fasta" = {
alignedAlleleFastaFile = alignedAlleleFile
},
stop("Unrecognised alignment file format\n")
)
if(userAlignment) { # user supplied alignment
markerToAlleleDbAlign <- alignedAlleleFastaFile
} else { # align the marker to the aligned alleles.
markerSeqFile <- paste(markerName, "markerSeq.fasta", sep=".")
write.fasta(markerSeq, markerName, file.out=markerSeqFile )
#muscle -profile -in1 existing_aln.afa -in2 new_seq.fa -out combined.afa
markerToAlleleDbAlign <- paste(markerName, "allignedToAlleles.fasta", sep=".")
# profile alignment of marker to existing allele alignment
muscleCommand <- paste(musclePath, "-quiet -profile -in1", alignedAlleleFastaFile, "-in2", markerSeqFile, "-out" ,markerToAlleleDbAlign )
system(muscleCommand)
}
### this section copied from getSubSeqsTable() Could be recoded as function?
# Extract portion corresponding to reference.
rawAlignment <- read.fasta(markerToAlleleDbAlign , as.string=T) # do not use read.alignment() - broken
alignedMarkerSeq <- s2c(rawAlignment[[markerName]])
#alignedMarkerSeq <- s2c(rawAlignment[[thisMarker]]) # was this a bug?
subStart <- min(grep("-",alignedMarkerSeq ,invert=T))
subEnd <- max(grep("-",alignedMarkerSeq ,invert=T))
alignedSubSeqs <- lapply(rawAlignment, FUN=function(x) substr(x[1], subStart, subEnd))
alignedSubTable <- data.frame(name=names(alignedSubSeqs ) , subSeq.aligned= as.character(unlist(alignedSubSeqs )))
alignedSubTable$subSeq.stripped <- gsub("-", "",alignedSubTable$subSeq.aligned )
# remove marker sequence from allele subalignment list.
alignedSubTable <- subset(alignedSubTable, name != markerName)
# TODO: 2 issues here. 1. concatentated allele name lists get truncated at 500 chars (probably by newline insertion).
# 2. blast is not returning the full name.
# HLA_A2 central region has 213 alleles all identical. The concatentated sequence IDs are 2030 chars long.
# Could try using an '_' as this might prevent word boundary splitting in one or both cases.
# Solves the first problem but still cannot blast with this. Need to also adjust blast usage.
alleleMap <- split(as.character(alignedSubTable$name), alignedSubTable$subSeq.stripped) # group allele nams sharing a common sequence.
##alleleMap <- paste(unlist(split(as.character(alignedSubTable$name), alignedSubTable$subSeq.stripped)),collapse="|")
# TODO: THis next line is what I want to do but it makes BLASTALL crash. Something to do with long sequence IDs in fasta files?
alleleMap <- lapply(alleleMap, FUN=function(x) paste(x,collapse="_")) # do not use '|' or '*' or ':'
#if(remTempFiles) {
# file.remove(markerSeqFile)
#}
#return(list(reference=as.SeqFastadna(markerSeq, markerName), alleleMap=alleleMap, inputAlleleCount = length(unlist(alleleMap)), uniqueSubAlleleCount=length(alleleMap)))
return(new("variantMap", reference=as.SeqFastadna(markerSeq, markerName), variantSource=sourceName, variantMap=alleleMap, inputVariantCount = length(unlist(alleleMap)), uniqueSubVariantCount=length(alleleMap)))
}
#' An S4 class that holds information about an mlgt analysis.
#'
#' Returned by \code{\link{prepareMlgtRun}}. Used as sole input for \code{\link{mlgt}}
#'
#' \describe{
#' \item{projectName}{In which project does this run belong}
#' \item{runName}{Which run was this. An identifier for the sequnece run}
#' \item{markers}{A \emph{list} of named sequences.}
#' \item{samples}{A vector of sample names}
#' \item{fTags}{A vector of named sequence of MIDs used to barcode samples at the 5' end.}
#' \item{rTags}{A vector of named sequence of MIDs used to barcode samples at the 3' end.}
#' \item{inputFastaFile}{The name of the file containing sequences. Currently only fasta format is supported. It is up to you to pre-filter the sequences.}
#' }
#'
#' @slot projectName In which project does this run belong
#' @slot runName Which run was this. An identifier for the sequnece run
#' @slot markers A \emph{list} of named sequences.
#' @slot samples A vector of sample names
#' @slot fTags A vector of named sequence of MIDs used to barcode samples at the 5' end.
#' @slot rTags A vector of named sequence of MIDs used to barcode samples at the 3' end.
#' @slot inputFastaFile The name of the file containing sequences. Currently only fasta format is supported. It is up to you to pre-filter the sequences.
#' @seealso \code{\link{prepareMlgtRun}}, \code{\link{mlgt}}
setClass("mlgtDesign",
representation(
projectName="character",
runName="character",
markers="list",
samples="character",
fTags="list",
rTags="list",
inputFastaFile="character",
markerBlastResults="character",
fTagBlastResults="character",
rTagBlastResults="character"
)
)
setMethod("show", "mlgtDesign", definition= function(object="mlgtDesign"){
cat("Design for mlgt run:\n")
cat(paste("Project:",object@projectName,"\n"))
cat(paste("Run:",object@runName,"\n"))
cat(paste("Samples:",length(object@samples),"\n"))
cat(paste("fTags:",length(object@fTags),"\n"))
cat(paste("rTags:",length(object@rTags),"\n"))
cat(paste("Markers:",length(object@markers),"\n"))
}
)
#' An S4 class to hold results from \code{\link{mlgt}}
#'
#' Extends \code{\link{mlgtDesign}}
#'
#' \describe{
#' \item{projectName}{In which project does this run belong}
#' \item{runName}{Which run was this. An identifier for the sequnece run}
#' \item{markers}{A \emph{list} of named sequences.}
#' \item{samples}{A vector of sample names}
#' \item{fTags}{A vector of named sequence of MIDs used to barcode samples at the 5' end.}
#' \item{rTags}{A vector of named sequence of MIDs used to barcode samples at the 3' end. May be same as \code{fTags}}
#' \item{inputFastaFile}{The name of the file containing sequences. Currently only fasta format is supported. It is up to you to pre-filter the sequences.}
#' \item{runSummaryTable}{A summary table with one row per marker}
#' \item{alleleDb}{A list of objects of class \code{\link{variantMap}}. Contains all variants returned by \code{\link{mlgt}}}
#' \item{markerSampleList}{A list of tables, one table per marker giving results for each sample/MID}
#' }
#'
#' @seealso \code{\link{mlgtDesign}}, \code{\link{prepareMlgtRun}}, \code{\link{mlgt}}
#'
setClass("mlgtResult",
representation(
runSummaryTable="data.frame",
alleleDb="list" ,
markerSampleList="list",
varCountTables="list"
),
contains="mlgtDesign"
)
setMethod("show", "mlgtResult", definition= function(object="mlgtResult"){
cat("Results for mlgt run:\n")
cat(paste("Project:",object@projectName,"\n"))
cat(paste("Run:",object@runName,"\n"))
cat(paste("Samples:",length(object@samples),"\n"))
cat(paste("fTags:",length(object@fTags),"\n"))
cat(paste("rTags:",length(object@rTags),"\n"))
cat(paste("Markers:",length(object@markers),"\n"))
print(object@runSummaryTable)
}
)
#' Return top blast hits
#'
#' Auxillary function
#'
#' @param blastTableFile The name of a file of tabulated blast results.
#' @return A reduced blast table with one hit per query
#' @export
getTopBlastHits <- function(blastTableFile) { # returns the first hit for each query in the table. May now be partially redundant if selecting for number of blast hits returned..
blastResults <- read.delim(blastTableFile, header=F)
## Fields:
# Query id,Subject id,% identity,alignment length,mismatches,gap openings,q. start,q. end,s. start,s. end,e-value,bit score
names(blastResults) <- c("query", "subject", "percent.id", "ali.length", "mismatches", "gap.openings", "q.start","q.end", "s.start","s.end", "e.value", "bit.score")
topHits <- blastResults[match(unique(blastResults$query), blastResults$query),]
}
#INTERNAL. Need to document?
#' Align and trim sequences for marker/sample pair
#'
#' A list of sequences mapped to both \option{thisMarker} and \option{thisSample} is created and these sequences are aligned to \option{markerSeq}.
#'
#' This internal function is called by \code{\link{mlgt}}
#'
#' @param thisMarker A specific marker name
#' @param thisSample A specific sample name
#' @param sampleMap A list of sequence IDs assigned to each marker. Each element named by marker name.
#' @param fMarkerMap A list of sequence IDs assigned to each sample using BLAST hits in forward orientation. Each element named by sample name.
#' @param rMarkerMap A list of sequence IDs assigned to each sample using BLAST hits in reverse orientation. Each element named by sample name.
#' @param markerSeq The sequence of \option{thisMarker}
#' @param maxVarsToAlign If total assigned sequences exceeds 'minTotalCount', then only the 'maxVarsToAlign' most abundant variants are used.
#' @param minTotalCount How many assigned sequences to allow before limiting the number of raw variants to allign.
#' @param errorCorrect Use error correection on alignment of raw variants
#' @param correctThreshold Maximum proportion of raw reads at which (minor allele) bases and gaps are corrected.
#' @param minLength Reads below this length are excluded (they are very likely to be primer-dimers).
#'
#' @return A table of unique variants and their counts. The sequences have been trimmed to the portion aligned with \option{markerSeq}
#'
getSubSeqsTable <- function(thisMarker, thisSample, sampleMap, fMarkerMap,rMarkerMap, markerSeq, maxVarsToAlign=30, minTotalCount=500, errorCorrect=FALSE, correctThreshold=0.01, minLength=70) {
if(exists("verbose")) cat("getSubSeqsTable",thisSample, thisMarker,"\n")
# check paths to auxillary programs
pathNames <- c("FASTACMD_PATH","MUSCLE_PATH")
for(thisPath in pathNames) {
if(nchar(Sys.getenv(thisPath)) < 1) {
stop(paste(thisPath,"has not been set!"))
}
}
musclePath <- Sys.getenv("MUSCLE_PATH")
fastacmdPath <- Sys.getenv("FASTACMD_PATH")
if(length(grep(" ",musclePath, fixed=T)) > 0 ) musclePath <- shQuote(musclePath)
if(length(grep(" ",fastacmdPath, fixed=T)) > 0 ) fastacmdPath <- shQuote(fastacmdPath)
thisVarCount <- new("varCount", rawTotal=0,
rawUniqueCount =0,
usedRawTotal=0,
usedRawUniqueCount=0,
subAlignTotal=0,
subAlignUniqueCount=0,
varCountTable=data.frame())
varCountTable <- data.frame()
#thisMarker <- "DPA1_E2"
#thisSample <- "MID-1"
fPairSeqList <- intersect(sampleMap[[thisSample]], fMarkerMap[[thisMarker]]) # fMarkerMap[[thisMarker]]
rPairSeqList <- intersect(sampleMap[[thisSample]], rMarkerMap[[thisMarker]])
# extract raw seqs from blastdb for forward hits. # THIS FUNCT CURRENTLY UNUSED BECAUSE NEED TO ASSESS IF ANYTHING TO QUERY BEFORE RUNNING fastacmd
extractRawSeqsCommand <- function(idList,strand=1, fileName) {
queryList <- paste(idList , collapse=",")
fastacmdCommand <- paste(fastacmdPath, "-p F -t T -d", "inputSeqs" , "-S", strand, "-o", fileName, "-s", queryList)
return(fastacmdCommand)
}
fRawSeqs <- rRawSeqs <- list()
## 12th Dec 11. Edited following rawseq extraction because failed when using large dataset. Replaced '-s' (queryList) option with '-i' (inputfile)
if(length(fPairSeqList ) > 0) {
fIdFileName <- paste("test", thisMarker, thisSample, "fIdFile.txt",sep=".")
write(fPairSeqList , file=fIdFileName )
fRawSeqFileName <- paste("test", thisMarker, thisSample, "fRawSeqExtract.fasta",sep=".")
strand <- 1
fastacmdCommand <- paste(fastacmdPath, "-p F -t T -d", "inputSeqs" , "-S", strand, "-o", fRawSeqFileName, "-i", fIdFileName)
system(fastacmdCommand)
fRawSeqs <- read.fasta(fRawSeqFileName , as.string=T)
}
if(length(rPairSeqList ) > 0) {
rIdFileName <- paste("test", thisMarker, thisSample, "rIdFile.txt",sep=".")
write(rPairSeqList , file=rIdFileName )
rRawSeqFileName <- paste("test", thisMarker, thisSample, "rRawSeqExtract.fasta",sep=".")
strand <- 2
fastacmdCommand <- paste(fastacmdPath, "-p F -t T -d", "inputSeqs" , "-S", strand, "-o", rRawSeqFileName, "-i", rIdFileName)
system(fastacmdCommand)
rRawSeqs <- read.fasta(rRawSeqFileName , as.string=T)
}
# Make file of unique seqs. Can name with sequence
### STRAND!!! - Done!
# ver 0.14 March2012 - New algorithm required. Take minimum unique raw variants to achieve:-
################ NO 50% (minPropReads) of reads
# or 30 most abundant unique variants (maxVarsToAlign)
# or 500 reads (minTotalCount), whichever is larger.
rawSeqs <- c(fRawSeqs ,rRawSeqs )
# filter out sequences shorter than minLength. Value of 0 means no filter.
if(minLength > 0) rawSeqs <- rawSeqs[which(nchar(rawSeqs) > minLength)]
totalRaw <- length(rawSeqs)
if(totalRaw < 1) {
#return(varCountTable)
return(thisVarCount)
}
rawSeqCountTable <- as.data.frame(table(unlist(rawSeqs)))
rawVariantCount <- nrow(rawSeqCountTable)
names(rawSeqCountTable) <- c("var", "count")
rawSeqCountTable <- rawSeqCountTable[order(rawSeqCountTable$count, decreasing=T),] # most abundant raw vars at top of list.
#minTotalCount <- ceiling(totalRaw * minPropReads) # want to catch at least this many raw reads.
#enoughReadsIndex <- cumsum(rawSeqCountTable$count)
useIndex <- min(maxVarsToAlign, nrow(rawSeqCountTable))
if(totalRaw > minTotalCount) {
#use only most abundant 30 (maxVarsToAlign) unique variants.
rawSeqCountTable <- rawSeqCountTable[1:useIndex,]
}
usedTotalRaw <- sum(rawSeqCountTable$count)
usedVarCount <- nrow(rawSeqCountTable)
cat(paste(thisSample,": Using", nrow(rawSeqCountTable), "variants, accounting for", usedTotalRaw, "of", totalRaw, "reads\n"))
rawVariantFile <- paste("test", thisMarker, thisSample, "raw.variants.fasta",sep=".") #"localVariants.fasta"
#rawVariantFile <- paste(runPath, rawVariantFileName, sep="/")
#v0.14# write.fasta(as.list(c(markerSeq,as.character(rawSeqCountTable$var))) ,c(thisMarker,as.character(rawSeqCountTable$var)),file.out=rawVariantFile ,open="w") # align marker AND raw variants
write.fasta(as.list(as.character(rawSeqCountTable$var)) ,as.character(rawSeqCountTable$var),file.out=rawVariantFile ,open="w") # align just raw variants
# Align all seqs
rawAlignFile <- paste("test", thisMarker, thisSample, "raw.align.fasta",sep=".") #"localAlign.fasta"
#rawAlignFile <- paste(runPath, rawAlignFileName, sep="/")
##Removed for ver0.14
#if(rawVariantCount > 800) {
# muscleCommand <- paste(musclePath, "-in", rawVariantFile , "-out", rawAlignFile , "-diags -quiet -maxiters 2" ) # faster alignment
# warning(paste("Using fast MUSCLE alignment for ", thisMarker, thisSample, rawVariantCount, "sequences\n"))
#} else {
muscleCommand <- paste(musclePath, "-in", rawVariantFile , "-out", rawAlignFile , "-diags -quiet" )
#}
#cat(paste(muscleCommand, "\n"))
system(muscleCommand)
#v0.14# error Correct if required
if(errorCorrect) {
alignedVars <- read.fasta(rawAlignFile, as.string=T)
seqCounts <- rawSeqCountTable$count[match(names(alignedVars),rawSeqCountTable$var)]
#cat(seqCounts)
#DONE MUST: strip off aligned marker and add back on - do not want this to be 'corrected' to match all other seqs.
#seqCounts <- varCountTable$count
## important to 'unpack' the alignment so that each sequence occurs the correct number of times.
sampleSeqs <- rep(alignedVars , seqCounts)
thisAlign <- as.alignment(sum(seqCounts), names(sampleSeqs), as.character(sampleSeqs))
if(exists("verbose")) cat(paste(length(unique(thisAlign$seq)),"/", thisAlign$nb,"unique seqs in original alignment, "))
newAlign <- errorCorrect.alignment(thisAlign, correctThreshold)
# need to repack this alignment
if(exists("verbose")) cat(paste(length(unique(newAlign$seq)),"/", newAlign$nb,"unique seqs in new alignment, "))
## DONE: repack the corrected alignment re-attribute the allele names. Update the markerSampleTable
newCountTable <- as.data.frame(table(unlist(newAlign$seq)),stringsAsFactors=FALSE)
rawSeqCountTable <- data.frame(alignedVar=newCountTable$Var1, count=as.numeric(newCountTable$Freq),stringsAsFactors=FALSE)
rawSeqCountTable$var <- gsub("-","",rawSeqCountTable$alignedVar)
rawSeqCountTable <- rawSeqCountTable[order(rawSeqCountTable$count,decreasing=T),]
#cat(paste("rawSeqCountTable rows:", nrow(rawSeqCountTable), "\n"))
rawAlignFile.corrected <- paste("test", thisMarker, thisSample, "raw.align.corrected.fasta",sep=".") #"localAlign.fasta"
#write.fasta(as.list(newAlign$seq), newAlign$nam, file.out=rawAlignFile.corrected )
write.fasta(as.list(rawSeqCountTable$alignedVar), rawSeqCountTable$var, file.out=rawAlignFile.corrected )
rawAlignFile <- rawAlignFile.corrected
}
#v0.14# Align marker sequence using profile alignment (not done as part of base alignment so that errorCorrect can be run on rawAlignment).
markerSeqFile <- paste(thisMarker, "markerSeq.fasta", sep=".")
write.fasta(markerSeq, thisMarker, file.out=markerSeqFile )
rawPlusMarkerFile <- paste("test", thisMarker, thisSample, "raw.marker.align.fasta",sep=".") #"localAlign.fasta"
muscleCommand <- paste(musclePath, "-profile -quiet -in1", rawAlignFile , "-in2", markerSeqFile , "-out", rawPlusMarkerFile )
system(muscleCommand)
#v0.14# Extract portion corresponding to reference.
rawAlignFile <- rawPlusMarkerFile
rawAlignment <- read.fasta(rawAlignFile, as.string=T) # do not use read.alignment() - broken
alignedMarkerSeq <- s2c(rawAlignment[[thisMarker]])
subStart <- min(grep("-",alignedMarkerSeq ,invert=T))
subEnd <- max(grep("-",alignedMarkerSeq ,invert=T))
alignedSubSeqs <- lapply(rawAlignment, FUN=function(x) substr(x[1], subStart, subEnd))
subAlignFile <- paste("test", thisMarker, thisSample, "sub.align.fasta",sep=".") #"localAlign.fasta"
#subAlignFile <- paste(runPath, subAlignFileName , sep="/")
write.fasta(alignedSubSeqs , names(alignedSubSeqs ), file.out=subAlignFile )
alignedSubTable <- data.frame(var = names(alignedSubSeqs ) , subSeq= as.character(unlist(alignedSubSeqs )))
# Re-apply count of each seq. There may be some duplicated subSeqs.
combTable <- merge(rawSeqCountTable ,alignedSubTable , by="var", all.x=T)
varCount <- by(combTable, as.character(combTable$subSeq), FUN=function(x) sum(x$count))
varCountTable <- data.frame(alignedVar=names(varCount), count=as.numeric(varCount),stringsAsFactors=FALSE) ## added stringsAsFactors=FALSE to enable passing of aligned list
varCountTable$var <- gsub("-","",varCountTable$alignedVar)
varCountTable <- varCountTable[order(varCountTable$count,decreasing=T),]
thisVarCount <- new("varCount", rawTotal=totalRaw,
rawUniqueCount = rawVariantCount ,
usedRawTotal = usedTotalRaw,
usedRawUniqueCount = usedVarCount,
subAlignTotal = sum(varCountTable$count),
subAlignUniqueCount = nrow(varCountTable),
varCountTable = varCountTable)
#return(varCountTable)
return(thisVarCount)
}
#mlgt <- function(object) attributes(object)
#setGeneric("mlgt")
#' Get variants for all markers/samples
#'
#' \code{mlgt} Works through all pairs of markers and samples. Aligns variants and trims aligned variants to the marker sequence. Potential 'alleles' are assigned from the most common variants within each sample.
#'
#' Depends upon \code{\link{prepareMlgtRun}} having been run in the current directory to generate \option{designObject} of class \code{\link{mlgtDesign}}.
#' The basic process for each marker/sample pair is to align all unique variants using MUSCLE and then extract the alignment portion aligned to the reference marker sequence, ignoring the rest.
#' The marker alignment is critical and \code{\link{mlgt}} has several options to optimise this alignment.
#' If the total number of reads is less than minTotalCount, then all variants are aligned. Otherwise, only the most abundant 30 unique variants are aligned.
#' Optionally, alignments are `error-correted' as per the separate function \code{\link{errorCorrect}}. Reads shorter than 'minLength' are filtered out.
#'
#' @param designObject an object of class \code{\link{mlgtDesign}}
#' @param minTotalCount How many assigned sequences to allow before limiting the number of raw variants to allign.
#' @param maxVarsToAlign If total assigned sequences exceeds 'minTotalCount', then only the 'maxVarsToAlign' most abundant variants are used.
#' @param errorCorrect Use error correection on alignment of raw variants
#' @param correctThreshold Maximum proportion of raw reads at which (minor allele) bases and gaps are corrected.
#' @param minLength Reads below this length are excluded (they are very likely to be primer-dimers).
#' @param varsToName How many variants from each sample should be tracked across samples (default=3) (NOT YET IMPLEMENTED)
#'
#' @return an object of class \code{\link{mlgtResult}} containing all variants and their counts, a summary table (all markers) and one summary table per marker.
#' @seealso \code{\link{prepareMlgtRun}}
#'
#' @export
#' @docType methods
#' @rdname mlgt-methods
#' @aliases mlgt.mlgtDesign
mlgt <- function(designObject, maxVarsToAlign=30, minTotalCount=500, errorCorrect=FALSE,correctThreshold=0.01, minLength=70, varsToName=3) attributes(designObject)
setGeneric("mlgt")
# TODO: use varsToName to determine columns varName.x and varFreq.x
# TODO: use varsToName to determine alToRecord
# e.g. varNamedDataFrame <- function(varName, n) {
# as.data.frame(matrix(NA, nrow=1, ncol=n,dimnames=list(NULL,paste("varName", 1:n, sep="."))))
# }
#test <- varNamedDataFrame(allele, 3) # then use cbind.
# TODO: replace use of "NA" with NA
# TODO: varCountTables=varCountTableList Seems to be allowing repeats of some sequences if their alignments hold different '-' gap positions.
# TODO: Not a problem for variantMap, which uses ungapped sequence, but untidy all the same.
mlgt.mlgtDesign <- function(designObject, maxVarsToAlign=30, minTotalCount=500, errorCorrect=FALSE,correctThreshold=0.01, minLength=70, varsToName=3) {
topHits <- getTopBlastHits("blastOut.markers.tab")
topHits$strand <- ifelse(topHits$s.end > topHits$s.start, 1,2)
fMarkerMap <- split(as.character(topHits$query[topHits$strand==1]), topHits$subject[topHits$strand==1])
rMarkerMap <- split(as.character(topHits$query[topHits$strand==2]), topHits$subject[topHits$strand==2])
## DONE: alter this section to allow different MIDs at either end and, hence, use result from both "blastOut.rTags.tab" and "blastOut.fTags.tab"
## when f and r MIDs are the same, the "blastOut.rTags.tab" and "blastOut.fTags.tab" will produce the same topHIts.
## when f and r MIDs are different, these files will differ and need to be combined.
## NEED TO MAKE SAMPLEMAP WITH HITS TO MID IN BOTH FORWARD AND REVERSE STRANDS like marker hits are split.
## Requires retention of 2 blast hits per sequence.
rTopSampleHits <- read.delim("blastOut.rTags.tab", header=F)
names(rTopSampleHits) <- c("query", "subject", "percentId", "aliLength", "mismatches", "gapOpenings", "q.start","q.end", "s.start","s.end", "p_value", "e_value")
rSampleMap <- split(as.character(rTopSampleHits$query), rTopSampleHits$subject)
fTopSampleHits <- read.delim("blastOut.fTags.tab", header=F)
names(fTopSampleHits) <- c("query", "subject", "percentId", "aliLength", "mismatches", "gapOpenings", "q.start","q.end", "s.start","s.end", "p_value", "e_value")
fSampleMap <- split(as.character(fTopSampleHits$query), fTopSampleHits$subject)
# combind sampleMaps to give sequences with MIDs in both orientations.
pairedSampleMap <- lapply(names(fSampleMap), FUN=function(x) intersect(fSampleMap[[x]], rSampleMap[[x]]))
names(pairedSampleMap) <- names(fSampleMap)
##########ITERATIONS
markerSampleList <- list()
runSummaryTable <- data.frame()
alleleDb <- list()
varCountTableList <- list()
if(errorCorrect) cat(paste("Using error correction at", correctThreshold, "\n"))
for(thisMarker in names(designObject@markers)) {
#for(thisMarker in names(markerMap)) {
#for(thisMarker in names(markerMap)[1:2]) { # temp to finish off
cat(paste(thisMarker,"\n"))
#cat("New Version\n")
#thisMarker <- "DQA1_E2"
## might need to combine all these to return a single item.
summaryList <- list()
summaryTable <- data.frame()
markerSequenceCount <- list("noSeq"=0) # BUG? requires some data otherwise won't sum properly with localSequenceCount.
alleleList <- list()
variantList <- list()
alleleCount <- 1
markerSeq <- unlist(getSequence(designObject@markers[[thisMarker]],as.string=T))
varCountTableList[[thisMarker]] <- data.frame()
for(thisSample in designObject@samples) {
#for(thisSample in names(pairedSampleMap)[1:4]) {
#print(thisSample)
testPairSeqList <- intersect(pairedSampleMap[[thisSample]],union(fMarkerMap[[thisMarker]], rMarkerMap[[thisMarker]]))
#testPairSeqList <- intersect(pairedSampleMap[[thisSample]], markerMap[[thisMarker]])
#testPairSeqList <- intersect(sampleMap[[thisSample]], markerMap[[thisMarker]])
seqTable <- data.frame()
localAlleleNames <- c("NA","NA","NA")
localAlleleFreqs <- c(0,0,0)
## go through all seq's mapped to this marker/sample pair.
## extract the corresponding sequence delimited by the top blast hits on the primers. IS THIS THE BEST WAY?
## Simple improvement: minimum blast hit length to primer to keep.
## internal Function
# TODO: use varsToName to determine columns varName.x and varFreq.x
recordNoSeqs <- function(summaryTable) { # to record no seqs before skipping out.
summaryRow <- data.frame(marker=thisMarker, sample=thisSample,
rawTotal=0, rawVars=0,
usedTotal=0, usedVars=0,
numbSeqs=0,numbVars=0,
varName.1="NA", varFreq.1= 0,
varName.2="NA", varFreq.2= 0,
varName.3="NA", varFreq.3= 0)
summaryTable <- rbind(summaryTable, summaryRow)
return(summaryTable)
}
if(length(testPairSeqList) < 1) {
#summaryList[[thisMarker]][[thisSample]] <- NA
summaryTable <- recordNoSeqs(summaryTable)
next ; # skip to next sample
}
## Ver. 0.14 - edited getSubSeqsTable to return object of class 'varCount' , which includes the required table.
# seqTable <- getSubSeqsTable(thisMarker, thisSample, pairedSampleMap, fMarkerMap,rMarkerMap, markerSeq)
thisVarCount <- getSubSeqsTable(thisMarker, thisSample, pairedSampleMap, fMarkerMap,rMarkerMap, markerSeq,
maxVarsToAlign=maxVarsToAlign, minTotalCount=minTotalCount, errorCorrect=errorCorrect,
correctThreshold=correctThreshold, minLength=minLength)
seqTable <- thisVarCount@varCountTable
#cat(paste("Raw total:",thisVarCount@rawTotal,"\n"))
# if no sequences returned, nothing to process.
if(nrow(seqTable) < 1 ) {
summaryTable <- recordNoSeqs(summaryTable)
#summaryList[[thisMarker]][[thisSample]] <- NA
next ; # go to next sample.
}
# store sequence and count of sequence as alignedVar (needed for alignment report)
# TODO: this could be source of error as alignedVar is not ALWAYS the same across samples for same variant.
# return to using seqTable$var BUT need another way of producing alignment report
varCountTableList[[thisMarker]][seqTable$alignedVar,thisSample] <- seqTable$count
#varCountTableList[[thisMarker]][seqTable$var,thisSample] <- seqTable$count
#localSequenceMap <- split(seqTable[,2], seqTable[,1])
#localSequenceCount <- lapply(localSequenceMap , length) # list named by sequence with counts.
#localSequenceCount <- localSequenceCount[order(as.numeric(localSequenceCount), decreasing=T)]
## test if variants are novel.
## Give allele names?
## Do with first three for now.
# TODO: use varsToName to determine alToRecord
alToRecord <- min(3,nrow(seqTable)) # required to cope with fewer than n variants.
if(alToRecord > 0) {
for (a in 1:alToRecord ) {
if(is.null(variantList[[seqTable$var[a]]])) { # novel
alleleName <- paste(thisMarker, alleleCount,sep=".")
variantList[[seqTable$var[a]]] <- alleleName
localAlleleNames[a] <- alleleName
localAlleleFreqs[a] <- seqTable$count[a]
alleleCount <- alleleCount + 1
} else { # pre-existing alllele
localAlleleNames[a] <- variantList[[seqTable$var[a]]]
localAlleleFreqs[a] <- seqTable$count[a]
}
}
}
# sequence correction?
# compile stats
if(nrow(seqTable) >0 ) { # cannot allow assignment from empty list as messes up class of list for remaining iterations
summaryList[[thisMarker]] <- list()
summaryList[[thisMarker]][[thisSample]] <- seqTable
}
# TODO: use varsToName to determine varName and varFreq columns.
summaryRow <- data.frame(marker=thisMarker, sample=thisSample,
rawTotal=thisVarCount@rawTotal, rawVars=thisVarCount@rawUniqueCount,
usedTotal=thisVarCount@usedRawTotal, usedVars=thisVarCount@usedRawUniqueCount,
numbSeqs=sum(seqTable$count),numbVars=nrow(seqTable),
varName.1=localAlleleNames[1], varFreq.1= localAlleleFreqs[1],
varName.2=localAlleleNames[2], varFreq.2= localAlleleFreqs[2],
varName.3=localAlleleNames[3], varFreq.3= localAlleleFreqs[3])
summaryTable <- rbind(summaryTable, summaryRow)
#sequence count across samples?
# need to sum from summaryTable or from summaryList.
#markerSequenceCount <-
#as.list(colSums(merge(m, n, all = TRUE), na.rm = TRUE)) # not working
localSequenceCount <- as.list(seqTable$count)
names(localSequenceCount) <- seqTable$var
markerSequenceCount <- as.list(colSums(merge(markerSequenceCount , localSequenceCount, all = TRUE), na.rm = TRUE))
# might need to instantiate the markerSequenceCount if empty.
} # end of sample loop
markerSampleList[[thisMarker]] <- summaryTable
## DONE: min(nchar(names(variantList))) throws warning when no variants in list. (Inf/-Inf)
minVarLength <- ifelse(length(markerSequenceCount) < 1, NA, min(nchar(names(markerSequenceCount))) )
maxVarLength <- ifelse(length(markerSequenceCount) < 1, NA, max(nchar(names(markerSequenceCount))) )
minAleLength <- ifelse(length(variantList) < 1, NA, min(nchar(names(variantList))) )
maxAleLength <- ifelse(length(variantList) < 1, NA, max(nchar(names(variantList))) )
runSummaryRow <- data.frame(marker=thisMarker, assignedSeqs=sum(summaryTable$numbSeqs), assignedVariants=sum(summaryTable$numbVars),
minVariantLength=minVarLength,
maxVariantLength=maxVarLength,
minAlleleLength=minAleLength, maxAlleleLength=maxAleLength )
runSummaryTable <- rbind(runSummaryTable, runSummaryRow)
if(length(variantList) > 0) {
# This line replaced. Not entirely tested the repurcussions. e.g. makeVarAlleleMap()?
#alleleDb[[thisMarker]] <- variantList # LATER: separate lists for alleles and variants?
#alleleDb[[thisMarker]] <- list(reference=as.SeqFastadna(markerSeq, thisMarker), alleleMap=variantList, inputAlleleCount = length(unlist(variantList)), uniqueSubAlleleCount=length(variantList))
alleleDb[[thisMarker]] <- new("variantMap", reference=as.SeqFastadna(markerSeq, thisMarker),
variantSource=paste(designObject@projectName, designObject@runName,sep="."),
variantMap=variantList, inputVariantCount = length(unlist(variantList)), uniqueSubVariantCount=length(variantList))
}
} # end of marker loop
localMlgtResult <- new("mlgtResult", designObject, runSummaryTable=runSummaryTable , alleleDb=alleleDb, markerSampleList=markerSampleList,
varCountTables=varCountTableList)
return(localMlgtResult)
} # end of mlgt function
#' @rdname mlgt-methods
#' @aliases mlgt,mlgtDesign-method
setMethod("mlgt",signature(designObject="mlgtDesign", maxVarsToAlign="ANY", minTotalCount="ANY", errorCorrect="ANY",correctThreshold="ANY", minLength="ANY", varsToName="ANY"), definition=mlgt.mlgtDesign)
#INTERNAL. Does this need documenting?
# Create a local BLAST db
#
# This internal utility uses \code{system(fomatdb)} to create a local BLAST database
#
# Requires the NCBI program formatdb to be installed and the environment variable formatdbPath to be set.
#
# @param inputFastaFile
# @param formatdbPath
# @param blastdbName
# @param indexDb Whether to generate an index for the db. Useful for large db of sequences, which are later to be extracted with fastacommand
#
#
setUpBlastDb <- function(inputFastaFile, formatdbPath, blastdbName, indexDb="F") {
formatdbCommand <- paste(formatdbPath, "-i", inputFastaFile , "-p F -o", indexDb ,"-n", blastdbName)
#cat(paste(formatdbCommand,"\n"))
system(formatdbCommand)
}
quoteIfSpaces <- function(pathString) {
if(length(grep(" ",pathString, fixed=T)) > 0 ) {
pathString <- shQuote(pathString)
}
return(pathString)
}
copyIfSpaces <- function(pathString) {
if(length(grep(" ",pathString, fixed=T)) > 0 ) {
newName <- make.names(basename(pathString))
file.copy(pathString,newName , overwrite=TRUE)
cat(paste("BLAST and MUSCLE cannot cope with whitespace in filenames.\nCopying",pathString,"to",newName,"\n"))
return(newName)
} else {
return(pathString)
}
}
#prepareMlgtRun <- function(object) attributes(object)
#prepareMlgtRun <- function(designObject) attributes(designObject)
#' Prepare to run mlgt
#'
#' Required before \code{\link{mlgt}} is used. Create BLAST databases and assign sequences using BLAST.
#'
#' This important function stores all the information about the analysis run AND populates the working directory
#' with multiple local Blast databases, which are later required by \code{\link{mlgt}}.
#' Once \code{prepareMlgtRun} has been run, \code{\link{mlgt}} can be run aswell as
#' \code{\link{printBlastResultGraphs}} and \code{\link{inspectBlastResults}}.
#'
#' @param designObject Only used internally.
#' @param projectName In which project does this run belong
#' @param runName Which run was this. An identifier for the sequnece run
#' @param markers A \emph{list} of named sequences.
#' @param samples A vector of sample names
#' @param fTags A vector of named sequence of MIDs used to barcode samples at the 5' end.
#' @param rTags A vector of named sequence of MIDs used to barcode samples at the 3' end.
#' @param inputFastaFile The name of the file containing sequences. Currently only fasta format is supported. It is up to you to pre-filter the sequences.
#' @param overwrite Should files in the current directory be overwritten? c("prompt", "yes", "no")
#'
#' @return An object of class \code{\link{mlgtDesign}} is returned. Also, several BLAST dbs and sets of BLAST results are created in the working directory.
#' These are essential for \code{\link{mlgt}} to run.
#'
#' @rdname prepareMlgtRun-methods
#' @export
#' @aliases prepareMlgtRun.listDesign,prepareMlgtRun.mlgtDesign
#' @seealso \code{\link{printBlastResultGraphs}} and \code{\link{inspectBlastResults}} can only be run AFTER \code{prepareMlgtRun}.
prepareMlgtRun <- function(designObject,projectName,runName, samples, markers,fTags,rTags, inputFastaFile, overwrite) attributes(designObject)
setGeneric("prepareMlgtRun")
prepareMlgtRun.listDesign <- function(projectName,runName, samples, markers,fTags,rTags, inputFastaFile,overwrite="prompt") {
# test inputFastaFile for spaces
inputFastaFile <- copyIfSpaces(inputFastaFile)
#if(length(grep(" ",inputFastaFile, fixed=T)) > 0 ) stop(paste("mlgt cannot handle path names with whitespace. Sorry.\n ->>",inputFastaFile,"\n"))
##inputFastaFile <- quoteIfSpaces(inputFastaFile)
designObject <- new("mlgtDesign", projectName=projectName, runName=runName,
samples=samples, markers=markers ,
fTags=fTags, rTags=rTags, inputFastaFile=inputFastaFile)
designObject <- prepareMlgtRun(designObject,overwrite=overwrite)
}
#' @rdname prepareMlgtRun-methods
#' @aliases prepareMlgtRun,missing,character,character,character,list,list,list,character,character-method
setMethod("prepareMlgtRun",
signature(designObject="missing",projectName="character", runName="character", samples="character",markers="list",
fTags="list", rTags="list", inputFastaFile="character", overwrite="character"),
definition=prepareMlgtRun.listDesign)
prepareMlgtRun.mlgtDesign <- function(designObject, overwrite="prompt") {
cat(paste(designObject@projectName,"\n"))
#check pathNames of auxillary programs.
pathNames <- c("BLASTALL_PATH","FORMATDB_PATH","FASTACMD_PATH","MUSCLE_PATH")
for(thisPath in pathNames) {
if(nchar(Sys.getenv(thisPath)) < 1) {
stop(paste(thisPath,"has not been set!"))
}
# shellQuote any paths containing spaces.
# Can't use variables in Sys.setenv
#if(length(grep(" ",Sys.getenv(thisPath), fixed=T)) > 0 ) Sys.setenv(thisPath= shQuote(thisPath))
}
formatdbPath <- Sys.getenv("FORMATDB_PATH")
fastacmdPath <- Sys.getenv("FASTACMD_PATH")
blastAllPath <- Sys.getenv("BLASTALL_PATH")
# shellQuote any paths containing spaces.
if(length(grep(" ",formatdbPath, fixed=T)) > 0 ) formatdbPath <- shQuote(formatdbPath)
if(length(grep(" ",fastacmdPath, fixed=T)) > 0 ) fastacmdPath <- shQuote(fastacmdPath)
if(length(grep(" ",blastAllPath, fixed=T)) > 0 ) blastAllPath <- shQuote(blastAllPath)
# runPath <- getwd() # could change this later
# if(length(grep(" ",runPath , fixed=T)) > 0 ) {
# stop("mlgt cannot yet cope with path names containing spaces. Please move to a folder with no spaces in path. Sorry. \n")
# }
# fTagsFastaFile <- paste(runPath,"fTags.fasta", sep="/")
# rTagsFastaFile <- paste(runPath,"rTags.fasta", sep="/")
# markersFastaFile <- paste(runPath,"markers.fasta", sep="/")
# rTagsBlastOutFile <- paste(runPath,"blastOut.rTags.tab", sep="/")
# fTagsBlastOutFile <- paste(runPath,"blastOut.fTags.tab", sep="/")
# blastOutFileName <- "blastOut.markers.tab"
# markerBlastOutFile <- paste(runPath, blastOutFileName, sep="/")
# removed concatenation of runPath because of issue with space character. All output must now go to working directory
fTagsFastaFile <- "fTags.fasta"
rTagsFastaFile <- "rTags.fasta"
markersFastaFile <- "markers.fasta"
rTagsBlastOutFile <- "blastOut.rTags.tab"
fTagsBlastOutFile <- "blastOut.fTags.tab"
blastOutFileName <- "blastOut.markers.tab"
markerBlastOutFile <- blastOutFileName #redundant?
existingFiles <- (file.exists(fTagsFastaFile ) | file.exists(rTagsFastaFile ) | file.exists(markersFastaFile ) |
file.exists(rTagsBlastOutFile) | file.exists(fTagsBlastOutFile) | file.exists(markerBlastOutFile))
if(existingFiles) {
overwrite <- tolower(overwrite)
# set up new directories if required.
if(overwrite == "prompt") overwrite <- readline("This folder already contains mlgt run files, do you want to write over this data? (yes/no)")
if(!(overwrite=="y" | overwrite=="n" | overwrite=="yes" | overwrite=="no")) {stop(paste("Unrecognised value for overwrite:", overwrite))}
overWriteBaseData <- switch(overwrite,
"yes"=TRUE,
"y"=TRUE,
"no"=FALSE,
"n"=FALSE)
if(!overWriteBaseData) {stop("This folder already contains mlgt run files. Exiting")}
}
cat("Checking parameters...\n")
#check names and sequences of samples, markers, and barcodes for duplication. Check barcodes for consistent length
fMinTagSize <- min(nchar(designObject@fTags))
if(!all(nchar(designObject@fTags) == fMinTagSize )) {
stop("fTags (barcodes) must all be of same length\n")
}
rMinTagSize <- min(nchar(designObject@rTags))
if(!all(nchar(designObject@rTags) == rMinTagSize )) {
stop("rTags (barcodes) must all be of same length\n")
}
if(anyDuplicated(as.character(designObject@fTags)) > 0 ) stop("Duplicated fTag sequences\n")
if(anyDuplicated(names(designObject@fTags)) > 0 ) stop("Duplicated fTag names\n")
if(anyDuplicated(as.character(designObject@rTags)) > 0 ) stop("Duplicated rTag sequences\n")
if(anyDuplicated(names(designObject@rTags)) > 0 ) stop("Duplicated rTag names\n")
if(anyDuplicated(as.character(designObject@markers)) > 0 ) stop("Duplicated marker sequences\n")
if(anyDuplicated(names(designObject@markers)) > 0 ) stop("Duplicated marker names\n")
if(anyDuplicated(designObject@samples) > 0 ) stop("Duplicated sample names\n")
#runPath <- getwd()
# set up blast DBs
cat("Setting up BLAST DBs...\n")
write.fasta(designObject@fTags, names(designObject@fTags), file.out=fTagsFastaFile)
setUpBlastDb(fTagsFastaFile , formatdbPath, blastdbName="fTags") # default is no index
write.fasta(designObject@rTags, names(designObject@rTags), file.out=rTagsFastaFile )
setUpBlastDb(rTagsFastaFile , formatdbPath, blastdbName="rTags") # default is no index
write.fasta(designObject@markers, names(designObject@markers), file.out=markersFastaFile )
setUpBlastDb(markersFastaFile , formatdbPath, blastdbName="markerSeqs", indexDb="T")
## input as blast DB with index (useful for fast sub-sequence retrieval?)
inputFastaFile <- designObject@inputFastaFile #
setUpBlastDb(inputFastaFile , formatdbPath, blastdbName="inputSeqs", indexDb="T")
# run preliminary blast
cat("Running BLAST searches...\n")
#rMinTagSize <- 10 # limit blast hits to perfect matches. ### TODO: SET GLOBALLY
dbName <- "rTags"
blastCommand <- paste(blastAllPath , "-p blastn -d", dbName , "-i", inputFastaFile , "-W", rMinTagSize ,"-m 8 -b 2 -S 3 -o", rTagsBlastOutFile )
system(blastCommand )
#fMinTagSize <- 10 # limit blast hits to perfect matches.
dbName <- "fTags"
blastCommand <- paste(blastAllPath , "-p blastn -d", dbName , "-i", inputFastaFile , "-W", fMinTagSize ,"-m 8 -b 2 -S 3 -o", fTagsBlastOutFile )
system(blastCommand )
## blast against markers
dbName <- "markerSeqs"
blastCommand <- paste(blastAllPath , "-p blastn -d", dbName , "-i", inputFastaFile , "-W", 11 , "-m 8 -b 1 -o", markerBlastOutFile )
system(blastCommand )
designObject@markerBlastResults <- markerBlastOutFile
designObject@fTagBlastResults <- fTagsBlastOutFile
designObject@rTagBlastResults <- rTagsBlastOutFile
return(designObject)
}
##setMethod("prepareMlgtRun","mlgtDesign", definition=prepareMlgtRun.mlgtDesign)
#setMethod("prepareMlgtRun",signature(designObject="mlgtDesign"), definition=prepareMlgtRun.mlgtDesign)
#TODO: test if signature with overwrite="ANY" will work. First attempt, no.
#' @rdname prepareMlgtRun-methods
#' @aliases prepareMlgtRun,mlgtDesign,missing,missing,missing,missing,missing,missing,missing,character-method
setMethod("prepareMlgtRun",
signature(designObject="mlgtDesign",projectName="missing", runName="missing", samples="missing",markers="missing",
fTags="missing", rTags="missing", inputFastaFile="missing", overwrite="character"),
definition=prepareMlgtRun.mlgtDesign)
#setGeneric("prepareMlgtRun","mlgtDesign", definition=prepareMlgtRun.mlgtDesign)
######################### genotyping & allele matching
#' Results from \code{\link{callGenotypes}}
#'
#' An S4 class containing a table and parameter values returned by \code{\link{callGenotypes}}
#'
#' \describe{
#' \item{projectName}{In which project does this run belong}
#' \item{runName}{Which run was this. An identifier for the sequence run}
#' \item{marker}{Which marker was this.}
#' \item{genotypeTable}{A data frame with variant counts, statistics, genotype calls and, optionally, allele names.}
#' \item{callMethod}{Which method was used to call genotypes}
#' \item{callParameters}{a named list containing parameter values used in the call}
#' \item{mappedToAlleles}{TRUE/FALSE whether an attempt was made to map the variants to a db on known alleles.}
#' \item{alleleDbName}{A list of objects of class \code{\link{variantMap}}. Contains all variants returned by \code{\link{mlgt}}}
#' }
#'
#' @seealso \code{\link{callGenotypes}}, \code{\link{writeGenotypeCallsToFile}}
setClass("genotypeCall",
representation(
projectName="character",
runName="character",
marker="character",
genotypeTable="data.frame",
callMethod="character",
callParameters="list",
mappedToAlleles="logical",
alleleDbName="character"
)
)
#INTERNAL. Does this need documentation?
makeVarAlleleMap <- function(allele.variantMap, variant.variantMap) {
varAlleleMap <- data.frame()
# to use stopifnot, need to ensure no empty maps are passed. Currently this is happening so taking out this check.
#stopifnot(allele.variantMap@reference == variant.variantMap@reference)
knownAlleleTable <- data.frame(alleleSeq=names(allele.variantMap@variantMap), knownAlleles=as.character(allele.variantMap@variantMap))
dataAlleleTable <- data.frame(alleleSeq=names(variant.variantMap@variantMap), varNames=as.character(variant.variantMap@variantMap))
varAlleleMap <- merge(knownAlleleTable, dataAlleleTable , by="alleleSeq")
}
# deprecated and/or defunct
makeVarAlleleMap.list <- function(alleleDb, varDb,alleleMarkers=names(alleleDb),varMarkers=names(varDb)) {
knownAlleleTable <- data.frame()
for(thisMarker in alleleMarkers) {
knownAlleleTable <- rbind(knownAlleleTable , data.frame(alleleSeq=names(alleleDb[[thisMarker]]@alleleMap), knownAlleles=as.character(alleleDb[[thisMarker]]@alleleMap)))
}
dataAlleleTable <- data.frame()
for(thisMarker in varMarkers) {
# this first line is what it SHOULD be like, once mlgtResult is updated to match the alleleDb format. Need new class: alleleDb
dataAlleleTable <- rbind(dataAlleleTable , data.frame(alleleSeq=names(varDb[[thisMarker]]@alleleMap), varNames=as.character(varDb[[thisMarker]]@alleleMap)))
#dataAlleleTable <- rbind(dataAlleleTable , data.frame(alleleSeq=names(varDb[[thisMarker]]), varNames=as.character(varDb[[thisMarker]])))
}
varAlleleMap <- merge(knownAlleleTable, dataAlleleTable , by="alleleSeq")
}
vectorOrRepeat <- function(paramValue, requiredLength) {
# Used by callGenotypes.mgltResult() to equalise lengths of parameter vectors when one has length > 1
if(length(paramValue) == requiredLength) {
return(paramValue)
} else {
if(length(paramValue) == 1) {
return(rep(paramValue, requiredLength))
} else {
stop(paste("Parameter has length",length(paramValue) ,"but does not match required length", requiredLength))
}
}
}
# replacement for vectorOrRepeat for cases where custom methods are allowed in callGenotypes().
# Returns a list of lists each identical except where user specified a vector of parameter values.
makeBigParamList <- function(..., markerCount) {
params <- list(...)
paramBigList <- list()
for(i in 1:markerCount) {
paramBigList[[i]] <- params
}
lengthList <- lapply(params , length)
vecParams <- which(lengthList > 1)
if(length(vecParams) > 0) {
vecNames <- names(params)[vecParams]
#cat(vecParams)
if(any(lengthList[vecParams] != markerCount)) { stop("Vector supplied that does not match length of markerList") }
for(i in 1:length(vecParams)) {
for(j in 1:markerCount) {
paramBigList[[j]][[vecNames[i]]] <- params[[vecNames[i]]][j]
}
}
}
return(paramBigList)
}
# Used for approximate (BLAST) variant to allele matching.
# returns a standard blast table with single best hit per query.
makeVarAlleleBlastMap <- function(allele.variantMap, variant.variantMap) {
pathNames <- c("BLASTALL_PATH","FORMATDB_PATH","FASTACMD_PATH","MUSCLE_PATH")
for(thisPath in pathNames) {
if(nchar(Sys.getenv(thisPath)) < 1) {
stop(paste(thisPath,"has not been set!"))
}
# shellQuote any paths containing spaces.
# Can't use variables in Sys.setenv
#if(length(grep(" ",Sys.getenv(thisPath), fixed=T)) > 0 ) Sys.setenv(thisPath= shQuote(thisPath))
}
formatdbPath <- Sys.getenv("FORMATDB_PATH")
fastacmdPath <- Sys.getenv("FASTACMD_PATH")
blastAllPath <- Sys.getenv("BLASTALL_PATH")
# shellQuote any paths containing spaces.
if(length(grep(" ",formatdbPath, fixed=T)) > 0 ) formatdbPath <- shQuote(formatdbPath)
if(length(grep(" ",fastacmdPath, fixed=T)) > 0 ) fastacmdPath <- shQuote(fastacmdPath)
if(length(grep(" ",blastAllPath, fixed=T)) > 0 ) blastAllPath <- shQuote(blastAllPath)
thisMarker <- getName(allele.variantMap@reference)
cat(thisMarker)
#export known variants to fasta (may need to sort out names)
knownAsFastaFile <- paste(thisMarker, "knownAlleles.fasta", sep=".")
# some sub-alleles may have zero length (they didn't align at all with marker)
thisVariantMap <- allele.variantMap@variantMap
thisVariantMap <- thisVariantMap[nchar(names(thisVariantMap)) > 0]
#write the known alleles to a fasta file. The concatentated names must be truncated to XX chars for blast to run.
write.fasta(as.list(names(thisVariantMap)),substring(as.character(thisVariantMap),1,60), file.out=knownAsFastaFile )
#create blast DB of known variants.
dbName <- paste(thisMarker,"knownAlleles",sep=".")
setUpBlastDb(knownAsFastaFile , formatdbPath, blastdbName=dbName )
#export new variants to fasta
newVarsAsFastaFile <- paste(thisMarker, "newVars.fasta", sep=".")
write.fasta(as.list(names(variant.variantMap@variantMap)),as.character(variant.variantMap@variantMap), file.out=newVarsAsFastaFile )
#blast new variants against known DB
newVarBlastResultFile <- paste(thisMarker, "blastOut.newVars.tab", sep=".")
blastCommand <- paste(blastAllPath , "-p blastn -d", dbName , "-i", newVarsAsFastaFile , "-W", 11 , "-m 8 -b 1 -o", newVarBlastResultFile)
system(blastCommand)
#open and retrieve the results.
topHits <- getTopBlastHits(newVarBlastResultFile)
#return as a useful lookuptable
}
## call genotypes on a table of variant counts. Can select specific markers/samples to return.
#' Default internal methods for \code{\link{callGenotypes}}
#'
#' This is the default method to call genotypes from a table of variant counts.
#' Methods:-
#' \describe{
#' \item{`callGenotypes.default'}{Three sequential steps for each marker/sample pair:
#' \enumerate{
#' \item {if the number of reads is less than \code{minTotalReads} the genotype is \emph{`tooFewReads'} }
#' \item {if the difference between the sum of counts of the top two variants and the count of the third most variant, expressed as proportion of total, is less than \code{minDiffToVarThree}, OR the third most abundant variant accounts for more than maxPropVarThree (default=0.1) of the reads, then the genotype is \emph{`complexVars'}}
#' \item {if the difference between the counts of top two variants, expressed as a proportion of the total, is greater than or equal to \code{minPropDiffHomHetThreshold}, then the genotype is \emph{HOMOZYGOTE}. Otherwise it is \emph{HETEROZYGOTE}. }
#' }
#' }
#' }
#'
#' @param table The table of sequence counts as in the markerSampleTable of an mlgtResult object.
#' @param minTotalReads Minimum number of reads before attempting to call genotypes
#' @param minDiffToVarThree Difference between sum of counts of top two variants and the count of the third most frequent variant, expressed as proportion of total.
#' @param minPropDiffHomHetThreshold Difference between counts of top two variants. One way to distinguish HOMOZYGOTES and HETEROZYGOTES.
#' @param maxPropVarThree Also call as 'complexVars' if the third variant accounts for more than this proportion of used reads (default=0.1)
#' @return A data.frame identical to those in markerSampleList but with additional columns giving parameter values,
#' and a 'status' column giving the genotype status.
callGenotypes.default <- function(table, minTotalReads=50, minDiffToVarThree=0.4,
minPropDiffHomHetThreshold=0.3, maxPropVarThree=0.1) {
#table$genotype
table$status <- "notCalled"
enoughReads <- table$numbSeqs >= minTotalReads
table$status[!enoughReads] <- "tooFewReads"
# difference between sum of vars 1 + 2 and var 3, as proportion of total
# > 0.5 is good. <0.3 not good. 0.4 as cut-off for now?
table$diffToVarThree <- with(table, ((varFreq.1+varFreq.2)-varFreq.3)/numbSeqs)
table$propThree <- with(table, (varFreq.3)/numbSeqs)
#distinctVars <- with(table, diffToVarThree >= minDiffToVarThree)
distinctVars <- with(table, (diffToVarThree >= minDiffToVarThree) & propThree < maxPropVarThree)
table$status[enoughReads & !distinctVars] <- "complexVars"
# difference between var 1 and var2 as proportion of total
# homozygote: >0.3, often > 0.5
# heterozygote: <0.25, often < 0.1
table$propDiffHomHet <- with(table, ((varFreq.1-varFreq.2)/numbSeqs))
eligible <- (enoughReads & distinctVars)
table$status[eligible] <- ifelse((table$propDiffHomHet[eligible] >= minPropDiffHomHetThreshold), "HOMOZYGOTE","HETEROZYGOTE")
#table$homozygote <- with(table, ((varFreq.1-varFreq.2)/numbSeqs) >= minPropDiffHomHetThreshold)
return(table)
}
## example custom function
callGenotypes.custom <- function(table) {
table$status <- "notCalled"
return(table)
}
## TODO: split callGenotypes into subfunctions. Perform alleles matching and approx allele matching first if elected.
## Then do the parameter estimatation and HOM/HET calls.
## Then choose the representative alleles (use.1, use.2) and give sequences.
## To make this customisable, would need to include '...' as first argument so that users can add in variables. T
## This function would then pass those variables to the user supplied function
## Some rules will have to be made on required input and output.
## e.g. result should still be list of class "genotypeCall" but used could specify what the table can contain.
## and the user supplied parameters could be stored within the callParameters slot.
## IMPORTANT, would also need to sort out the generic set-up given below (probably no longer needed).
# generic method for callGenotypes.
#' Make genotype calls
#'
#' Apply a genotype call method to a table or list of tables of variant data such as the \code{markerSampleList} table of an \code{\link{mlgtResult}}.
#'
#' After \code{\link{mlgt}} has generated tables of the most common variants assigned in each marker/sample pair, an attempt can be made to call genotypes.
#' This is kept separate because users might want to try different calling methods and have the option to map to a known set of alleles. Currently, only
#' one method is implemented (\emph{`custom'}). See \code{\link{callGenotypes.default}}.
#' This function also includes the option to map variants to a list of known alleles created using \code{\link{createKnownAlleleList}}. The basic method makes only perfect matches but a secondary method can be triggered (approxMatching=TRUE) to find the allele with the greatest similarity using a local BLAST search.
#'
#'
#' @param resultObject An object of class \code{\link{mlgtResult}}, as returned by \code{\link{mlgt}}
#' @param alleleDb A list of \code{\link{variantMap}} objects derived from known alleles. As made by
#' \code{\link{createKnownAlleleList}}
#' @param method How to call genotypes. Currently only "callGenotypes.default" is implemented. Users can define
#' their own methods as R functions (see the vignette).
#' @param markerList For which of the markers do you want to call genotypes (default is all)?
#' @param sampleList For which of the samples do you want to call genotypes (default is all)?
#' @param mapAlleles FALSE/TRUE. Whether to map variants to db \option{alleleDb} of known alleles.
#' @param approxMatching If TRUE, a BLAST search is also performed to find matches (slower). Additional columns are added to the genoytpeTable
#' @param numbAllelesToMatch How many of the named variants should be matched to the alleleDb. Default=2.
#' @param ... Other parameter values will be passed to custom methods such as \code{\link{callGenotypes.default}}
#'
#' @return list of call results including the call parameters and a table of calls (class \code{\link{genotypeCall}}). If an mlgtResult object was supplied then a list of \code{\link{genotypeCall}} objects will be returned, each named by marker.
#'
#' @export
#' @docType methods
#' @aliases callGenotypes.mlgtResult
#' @examples \dontrun{
#' data("mlgtResult", package="mlgt")
#' my.mlgt.Result
#' # the default method
#' my.genoytpes <- callGenotypes(my.mlgt.Result)
#' # using a custom method
#' callGenotypes.custom <- function(table, maxPropUniqueVars=0.5) {
#' table$status <- "notCalled"
#' table$propUniqueVars <- table$numbVar/table$numbSeq
#' table$status <- ifelse(table$propUniqueVars <= maxPropUniqueVars,"good", "bad")
#' return(table)
#' }
#' my.custom.Genotypes <- callGenotypes(my.mlgt.Result, method="callGenotypes.custom")
#' }
callGenotypes <- function(resultObject, method="callGenotypes.default",
markerList=names(resultObject@markers),
sampleList=resultObject@samples, mapAlleles=FALSE, alleleDb=NULL, approxMatching=FALSE,
numbAllelesToMatch=2, ... ) {
## FM requested marker specific parameters.
## test for vectors in any of the calling parameters.
## if all are single, apply genotyping to one large table of all results,
## if any are vectors, need to apply genotyping to each marker separately.
## Should mark if different thresholds used.
## need to test that the threshold vector matches the markerlist length.
runTable <- data.frame()
genotypeTable <- data.frame()
callResults <- list()
# if(length(minTotalReads) > 1 | length(minDiffToVarThree) > 1 | length(minPropDiffHomHetThreshold) > 1 ) {
# find parameters as vectors and test the lengths. Set those which are only 1 to be length of markerList.
#minTotalReads <- vectorOrRepeat(minTotalReads, length(markerList))
#minDiffToVarThree <- vectorOrRepeat(minDiffToVarThree, length(markerList))
#minPropDiffHomHetThreshold<- vectorOrRepeat(minPropDiffHomHetThreshold, length(markerList))
longParamList <- makeBigParamList(..., markerCount=length(markerList))
# multiple parameter values set. Genotype each marker separately
for(i in 1:length(markerList)) {
thisMarker <- markerList[i]
subTable <- resultObject@markerSampleList[[thisMarker]]
subTable <- subTable[match(sampleList,subTable$sample),]
numbAllelesToMatch.used <- numbAllelesToMatch
if(nrow(subTable) < 1) {
# do nothing with this marker
warning(paste("No data for:",thisMarker))
} else {
thisParamList <- longParamList[[i]]
thisParamList[['table']] <- subTable
genotypeTable <- do.call(method, thisParamList )
countNamedVars <- max(as.numeric(sub('varName.','',names(genotypeTable)[grep('varName',names(genotypeTable))])))
if(countNamedVars < numbAllelesToMatch) {
warning(paste("Cannot match more variants than already have names:", thisMarker))
numbAllelesToMatch.used <- countNamedVars
}
#genotypeTable <- callGenotypes.table(subTable , alleleDb=alleleDb, method=method,minTotalReads=minTotalReads[i],
# minDiffToVarThree=minDiffToVarThree[i],
# minPropDiffHomHetThreshold=minPropDiffHomHetThreshold[i], mapAlleles=mapAlleles)
#genotypeTable <- rbind(genotypeTable , subGenoTable)
if(mapAlleles) {
# 2-step strategy.
# 1. Try perfect matching first. Quick and perfect.
# Keep track of which alleles were matched this way
# 2. Match with BLAST (build blast DB of known alleles and blast all new variants (once) against this.
# Record best hit and quality of best hit (percentID, percentlength)
if(is.null(alleleDb)) {
warning("No alleleDb specified\n")
} else {
if(is.null(alleleDb[[thisMarker]])) {
warning(paste("No known alleles for",thisMarker))
for(k in 1:numbAllelesToMatch.used) {
#genotypeTable$allele.1 <- "noKnownAlleles"
#genotypeTable$allele.2 <- "noKnownAlleles"
genotypeTable[paste('allele',k,sep=".")] <- "noKnownAlleles"
}
if(approxMatching) { # need to match column names
for(k in 1:numbAllelesToMatch.used) {
genotypeTable[paste('allele',k,'approx',sep=".")] <- NA
}
#genotypeTable$allele.1.approx <- NA
#genotypeTable$allele.2.approx <- NA
}
} else {
if(is.null(resultObject@alleleDb[[thisMarker]])) {
warning(paste("No variants for",thisMarker))
#genotypeTable$allele.1 <- NA
#genotypeTable$allele.2 <- NA
for(k in 1:numbAllelesToMatch.used) {
genotypeTable[paste('allele',k,sep=".")] <- NA
}
if(approxMatching) { # need to match column names
for(k in 1:numbAllelesToMatch.used) {
genotypeTable[paste('allele',k,'approx',sep=".")] <- NA
}
}
} else {
#varAlleleMap <- makeVarAlleleMap(alleleDb, resultObject@alleleDb, alleleMarkers=markerList, varMarkers=markerList)
varAlleleMap <- makeVarAlleleMap(allele.variantMap=alleleDb[[thisMarker]], variant.variantMap=resultObject@alleleDb[[thisMarker]])
#genotypeTable$allele.1 <- varAlleleMap$knownAlleles[match(genotypeTable$varName.1, varAlleleMap$varNames)]
#genotypeTable$allele.2 <- varAlleleMap$knownAlleles[match(genotypeTable$varName.2, varAlleleMap$varNames)]
for(k in 1:numbAllelesToMatch.used) {
#cat(paste('varName',k,sep="."))
genotypeTable[paste('allele',k,sep=".")] <- varAlleleMap$knownAlleles[match(genotypeTable[,paste('varName',k,sep=".")], varAlleleMap$varNames)]
}
if(approxMatching) { # perform approx matching by BLAST
cat("Attempting to find approximate matches using BLAST\n")
varAlleleBlastMap <- makeVarAlleleBlastMap(allele.variantMap=alleleDb[[thisMarker]], variant.variantMap=resultObject@alleleDb[[thisMarker]])
for(k in 1:numbAllelesToMatch.used) {
genotypeTable[paste('allele',k,'approx',sep=".")] <- varAlleleBlastMap$subject[match(genotypeTable[,paste('varName',k,sep=".")], varAlleleBlastMap$query)]
}
#genotypeTable$allele.1.approx <- varAlleleBlastMap$subject[match(genotypeTable$varName.1, varAlleleBlastMap$query)]
#genotypeTable$allele.2.approx <- varAlleleBlastMap$subject[match(genotypeTable$varName.2, varAlleleBlastMap$query)]
}
}
}
}
}
callResults[[thisMarker]] <- new("genotypeCall",
projectName=resultObject@projectName,
runName=resultObject@runName,
marker=thisMarker ,
genotypeTable=genotypeTable,
callMethod=method,
callParameters=longParamList[[i]],
mappedToAlleles=mapAlleles,
alleleDbName="NeedToSetThis" )
}
}
return(callResults)
}
### ver 0.14 have removed generics for callGenotypes to make mixed use of '...' and named parameters.
# generic method for callGenotypes.
## Make genotype calls
##
## Apply a genotype call method to a table or list of tables of variant data such as the \code{markerSampleList} table of an \code{\link{mlgtResult}}.
##
## After \code{\link{mlgt}} has generated tables of the most common variants assigned in each marker/sample pair, an attempt can be made to call genotypes.
## This is kept separate because users might want to try different calling methods and have the option to map to a known set of alleles. Currently, only
## one method is implemented (\emph{`custom'}).
## Methods:-
## \describe{
## \item{`callGenotypes.default'}{Three sequential steps for each marker/sample pair:
## \enumerate{
## \item {if the number of reads is less than \code{minTotalReads} the genotype is \emph{`tooFewReads'} }
## \item {if the difference between the sum of counts of the top two variants and the count of the third most variant, expressed as proportion of total, is less than \code{minDiffToVarThree}, then the genotype is \emph{`complexVars'}}
## \item {if the difference between the counts of top two variants, expressed as a proportion of the total, is greater than or equal to \code{minPropDiffHomHetThreshold}, then the genotype is \emph{HOMOZYGOTE}. Otherwise it is \emph{HETEROZYGOTE}. }
## }
## }
## }
##
##
## @param resultObject An object of class \code{\link{mlgtResult}}, as returned by \code{\link{mlgt}}
## @param table [Separate usage] A table of variant counts.
## @param alleleDb A list of \code{\link{variantMap}} objects derived from known alleles. As made by
## \code{\link{createKnownAlleleList}}
## @param method How to call genotypes. Currently only "callGenotypes.default" is implemented. Users can define
## their own methods as R functions (see the vignette).
## @param markerList For which of the markers do you want to call genotypes (default is all)?
## @param sampleList For which of the samples do you want to call genotypes (default is all)?
## @param mapAlleles FALSE/TRUE. Whether to map variants to db \option{alleleDb} of known alleles.
##
## @return list of call results including the call parameters and a table of calls (class \code{\link{genotypeCall}}). If an mlgtResult object was supplied then a list of \code{\link{genotypeCall}} objects will be returned, each named by marker.
##
## @export
## @docType methods
## @aliases callGenotypes.mlgtResult
#setGeneric("callGenotypes", function(resultObject, table, alleleDb=NULL, method="custom", minTotalReads=50, maxPropUniqueVars=0.8,
# minPropToCall=0.1, minDiffToVarThree=0.4,
# minPropDiffHomHetThreshold=0.3, markerList=names(resultObject@markers),
# sampleList=resultObject@samples, mapAlleles=FALSE, ...)
# standardGeneric("callGenotypes")
# )
#setMethod("callGenotypes", signature(resultObject="missing", table="data.frame", alleleDb="ANY", method="ANY", minTotalReads="ANY", maxPropUniqueVars="ANY",
# minPropToCall="ANY", minDiffToVarThree="ANY",minPropDiffHomHetThreshold="ANY", markerList="ANY",
# sampleList="ANY", mapAlleles="ANY"),
# definition=callGenotypes.default )
#setMethod("callGenotypes", signature(resultObject="mlgtResult", table="missing", alleleDb="ANY", method="ANY", minTotalReads="ANY", maxPropUniqueVars="ANY",
# minPropToCall="ANY", minDiffToVarThree="ANY",minPropDiffHomHetThreshold="ANY", markerList="ANY",
# sampleList="ANY", mapAlleles="ANY"),
# definition=callGenotypes.mlgtResult )
#setMethod("callGenotypes", signature(resultObject="mlgtResult", table="missing"),
# definition=callGenotypes.mlgtResult )
# default for 'file' could be derived from project, run, marker attributes of genotypeCall.
writeGenotypeCallsToFile.genotypeCall <- function(genotypeCall, filePrefix="genoCalls", file=paste(filePrefix,genotypeCall@projectName,genotypeCall@runName,genotypeCall@marker,"tab",sep="."),
writeParams=FALSE, appendValue=FALSE) {
if(writeParams) {
cat("# Genotype calls generated by R package 'mlgt' (", packageVersion("mlgt"),")", date(),"\n",file=file, append=appendValue)
appendValue=TRUE
cat("# Project:", genotypeCall@projectName,"\n", file=file, append=appendValue)
cat("# Run", genotypeCall@runName,"\n", file=file, append=appendValue)
cat("# Marker", genotypeCall@marker,"\n", file=file, append=appendValue)
cat("# Call method:", genotypeCall@callMethod,"\n", file=file, append=appendValue)
cat("# Call parameters:-\n", file=file, append=appendValue)
for(i in 1:length(genotypeCall@callParameters)) {
thisParam <- unlist(genotypeCall@callParameters[i])
cat("#\t",names(thisParam),"=", thisParam,"\n", file=file, append=appendValue)
}
cat("# MappedToAlleles: ", genotypeCall@mappedToAlleles,"\n", file=file, append=appendValue)
cat("# AlleleDb: ", genotypeCall@alleleDbName,"\n", file=file, append=appendValue)
}
write.table(genotypeCall@genotypeTable, file=file, append=appendValue, row.names=F, quote=F, sep="\t")
cat("Results written to",file,"\n")
#return(invisible(1))
}
# Need function to write genotype calls as a single file.
writeGenotypeCallsToFile.list <- function(callList, filePrefix="genoCalls", file, singleFile=FALSE,writeParams=FALSE) {
if(singleFile) {
masterTable <- data.frame()
for(i in 1:length(callList)) {
masterTable <- rbind(masterTable , callList[[i]]@genotypeTable)
}
write.table(masterTable , file=file, row.names=F, quote=F, sep="\t")
cat("Results written to",file,"\n")
} else {
#invisible(lapply(callList, FUN=function(x) writeGenotypeCallsToFile.genotypeCall(x,writeParams=writeParams)))
cat(length(lapply(callList, FUN=function(x) writeGenotypeCallsToFile.genotypeCall(x,writeParams=writeParams, filePrefix=filePrefix))), "files written\n")
}
}
# DONE: allow write to single file when some markers mapped to alleles and some not. Consistent return of empty/NA/NaN columns?
# DONE: allow prefix to denote instance of filename - otherwise different genotype call sets will overwrite each other.
# generic method. Need to give defaults if defaults to be set in specific forms.
#' Write genotype calls to file
#'
#' A genotype call table or a list of tables can be written to tab-delimited file(s).
#'
#' This function is quite flexible and can output a single table of concatenated results or a series of individual files.
#' Call parameters can be included above each table but be careful doing this when \code{singleFile=TRUE}
#'
#' @param callList A \code{list} of genotypes calls.
#' @param genotypeCall Alternatively, supply a single table of genotype calls
#' @param filePrefix A prefix to add to the start of each file name. Useful to distinguish sets of genotype call results from same run.
#' @param file The file to write to. If none specified, function will attempt to make one. Ignored if \option{singleFile = TRUE}.
#' @param singleFile FALSE/TRUE whether to concatenate results from a list of genotypeCalls
#' @param writeParams List call parameter values at top of file? Beware using this option when \option{singleFile = TRUE}
#' @param appendValue Used internally to concatenate results.
#'
#' @return Writes tables in the current working directory.
#'
#' @rdname writeGenotypeCallsToFile-methods
#' @export
#' @aliases writeGenotypeCallsToFile.list,writeGenotypeCallsToFile.genotypeCall
#' @examples \dontrun{
#' data("mlgtResult", package="mlgt")
#' my.genoytpes <- callGenotypes(my.mlgt.Result)
#' writeGenotypeCallsToFile(my.genotypes)
#' }
setGeneric("writeGenotypeCallsToFile", function(callList, genotypeCall, filePrefix="genoCalls", file="", singleFile=FALSE, writeParams=FALSE, appendValue=FALSE) standardGeneric("writeGenotypeCallsToFile"))
#' @rdname writeGenotypeCallsToFile-methods
#' @aliases writeGenotypeCallsToFile,list,missing-method
setMethod("writeGenotypeCallsToFile", signature(callList="list", genotypeCall="missing", filePrefix="ANY", file="ANY", singleFile="ANY",
writeParams="ANY", appendValue="ANY"),
definition=writeGenotypeCallsToFile.list)
#' @rdname writeGenotypeCallsToFile-methods
#' @aliases writeGenotypeCallsToFile,missing,genotypeCall-method
setMethod("writeGenotypeCallsToFile", signature(callList="missing", genotypeCall="genotypeCall", filePrefix="ANY", file="ANY", singleFile="ANY",
writeParams="ANY", appendValue="ANY"),
definition=writeGenotypeCallsToFile.genotypeCall )
#writeGenotypeCallsToFile <- function(callList, genotypeCall, file="", singleFile=FALSE, writeParams=FALSE, appendValue=FALSE) attributes(callList)
########################## plotting
#' Plot BLAST statisitics for one marker
#'
#' \code{\link{prepareMlgtRun}} produces several BLAST tables. It is instructive to plot the BLAST results and assess the performance
#' of different markers.
#'
#' This function is used to plot a series of histograms based on BLAST statistics.
#'
#' @param blastTable The file of BLAST results.
#' @param subject The name of a single marker
#'
#' @return Plots three histograms based on the BLAST statistics 'Alignment length', 'Bit Score' and 'Percent Identity'
#' @export
#' @seealso \code{\link{printBlastResultGraphs}}
inspectBlastResults <- function(blastTable, subject) {
#topHits <- getTopBlastHits(resultFile)
#topHits$strand <- ifelse(topHits$s.end > topHits$s.start, 1,2)
hitCount <- length(which(blastTable$subject == subject))
if(hitCount > 0) {
#subject <- "DPA1_E2"
breakValue <- max(10, 10^(floor(log10(hitCount)))) # favour a large number of breaks. At least 10.
par(mfrow=c(1,3))
hist(blastTable$ali.length[blastTable$subject == subject], breaks=breakValue, xlab="Alignment Length", main=subject)
hist(blastTable$bit.score[blastTable$subject == subject], breaks=breakValue, xlab="Bit Score", main=subject)
hist(blastTable$percent.id[blastTable$subject == subject], breaks=breakValue, xlab="% identity", main=subject)
} else {
warning(paste("No data for ", subject))
}
}
#' Plot BLAST statistics for several markers to file
#'
#' Plot the BLAST statistics easily for all markers of an \code{\link{mlgtResult}} object.
#'
#'
#'
#' @param designObject An object of class \code{\link{mlgtDesign}} which will contain the name of the blast results file \code{designObject@@markerBlastResults}
#' @param markerList Which markers to output. Defaults to \code{designObject@@markers}
#' @param fileName Defaults to "blastResultGraphs.pdf"
#'
#' @return Plots BLAST results to a pdf file.
#' @export
#' @seealso \code{\link{inspectBlastResults}}
printBlastResultGraphs <- function(designObject, markerList=designObject@markers, fileName="blastResultGraphs.pdf") {
topHits <- getTopBlastHits(designObject@markerBlastResults)
pdf(fileName,height=4)
for(thisMarker in names(markerList)) {
inspectBlastResults(topHits, thisMarker )
}
dev.off()
}
########## Multiple methods for plotGenotypeEvidence
#
plotGenotypeEvidence.genotypeCall <- function(genotypeCall) {
genotypeTable <- genotypeCall@genotypeTable
thisMarker <- genotypeCall@marker
# next three lines are a temp fix to retrieve default call parameters, which are not retained by callGenotypes.default(). May remove this function anyway.
minTotalReads <- ifelse(exists("genotypeCall@callParameters[['minTotalReads']]"),genotypeCall@callParameters['minTotalReads'],50)
minDiffToVarThree <- ifelse(exists("genotypeCall@callParameters[['minDiffToVarThree']]"),genotypeCall@callParameters['minDiffToVarThree'],0.4)
minPropDiffHomHetThreshold <- ifelse(exists("genotypeCall@callParameters[['minPropDiffHomHetThreshold']]"),genotypeCall@callParameters['minPropDiffHomHetThreshold'],0.3)
if(sum(genotypeTable$numbSeqs) < 1) {
warning(paste("No seqs to plot for",thisMarker), call.=F)
} else {
statusList <- as.factor(genotypeTable$status)
pchList <- statusList
levels(pchList) <- (1:nlevels(pchList ))
#levels(pchList) <- 20+(1:nlevels(pchList ))
par(mfrow=c(2,3))
hist( genotypeTable$numbSeqs, breaks=20, main=thisMarker, xlab="numbSeqs"); abline(v=minTotalReads , lty=2)
hist( genotypeTable$diffToVarThree, breaks=20, main=thisMarker, xlab="diffToVarThree", xlim=c(0,1)); abline(v=minDiffToVarThree , lty=2)
hist(genotypeTable$propDiffHomHet, breaks=20, main=thisMarker, xlab="propDiffHomHet", xlim=c(0,1)) ; abline(v=minPropDiffHomHetThreshold , lty=2)
plot(genotypeTable$diffToVarThree,genotypeTable$propDiffHomHet, main=thisMarker, xlab="diffToVarThree", ylab="propDiffHomHet",xlim=c(0,1), ylim=c(0,1),pch=as.numeric(levels(pchList))[pchList]); abline(h=minPropDiffHomHetThreshold , lty=2); abline(v=minDiffToVarThree , lty=2)
legend("topleft", levels(as.factor(genotypeTable$status)), pch=as.numeric(levels(pchList)))
plot(genotypeTable$numbSeqs,genotypeTable$diffToVarThree, main=thisMarker, xlab="numbSeqs", ylab="diffToVarThree", ylim=c(0,1),pch=as.numeric(levels(pchList))[pchList]); abline(h=minDiffToVarThree , lty=2); abline(v=minTotalReads , lty=2)
plot(genotypeTable$numbSeqs,genotypeTable$propDiffHomHet, main=thisMarker, xlab="numbSeqs", ylab="propDiffHomHet", ylim=c(0,1),pch=as.numeric(levels(pchList))[pchList]); abline(h=minPropDiffHomHetThreshold , lty=2); abline(v=minTotalReads , lty=2)
}
}
plotGenotypeEvidence.genotypeCall.file <- function(genotypeCall, file) {
if(length(grep(".pdf$", file) ) < 1) {
file <- paste(file,"pdf", sep=".")
}
pdf(file)
plotGenotypeEvidence.genotypeCall(genotypeCall)
dev.off()
cat("Results output to", file, "\n")
}
# list must have a file specified for output
plotGenotypeEvidence.list <- function(callList, file) {
if(length(grep(".pdf$", file) ) < 1) {
file <- paste(file,"pdf", sep=".")
}
pdf(file)
for(thisCall in callList) {
#cat(thisCall@marker)
plotGenotypeEvidence.genotypeCall(thisCall)
}
dev.off()
cat("Results output to", file, "\n")
}
#' Plot genotyping evidence
#'
#' Plot the distributions of values used in calling genotypes.
#'
#' Currently only makes sense with "custom" method. The resulting plots are
#' \enumerate{
#' \item {Histogram of the number of sequences assigned to each sample}
#' \item {Histogram of diffToVarThree parameter. Used to decide whether to make the call}
#' \item {Histogram of propDiffHomHet parameter. Used to distinguish HOMOZYGOTES and HETEROZYGOTES}
#' \item {propDiffHomHet against diffToVarThree }
#' \item {diffToVarThree against number of sequences}
#' \item {propDiffHomHet against number of sequences}
#' }
#'
#' @param callList A \code{list} of genotypes calls.
#' @param genotypeCall A single table of genotype calls
#' @param file The file to write to.
#'
#' @return Creates six plots for each marker with a genotypeCall table. See \code{details}.
#'
#' @export
#' @seealso \code{\link{callGenotypes}}
#' @aliases plotGenotypeEvidence.list
#' @aliases plotGenotypeEvidence.genotypeCall.file
#' @aliases plotGenotypeEvidence.genotypeCall
#' @aliases plotGenotypeEvidence,missing,list,character-method
#' @aliases plotGenotypeEvidence,genoytpeCall,missing,missing-method
#' @aliases plotGenotypeEvidence,genoytpeCall,missing,character-method
#' @rdname plotGenotypeEvidence-methods
#' @examples \dontrun{
#' data("mlgtResult", package="mlgt")
#' my.genoytpes <- callGenotypes(my.mlgt.Result)
#' plotGenotypeEvidence(genotypeCall=my.genotypes[["DPA1_E2"]])
#' }
setGeneric("plotGenotypeEvidence", function(genotypeCall, callList, file) standardGeneric("plotGenotypeEvidence"))
#' @rdname plotGenotypeEvidence-methods
#' @aliases plotGenotypeEvidence,missing,list,character-method
setMethod("plotGenotypeEvidence", signature(genotypeCall="missing", callList="list", file="character"), definition=plotGenotypeEvidence.list)
#' @rdname plotGenotypeEvidence-methods
#' @aliases plotGenotypeEvidence,genotypeCall,missing,character-method
setMethod("plotGenotypeEvidence", signature(genotypeCall="genotypeCall", callList="missing", file="character"), definition=plotGenotypeEvidence.genotypeCall.file)
#' @rdname plotGenotypeEvidence-methods
#' @aliases plotGenotypeEvidence,genotypeCall,missing,missing-method
setMethod("plotGenotypeEvidence", signature(genotypeCall="genotypeCall", callList="missing", file="missing"), definition=plotGenotypeEvidence.genotypeCall)
#plotGenotypeEvidence <- function(callList, genotypeCall, file) attributes(genotypeCall)
#' Dump variants as fasta
#'
#' Output unique variants to one or more fasta files.
#'
#' This is a stop-gap function while I decide how best to handle output of full sequences.
#'
#' @param resultObject An object of class \code{\link{mlgtResult}} containing the sequence variants.
#' @param markers For which markers do you want to output sequences.
#' @param file An output file name. If not supplied, one is created.
#' @param singleFile Whether to output results for all markers to a single file or to one file per marker.
#'
#' @return Writes fasta files in the current directory.
#' @export
dumpVariantMap.mlgtResult <- function(resultObject, markers=names(resultObject@markers),
file=paste(resultObject@projectName,resultObject@runName,"seqDump",sep="."),
singleFile=TRUE) {
file <- sub("\\.fasta","",file)
writeOption <- ifelse(singleFile,"a","w") # used by write.fasta. "a" = append
baseFileName <- file
for(thisMarker in markers) {
useFile <- ifelse(singleFile,paste(baseFileName,"fasta",sep="."),paste(baseFileName,thisMarker,"fasta",sep="."))
theSeqs <- names(resultObject@alleleDb[[thisMarker]]@variantMap)
theNames <- as.character(resultObject@alleleDb[[thisMarker]]@variantMap)
write.fasta(lapply(theSeqs,s2c), theNames, file.out=useFile , open=writeOption )
}
}
#dumpVariantMap.variantMap
## TODO docs, internal
stripGapColumns <- function(alignment) {
gap_index <- which(con(alignment, method="threshold",threshold=(1-1e-07)) == '-') # bug in seqinr: threshold =1 returns NA for all.
if(length(gap_index) < 1) { # nothing to strip
if(exists("verbose")) cat("No gap columns to remove ")
return(alignment)
}
alignMatrix <- as.matrix(alignment)[,-c(gap_index)]
if(exists("verbose")) cat(paste("removed",length(gap_index),"gap columns "))
deGapSeqs <- apply(alignMatrix,1,c2s)
deGapAlign <- as.alignment(alignment$nb,alignment$nam,deGapSeqs)
return(deGapAlign)
}
## TODO docs, internal
## supply an UN-PACKKED alignment (including duplicated sequences)
errorCorrect.alignment <- function(alignment, correctThreshold=0.01) {
#alignment.corrected <- alignment
minDepth <- ceiling(1/correctThreshold) # no point attempting if less depth than this.
if(alignment$nb < minDepth) {
warning(paste("No correction possible with depth of", alignment$nb, "and correction threshold of", correctThreshold, "\n"))
return(alignment)
}
thisProfile <- consensus(alignment, method="profile")
thisConsensus <- con(alignment, method="threshold", threshold=correctThreshold )
totalSeqs <- alignment$nb
totalLetters <- nrow(thisProfile)
mafList <- apply(thisProfile, 2, FUN=function(x) (sort(x)[totalLetters-1] / totalSeqs))
correct_index <- intersect(which(mafList < correctThreshold), which(mafList > 0))
#remove NAs from index.
correct_index <- correct_index[!is.na(thisConsensus[correct_index])]
alignment.matrix <- as.matrix.alignment(alignment)
alignment.matrix[,c(correct_index)] <- t(apply(alignment.matrix,1,FUN=function(x) x[c(correct_index)] <- thisConsensus[correct_index]))
seqList.correct <- apply(alignment.matrix,1,c2s)
alignment.corrected <- as.alignment(nb=length(seqList.correct),nam=names(seqList.correct),seq=seqList.correct)
alignment.corrected <- stripGapColumns(alignment.corrected)
return(alignment.corrected)
}
## TODO docs, incorporate into mlgt() lots of duplicated code, README
##
## wrapper function to perform errorCorrect on an existing mlgtResult object
## this is basically mlgt() without any of the assignment and alignment and a call to errorCorrect()
## Examples:-
## my.corrected.mlgt.Result <- errorCorrect.mlgtResult(my.mlgt.Result)
## my.corrected.mlgt.Result <- errorCorrect.mlgtResult(my.mlgt.Result,correctThreshold=0.05)
## alignReport(my.mlgt.Result, fileName="alignReportOut.pdf", method="profile")
## alignReport(my.corrected.mlgt.Result, fileName="alignReportOut.corrected.pdf", method="profile")
## alignReport(my.mlgt.Result, fileName="alignReportOut.hist.pdf", method="hist")
## alignReport(my.corrected.mlgt.Result, fileName="alignReportOut.hist.corrected.pdf")
## my.genotypes <- callGenotypes(my.mlgt.Result)
## my.corrected.genotypes <- callGenotypes(my.corrected.mlgt.Result)
## my.genotypes[[thisMarker]]@genotypeTable
## my.corrected.genotypes[[thisMarker]]@genotypeTable
## error correction has little effect on the the sample dataset even with high threshold of 0.05. Most samples with > 100 seqs are called correctly anyway.
errorCorrect.mlgtResult <- function(mlgtResultObject, correctThreshold=0.01) {
markerSampleList <- list()
runSummaryTable <- data.frame()
alleleDb <- list()
varCountTableList <- list()
###ITERATIONS
for(thisMarker in names(mlgtResultObject@markers)) {
cat(paste(thisMarker,"\n"))
#thisMarker <- "DQA1_E2"
## might need to combine all these to return a single item.
summaryList <- list()
summaryTable <- data.frame()
markerSequenceCount <- list("noSeq"=0) # BUG? requires some data otherwise won't sum properly with localSequenceCount.
alleleList <- list()
variantList <- list()
alleleCount <- 1
markerSeq <- unlist(getSequence(mlgtResultObject@markers[[thisMarker]],as.string=T))
varCountTableList[[thisMarker]] <- data.frame()
thisTable <- mlgtResultObject@varCountTables[[thisMarker]]
for(thisSample in mlgtResultObject@samples) {
cat(paste(thisSample ," "))
## need to keep data from mlgtResultObject where no correction is made, but create new data where a correction is made.
#testPairSeqList <- intersect(pairedSampleMap[[thisSample]],union(fMarkerMap[[thisMarker]], rMarkerMap[[thisMarker]]))
seqTable <- data.frame()
localAlleleNames <- c("NA","NA","NA")
localAlleleFreqs <- c(0,0,0)
## go through all seq's mapped to this marker/sample pair.
## extract the corresponding sequence delimited by the top blast hits on the primers. IS THIS THE BEST WAY?
## Simple improvement: minimum blast hit length to primer to keep.
## internal Function
recordNoSeqs <- function(summaryTable) { # to record no seqs before skipping out.
summaryRow <- data.frame(marker=thisMarker, sample=thisSample, numbSeqs=0,numbVars=0,
varName.1="NA", varFreq.1= 0,
varName.2="NA", varFreq.2= 0,
varName.3="NA", varFreq.3= 0)
summaryTable <- rbind(summaryTable, summaryRow)
return(summaryTable)
}
if(is.na(match(thisSample,names(thisTable)))) {
summaryTable <- recordNoSeqs(summaryTable)
next;
}
valueIndex <- !is.na(thisTable[,thisSample])
seqCounts <- thisTable[valueIndex,thisSample]
## important to 'unpack' the alignment so that each sequence occurs the correct number of times.
sampleSeqs <- rep(row.names(thisTable)[valueIndex ], seqCounts)
thisAlign <- as.alignment(sum(seqCounts), sampleSeqs, sampleSeqs)
cat(paste(length(unique(thisAlign$seq)),"/", thisAlign$nb,"unique seqs in original alignment, "))
newAlign <- errorCorrect.alignment(thisAlign, correctThreshold)
cat(paste(length(unique(newAlign$seq)),"/", newAlign$nb,"unique seqs in new alignment, "))
## DONE: repack the corrected alignment re-attribute the allele names. Update the markerSampleTable
varCountTable <- as.data.frame(table(unlist(newAlign$seq)),stringsAsFactors=FALSE)
seqTable <- data.frame(alignedVar=varCountTable$Var1, count=as.numeric(varCountTable$Freq),stringsAsFactors=FALSE)
seqTable$var <- gsub("-","",seqTable$alignedVar)
seqTable <- seqTable[order(seqTable$count,decreasing=T),]
#dim(seqTable)
# if no sequences returned, nothing to process.
if(nrow(seqTable) < 1 ) {
summaryTable <- recordNoSeqs(summaryTable)
cat(" no variants\n")
#summaryList[[thisMarker]][[thisSample]] <- NA
next ; # go to next sample.
}
# store sequence and count of sequence as alignedVar (needed for alignment report)
varCountTableList[[thisMarker]][seqTable$alignedVar,thisSample] <- seqTable$count
## test if variants are novel.
## Give allele names?
## Do with first three for now.
alToRecord <- min(3,nrow(seqTable))
if(alToRecord > 0) {
for (a in 1:alToRecord ) {
if(is.null(variantList[[seqTable$var[a]]])) { # novel
alleleName <- paste(thisMarker, alleleCount,sep=".")
variantList[[seqTable$var[a]]] <- alleleName
localAlleleNames[a] <- alleleName
localAlleleFreqs[a] <- seqTable$count[a]
alleleCount <- alleleCount + 1
} else { # pre-existing alllele
localAlleleNames[a] <- variantList[[seqTable$var[a]]]
localAlleleFreqs[a] <- seqTable$count[a]
}
}
}
# compile stats
if(nrow(seqTable) >0 ) { # cannot allow assignment from empty list as messes up class of list for remaining iterations
summaryList[[thisMarker]] <- list()
summaryList[[thisMarker]][[thisSample]] <- seqTable
}
summaryRow <- data.frame(marker=thisMarker, sample=thisSample, numbSeqs=sum(seqTable$count),numbVars=nrow(seqTable),
varName.1=localAlleleNames[1], varFreq.1= localAlleleFreqs[1],
varName.2=localAlleleNames[2], varFreq.2= localAlleleFreqs[2],
varName.3=localAlleleNames[3], varFreq.3= localAlleleFreqs[3])
summaryTable <- rbind(summaryTable, summaryRow)
#sequence count across samples?
# need to sum from summaryTable or from summaryList.
#markerSequenceCount <-
#as.list(colSums(merge(m, n, all = TRUE), na.rm = TRUE)) # not working
localSequenceCount <- as.list(seqTable$count)
names(localSequenceCount) <- seqTable$var
markerSequenceCount <- as.list(colSums(merge(markerSequenceCount , localSequenceCount, all = TRUE), na.rm = TRUE))
# might need to instantiate the markerSequenceCount if empty.
cat("\n")
} # end of sample loop
markerSampleList[[thisMarker]] <- summaryTable
## DONE: min(nchar(names(variantList))) throws warning when no variants in list. (Inf/-Inf)
minVarLength <- ifelse(length(markerSequenceCount) < 1, NA, min(nchar(names(markerSequenceCount))) )
maxVarLength <- ifelse(length(markerSequenceCount) < 1, NA, max(nchar(names(markerSequenceCount))) )
minAleLength <- ifelse(length(variantList) < 1, NA, min(nchar(names(variantList))) )
maxAleLength <- ifelse(length(variantList) < 1, NA, max(nchar(names(variantList))) )
runSummaryRow <- data.frame(marker=thisMarker, assignedSeqs=sum(summaryTable$numbSeqs), assignedVariants=sum(summaryTable$numbVars),
minVariantLength=minVarLength,
maxVariantLength=maxVarLength,
minAlleleLength=minAleLength, maxAlleleLength=maxAleLength )
runSummaryTable <- rbind(runSummaryTable, runSummaryRow)
if(length(variantList) > 0) {
# This line replaced. Not entirely tested the repurcussions. e.g. makeVarAlleleMap()?
#alleleDb[[thisMarker]] <- variantList # LATER: separate lists for alleles and variants?
#alleleDb[[thisMarker]] <- list(reference=as.SeqFastadna(markerSeq, thisMarker), alleleMap=variantList, inputAlleleCount = length(unlist(variantList)), uniqueSubAlleleCount=length(variantList))
alleleDb[[thisMarker]] <- new("variantMap", reference=as.SeqFastadna(markerSeq, thisMarker),
variantSource=paste(mlgtResultObject@projectName, mlgtResultObject@runName,sep="."),
variantMap=variantList, inputVariantCount = length(unlist(variantList)), uniqueSubVariantCount=length(variantList))
}
} # end of marker loop
localMlgtResult <- new("mlgtResult", mlgtResultObject, runSummaryTable=runSummaryTable , alleleDb=alleleDb, markerSampleList=markerSampleList,
varCountTables=varCountTableList)
return(localMlgtResult)
}
#' Alignment error correction
#'
#' Correct very low frequency site variants.
#'
#' You may want to alter some of the sequences if you believe that sequences at very low frequency
#' (within the set of sequences from a marker/sample pair) represent sequencing errors.
#' \code{errorCorrect()} is implemented as an additional step after running \code{\link{mlgt}}, however, it is recommended to include error correction within \code{\link{mlgt}} using the errorCorrect=TRUE option.
#' Using \code{\link{alignReport}} beforehand may help you decide whether to do this.
#'
#' @param mlgtResultObject An object of class \code{\link{mlgtResult}}
#' @param correctThreshold The maximimum Minor Allele Frequency (MAF) at which variants will be corrected.
#'
#' @return A new \code{\link{mlgtResult}} object with errors 'corrected'
#' @rdname errorCorrect-methods
#' @export
#' @seealso \code{\link{alignReport}}
#'
setGeneric("errorCorrect", function(mlgtResultObject, alignment, correctThreshold=0.01) standardGeneric("errorCorrect"))
#' @rdname errorCorrect-methods
#' @aliases errorCorrect,missing,list-method
setMethod("errorCorrect", signature(mlgtResultObject="missing",alignment="list", correctThreshold="ANY"),
definition=errorCorrect.alignment)
#' @rdname errorCorrect-methods
#' @aliases errorCorrect,mlgtResult,missing-method
setMethod("errorCorrect", signature(mlgtResultObject="mlgtResult", alignment="missing", correctThreshold="ANY"),
definition=errorCorrect.mlgtResult)
# TODO: rewrite alignReport() so that it does not rely upon varCountTables.
# Use re-alignment through muscle. Seems very slow.
# ALT: store alignments within mlgtResult - gonna be huge, for limited return.
# ALT.2: store a varCountTable and an AlignedVarTable (the second would be larger but could be used to reconstruct any alignment for any sample/marker.
## Generate stats per site along the alignments. WITHIN a marker/sample pair.
## DONE: Docs needed, add e.g. to README
## This function is a bit weird in that it collects a table of info and, optionally, generates some graphs.
## What if people want to export the tables of results to file AND the images?
## EXAMPLES:-
## alignReport(my.mlgt.Result,markers=thisMarker, samples=thisSample, method="profile")
## alignReport(my.mlgt.Result,markers=thisMarker, samples=thisSample, method="hist", fileName="testOutHist")
## alignReport(my.mlgt.Result, method="profile", fileName="testOutMultiProfile")
## alignReport(my.mlgt.Result,markers="DPA1_E2", samples="MID-17", method="profile")
## alignReport(my.mlgt.Result,markers="DPA1_E2", samples="MID-1", method="hist")
## alignReport(my.mlgt.Result,markers="DPA1_E2", samples="MID-22", method="hist") # good example where change would be useful
## alignReport(my.mlgt.Result,markers="DPA1_E2", samples="MID-1", method="profile", correctThreshold=0.02)
## my.alignReport <- alignReport(my.mlgt.Result)
#' Report on alignment
#'
#' Inspect site frequency spectra for alignments.
#'
#' Produce different kinds of reports to assess quality of data for each marker/sample pair.
#' Can be a good way to assess whether \code{\link{errorCorrect}} should be applied.
#'
#'
#' @param mlgtResultObject an object of class \code{\link{mlgtResult}}
#' @param markers Which markers to output
#' @param samples Which samples to output
#' @param correctThreshold A hypothetical level at which you migth correct low frequence variants. Default = 0.01.
#' @param consThreshold (1- correctThreshold)
#' @param profPlotWidth How many residues to plot in \code{profile} mode. Default=60.
#' @param fileName Give a filename to export result to (pdf).
#' @param method One of c("table", "profile", "hist"). "hist" plot a histogram of MAF frequencies. "profile" plots a coloured barplot represnting the allele frequencies at each site.
#' @param warn Issue warnings (default = TRUE)
#'
#' @return A data frame for each marker listing site statistics.
#' @seealso \code{\link{errorCorrect}}
#' @export
#' @examples \dontrun{
#' data("mlgtResult", package="mlgt")
#' alignReport(my.mlgt.Result,markers="DPA1_E2", samples="MID-22", method="profile")
#' alignReport(my.mlgt.Result,markers="DPA1_E2", samples="MID-22", method="hist")
#' }
alignReport <- function(mlgtResultObject, markers=names(mlgtResultObject@markers), samples=mlgtResultObject@samples,
correctThreshold = 0.01, consThreshold = (1 - correctThreshold), profPlotWidth = 60, fileName=NULL, method="table", warn=TRUE) {
# need method for both plots (save processing time) but how to do without generating profiles twice.
# need to tidy and label profile plots.
reportList <- list()
if(!is.null(fileName)) {
if(length(grep(".pdf$", fileName)) < 1 & !is.null(fileName)) {
fileName <- paste(fileName,"pdf", sep=".")
}
pdf(fileName)
}
colTable <- data.frame(profChar = c("-","a","c","g","t"),
profCol = c("grey","green", "blue", "yellow", "red"))
for(thisMarker in markers) {
thisTable <- mlgtResultObject@varCountTables[[thisMarker]]
cat(paste(thisMarker,"\n"))
if(nrow(thisTable) < 1) { # drops this marker if no data. Might be better to return and empty table?
if(warn) {
warning(paste("No data for", thisMarker))
}
#reportTable[thisSample,c("numbSeqs","numbVars")] <- 0
#reportTable[thisSample,c("alignLength","invar.sites","mafBelowThreshold","mafAboveThreshold")] <- NA
next;
}
reportTable <- data.frame()
for(thisSample in samples) {
if(is.na(match(thisSample,names(thisTable)))) {
if(warn) {
warning(paste("No variants for", thisSample, "and", thisMarker))
}
#reportTable[thisSample,c("invar.sites","mafBelowThreshold","mafAboveThreshold")] <- NA
reportTable[thisSample,"numbSeqs"] <- 0
reportTable[thisSample,"numbVars"] <- 0
reportTable[thisSample,"alignLength"] <- NA
reportTable[thisSample,"invar.sites"] <- NA
reportTable[thisSample,"mafAboveThreshold"] <- NA
reportTable[thisSample,"mafBelowThreshold"] <- NA
next;
}
#cat(paste(thisSample ," "))
valueIndex <- !is.na(thisTable[,thisSample])
seqCounts <- thisTable[valueIndex,thisSample]
sampleSeqs <- rep(row.names(thisTable)[valueIndex ], seqCounts)
thisAlign <- as.alignment(sum(seqCounts), sampleSeqs, sampleSeqs)
if(thisAlign$nb < 2) { # too few sequences to plot.
#reportTable[thisSample,c("invar.sites","mafBelowThreshold","mafAboveThreshold")] <- NA
reportTable[thisSample,"numbSeqs"] <- 1
reportTable[thisSample,"numbVars"] <- 1
reportTable[thisSample,"alignLength"] <- nchar(thisAlign$seq[1])
reportTable[thisSample,"invar.sites"] <- NA
reportTable[thisSample,"mafAboveThreshold"] <- NA
reportTable[thisSample,"mafBelowThreshold"] <- NA
next;
}
thisProfile <- consensus(thisAlign , method="profile")
thisConsensus <- con(thisAlign, method="threshold", threshold=consThreshold)
totalSeqs <- sum(seqCounts)
totalLetters <- nrow(thisProfile)
mafList <- apply(thisProfile, 2, FUN=function(x) (sort(x)[totalLetters-1] / totalSeqs))
reportTable[thisSample, "numbSeqs"] <- totalSeqs
reportTable[thisSample, "numbVars"] <- length(seqCounts)
reportTable[thisSample, "alignLength"] <- ncol(thisProfile)
reportTable[thisSample, "invar.sites"] <- sum(mafList == 0)
## variable sites with minor allele > correction threshold.
reportTable[thisSample, "mafAboveThreshold"] <- sum(mafList >= correctThreshold )
## varaible sites with minor alleles < correction threshold.
reportTable[thisSample, "mafBelowThreshold"] <- reportTable[thisSample, "alignLength"] - (reportTable[thisSample, "invar.sites"] + reportTable[thisSample, "mafAboveThreshold"])
if(method=="profile") {
profColours <- as.character(colTable$profCol[match(row.names(thisProfile),colTable$profChar)])
## splits the plotting across so many lines. Buffers final plot to constant length.
profLen <- ncol(thisProfile)
n_plot <- ceiling(profLen / profPlotWidth )
plotProfile <- thisProfile
plotConsensus <- toupper(thisConsensus)
remainder <- profLen %% profPlotWidth
if(remainder > 0) {
extLen <- profLen + (profPlotWidth - remainder)
profExtension <- matrix(0,nrow=nrow(thisProfile), ncol=(profPlotWidth - remainder),
dimnames=list(row.names(thisProfile),c((profLen+1): extLen)))
plotProfile <- cbind(thisProfile,profExtension)
plotConsensus <- c(toupper(thisConsensus), rep("",remainder))
}
old.o <- par(mfrow=c((n_plot+1),1), mar=c(2,4,2,2))
plot.new()
title(paste(thisMarker, thisSample, sep=" : "), line=0)
title("", line=0,adj=0, sub=paste(c("Total sites","Invariant sites","MAF above threshold","MAF below threshold"),reportTable[thisSample,3:6],sep=": ",collapse="\n") )
legend("right", legend=toupper(colTable$profChar),fill=as.character(colTable$profCol), horiz=T)
for(i in 1:n_plot) {
start <- ((i-1)*profPlotWidth) + 1
#index <- start:(min(start+profPlotWidth, profLen))
index <- start:((start+profPlotWidth)-1)
barplot(plotProfile[,index ], col=profColours , names.arg=toupper(plotConsensus[index]) )
}
par(old.o)
}
if(method=="hist") {
#if(!is.null(fileName)) pdf(fileName)
if(sum(mafList > 0) > 0) {
hist(mafList[mafList > 0], breaks=200, xlim=c(0,0.5), xlab="Site-specific minor allele frequency", sub="non-zero values only",main=paste(thisMarker, thisSample, sep=":"))
abline(v=correctThreshold, lty=2)
}
}
}
reportList[[thisMarker]] <- reportTable
}
if(!is.null(fileName)) {
dev.off()
cat(paste("Alignment figures(s) plotted to", fileName,"\n"))
}
#print(reportList)
return(reportList)
}
## TODO: as per alleleReport() above, need to use proper varCountTable with ungapped sequences.
## DONE docs, README entry
## Examples
## dumpVariants(my.mlgt.Result,fileSuffix="variantDump.fasta")
## dumpVariants(my.corrected.mlgt.Result, markers="FLA_DRB", samples="cat348" )
## dumpVariants(my.corrected.mlgt.Result,fileSuffix="corrected.0.05.variantDump.fasta")
## dumpVariants(my.corrected.mlgt.Result,fileSuffix="corrected.0.05.variantDump.unique.fasta", uniqueOnly=T)
#' Print sequence to file
#'
#' A function to output all sequences or just unique sequences to a fasta file
#'
#' The sequence variants stored within an object of class \code{\link{mlgtResult}}
#' are not very easy to extract. This function will output all variants or all
#' variant for specific markers and samples into fasta files. Users can select to only
#' output unique sequences or the full alignment including duplicated sequences.
#' One file will be created for each marker/sample pair.
#'
#' @param mlgtResultObject an object of class \code{\link{mlgtResult}}
#' @param markers Which markers to output
#' @param samples Which samples to output
#' @param fileSuffix Add a common suffix to the file names. Usefull for keeping track of different sets of sequences.
#' @param uniqueOnly Only output single copy of each sequence. A count for each sequence are appended to the names.
#'
#' @export
#'
dumpVariants <- function(mlgtResultObject, markers=names(mlgtResultObject@markers),
samples=mlgtResultObject@samples, fileSuffix="variantDump.fasta", uniqueOnly=FALSE) {
for(thisMarker in markers) {
thisTable <- mlgtResultObject@varCountTables[[thisMarker]]
for(thisSample in samples) {
if(is.na(match(thisSample,names(thisTable)))) {
warning(paste("Nothing to output for", thisMarker, thisSample))
next;
}
fileName <- paste(thisMarker,thisSample,fileSuffix, sep=".")
valueIndex <- !is.na(thisTable[,thisSample])
seqCounts <- thisTable[valueIndex,thisSample]
if(uniqueOnly) { # export one copy of each sequence, append count to name line
sampleSeqs <- row.names(thisTable)[valueIndex]
seqNames <- paste(sampleSeqs,seqCounts)
thisAlign <- as.alignment(length(seqCounts), seqNames, sampleSeqs)
} else { # export copies of seqs as per counts.
## important to 'unpack' the alignment so that each sequence occurs the correct number of times.
sampleSeqs <- rep(row.names(thisTable)[valueIndex ], seqCounts)
thisAlign <- as.alignment(sum(seqCounts), sampleSeqs, sampleSeqs)
}
write.fasta(sequences=lapply(thisAlign$seq,s2c), names=thisAlign$nam, file.out=fileName)
cat(paste("Variants written to", fileName,"\n"))
}
}
}
# TODO: as alignReport() above, use true ungapped varCountTable
## used by combineMlgtResults()
mergeMlgtResults.complex <- function(result1, result2) {
master <- result1
# need to check if samples shared between results.
# If not, then perform complex join. Combining results where approriate.
# If they are, then test if marker/sample pairs shared. If yes, then stop(), otherwise perform complex join.
master@markers <- c(master@markers,result2@markers)
master@markers <- master@markers[!duplicated(master@markers)]
newRunSummaryTable <- data.frame()
for(thisMarker in names(master@markers)) {
markerSampleOverlap <- intersect(master@markerSampleList[[thisMarker]]$sample,result2@markerSampleList[[thisMarker]]$sample)
if(length(markerSampleOverlap) > 0) {
# STOP!
stop(paste("Cannot join results sharing marker results for same samples\n",thisMarker,markerSampleOverlap,"\n"))
}
# need to combine alleleDBs and variantMaps first so that new consistent allele names can propagate to the markerSampleList
#master@alleleDb <- as.list(merge(master@alleleDb, result2@alleleDb))
#master@alleleDb <- mergeAlleleDbs(master@alleleDb)
masterAlleleTable <- data.frame(seq=names(unlist(master@alleleDb[[thisMarker]]@variantMap)),
masterName=as.character(unlist(master@alleleDb[[thisMarker]]@variantMap)), stringsAsFactors=F )
alleleTable2 <- data.frame(seq=names(unlist(result2@alleleDb[[thisMarker]]@variantMap)),
alleleName=as.character(unlist(result2@alleleDb[[thisMarker]]@variantMap)), stringsAsFactors=F )
masterMatchTable <- merge(masterAlleleTable, alleleTable2, by="seq", all=T)
# some alleles will be new and these need to be added to master table and given new allele names
maxAllele <- max(na.omit(as.numeric(sub(paste(thisMarker,".",sep=""),"",masterMatchTable$masterName))))
newAlleleCount <-sum(is.na(masterMatchTable$masterName))
masterMatchTable$masterName[is.na(masterMatchTable$masterName)] <- paste(thisMarker, (1:newAlleleCount + maxAllele), sep=".")
#create new variantMap from masterMatchTable
newVarMap <- as.list(masterMatchTable$masterName)
names(newVarMap) <- masterMatchTable$seq
master@alleleDb[[thisMarker]]@variantMap <- newVarMap
# update allele Names in result2 table
nameCols <- grep("varName", names(result2@markerSampleList[[thisMarker]]))
for(n in nameCols) {
result2@markerSampleList[[thisMarker]][,n] <- masterMatchTable$masterName[match(result2@markerSampleList[[thisMarker]][,n] , masterMatchTable$alleleName)]
}
master@markerSampleList[[thisMarker]] <- rbind(master@markerSampleList[[thisMarker]],result2@markerSampleList[[thisMarker]])
# Combine result across varCountTables.
#master@varCountTables <- as.list(merge(master@varCountTables, result2@varCountTables))
# varCountTables[[thisMarker]][seqTable$alignedVar,thisSample] <- seqTable$count
frame2 <- result2@varCountTables[[thisMarker]]
for(thisCol in names(frame2)) {
index <- which(!is.na(frame2[,thisCol] ))
counts <- frame2[index,thisCol]
names <- row.names(frame2)[index]
master@varCountTables[[thisMarker]][names,thisCol] <- counts
}
index1 <- match(thisMarker, master@runSummaryTable$marker)
index2 <- match(thisMarker, result2@runSummaryTable$marker)
runSummaryRow <- data.frame(marker=thisMarker, assignedSeqs=sum(master@markerSampleList[[thisMarker]]$numbSeqs), assignedVariants=sum(master@markerSampleList[[thisMarker]]$numbVars),
minVariantLength=min(master@runSummaryTable$minVariantLength[index1], result2@runSummaryTable$minVariantLength[index2] ),
maxVariantLength=max(master@runSummaryTable$maxVariantLength[index1], result2@runSummaryTable$maxVariantLength[index2] ),
minAlleleLength=min(master@runSummaryTable$minAlleleLength[index1], result2@runSummaryTable$minAlleleLength[index2] ),
maxAlleleLength=max(master@runSummaryTable$maxAlleleLength[index1], result2@runSummaryTable$maxAlleleLength[index2] ) )
newRunSummaryTable <- rbind(newRunSummaryTable,runSummaryRow )
}
master@samples <- union(master@samples,result2@samples)
master@runSummaryTable <- newRunSummaryTable
# keep the following unless different between results.
if(!identical(master@fTags,result2@fTags)) { master@fTags <- list() } # @fTags. List of class SeqFastadna
if(!identical(master@rTags,result2@rTags)) { master@rTags<- list() } # @rTags. List of class SeqFastadna
if(!identical(master@inputFastaFile,result2@inputFastaFile)) { master@inputFastaFile <- '' } # @inputFastaFile
if(!identical(master@markerBlastResults,result2@markerBlastResults)) { master@markerBlastResults <- '' } # @markerBlastResults
if(!identical(master@fTagBlastResults,result2@fTagBlastResults)) { master@fTagBlastResults <- '' } # @fTagBlastResults
if(!identical(master@rTagBlastResults,result2@rTagBlastResults)) { master@rTagBlastResults <- '' } # @rTagBlastResults
if(!identical(master@runName,result2@runName)) { master@runName<- 'CombinedResults' } # @runName
# @projectName is taken as the first result. May need to change this.
return(master)
}
## used by combineMlgtResults()
mergeMlgtResults.simple <- function(result1, result2) {
master <- result1
master@markers <- c(master@markers,result2@markers)
master@markers <- master@markers[!duplicated(master@markers)]
master@markerSampleList <- c(master@markerSampleList, result2@markerSampleList)
master@markerSampleList <- master@markerSampleList[!duplicated(master@markerSampleList)]
master@alleleDb <- c(master@alleleDb, result2@alleleDb)
master@alleleDb <- master@alleleDb[!duplicated(master@alleleDb)]
master@varCountTables <- c(master@varCountTables, result2@varCountTables)
master@varCountTables <- master@varCountTables[!duplicated(master@varCountTables)]
master@samples <- union(master@samples,result2@samples)
master@runSummaryTable <- rbind(master@runSummaryTable, result2@runSummaryTable)
# keep the following unless different between results.
if(!identical(master@fTags,result2@fTags)) { master@fTags <- list() } # @fTags. List of class SeqFastadna
if(!identical(master@rTags,result2@rTags)) { master@rTags<- list() } # @rTags. List of class SeqFastadna
if(!identical(master@inputFastaFile,result2@inputFastaFile)) { master@inputFastaFile <- '' } # @inputFastaFile
if(!identical(master@markerBlastResults,result2@markerBlastResults)) { master@markerBlastResults <- '' } # @markerBlastResults
if(!identical(master@fTagBlastResults,result2@fTagBlastResults)) { master@fTagBlastResults <- '' } # @fTagBlastResults
if(!identical(master@rTagBlastResults,result2@rTagBlastResults)) { master@rTagBlastResults <- '' } # @rTagBlastResults
if(!identical(master@runName,result2@runName)) { master@runName<- 'CombinedResults' } # @runName
# @projectName is taken as the first result. May need to change this.
return(master)
}
## I imagine most of the time, combining results can be done after mlgt is run by simple concatenation of genotype tables.
## This might be the case if certain markers are rerun.
## However, there are instances where combination within mlgt is desirable. e.g. after a parallel run.
## Re-runs of certain marker samples could also be accomodated, but care would be have to be taken to update the correct results.
## 1. to combine and summarise results across runs.
## 2. to re-combine results after running parallel processing.
## Lots of the merging should be in common.
## Need checks that samples/markers are not duplicated (option to rename?)
## Needs to be fast enough for point 2 above to be worthwhile.
## Even if markers don't overlap, need to check that samples and mids are the same or different.
## Or do I? MIDs should be allowed to differ between runs.
#' Combine two or more mlgtResult objects
#'
#' Combine results from one or more runs, or combine partial results after a parallel job.
#'
#' In some cases, you may want to combine multiple \code{\link{mlgtResult}} objects
#' into a single object.
#' Can combine results using the same markers as long as the samples used have different names between results.
#' Can combine results using different sets (subsets) of markers.
#' Will fail if the same marker/sample combination appears in more than one \code{\link{mlgtResult}}.
#' Can be used to recombine the list of result obtained by running \code{\link{mlgt}} in parallel
#' on subsets of the full marker list.
#'
#'
#' @param resultList A list of objects of class \code{\link{mlgtResult}}
#' @param projectName Do you want to provide your own projectName
#' @param runName Do you want to provide your own runName
#'
#' @return An object of class \code{\link{mlgtResult}}
#' @export
#'
combineMlgtResults <- function(resultList,projectName=resultList[[1]]@projectName, runName="combinedMlgtResults") {
# set first result as master
master <- resultList[[1]]
for(i in 2:length(resultList)) {
# cycle through remaining results adding each to master
# check that sample/marker combinations do not overlap
#Any overlap in markers?
markerOverlap <- intersect(names(master@markers),names(resultList[[i]]@markers))
if(length(markerOverlap) > 0) { # overlapping markers, test for sample/marker overlap and maybe complex join.
# need to check if overlapping marker sequences are identical
cat("Complex join\n")
if(!identical(master@markers[markerOverlap],resultList[[i]]@markers[markerOverlap])) {
#STOP
stop("Cannot combine: markers with same name have different sequences.\n")
}
master <- mergeMlgtResults.complex(master, resultList[[i]])
} else { # no overlap in markers, 'simple' join
cat("Simple join\n")
master <- mergeMlgtResults.simple(master, resultList[[i]])
}
}
return(master)
}
#' @name my.mlgt.Result
#' @title An example \code{\link{mlgtResult}} object.
#' @description This is the result of running \code{\link{mlgt}} on the sample data given in the README.
#' @docType data
#' @usage my.mlgt.Result
#' @format a \code{\link{mlgtResult}} object.
#' @source Package mlgt
#' @author Dave T. Gerrard, 2012-04-01
NULL
| /mlgt.R | no_license | davetgerrard/mlgt | R | false | false | 116,473 | r | #' mlgt: Multi-locus geno-typing
#'
#' \tabular{ll}{
#' Package: \tab mlgt\cr
#' Type: \tab Package\cr
#' Version: \tab 0.18\cr
#' Date: \tab 2012-10-02\cr
#' Author: \tab Dave T. Gerrard <david.gerrard@@manchester.ac.uk>\cr
#' License: \tab GPL (>= 2)\cr
#' LazyLoad: \tab yes\cr
#' }
#'
#' mlgt sorts a batch of sequence by barcode and identity to
#' templates. It makes use of external applications BLAST and
#' MUSCLE. Genotypes are called and alleles can be compared
#' to a reference list of sequences.
#' More information about each function can be found in
#' its help documentation.
#'
#' Some text
#'
#' The main functions are:
#' \code{\link{prepareMlgtRun}}, \code{\link{mlgt}},
#' \code{\link{callGenotypes}}, \code{\link{createKnownAlleleList}},
#'
#' ...
#'
#' @references BLAST - Altschul, S. F., W. Gish, W. Miller, E. W. Myers, and D. J. Lipman (1990). Basic local alignment search tool. Journal of molecular biology 215 (3), 403-410.
#' @references MUSCLE - Robert C. Edgar (2004) MUSCLE: multiple sequence alignment with high accuracy and high throughput. Nucleic Acids Research 32(5), 1792-97.
#' @references IMGT/HLA database - Robinson J, Mistry K, McWilliam H, Lopez R, Parham P, Marsh SGE (2011) The IMGT/HLA Database. Nucleic Acids Research 39 Suppl 1:D1171-6
#' @import seqinr
#' @docType package
#' @name mlgt-package
NULL
# require(seqinr)
# n/b @ slot not currently recognised by roxygen.
# wanted reference to be of SeqFastadna, but unrecognised even with seqinr loaded.
#' An S4 class to hold all unique variants found/known for a marker.
#'
#' @slot reference
#' @slot variantSource
#' @slot variantMap
#' @slot inputVariantCount
#' @slot uniqueSubVariantCount
setClass("variantMap", representation(reference='ANY', variantSource='character',variantMap='list',
inputVariantCount='integer', uniqueSubVariantCount='integer'))
setClass("varCount",
representation(
rawTotal="numeric",
rawUniqueCount ="numeric",
usedRawTotal="numeric",
usedRawUniqueCount="numeric",
subAlignTotal="numeric",
subAlignUniqueCount="numeric",
varCountTable="data.frame"
)
)
#' Create \code{\link{variantMap}} object from allele alignment
#'
#' Create a \code{\link{variantMap}} object to store known alleles for a marker
#'
#' To compare variants produced using \code{\link{mlgt}} the sequences of the known
#' alleles must be aligned to the same marker used to find the variants.
#' The resulting sub-sequence alignment may have identical sequences for different
#' alleles. If that happens, those alleles are condensed into one and their names
#' concatenated.
#' User can supply files with marker sequences pre-aligned to the reference alleles.
#'
#' @param markerName A specific marker name
#' @param markerSeq something
#' @param alignedAlleleFile a sequence alignment
#' @param alignFormat the format of alignedAlleleFile. "msf" (the default) or "fasta"
#' @param sourceName A character string to record the source of the alignment. Defaults to
#' the value of alignedAlleleFile
#' @param userAlignment The specified 'alignedAlleleFile' already includes the marker sequence. Default = FALSE.
#'
#' @return a \code{\link{variantMap}} object named by markerName
#'
#' @export
#' @docType methods
createKnownAlleleList <- function(markerName, markerSeq, alignedAlleleFile, alignFormat="msf", sourceName=alignedAlleleFile, userAlignment=FALSE) {
## The aligned alleles must have unique names and the markerName must be different too. TODO: test for this.
## DONE put default input file format (MSF). Make check for fasta format (can skip first part if already fasta).
## clean up (remove) files. This function probably doesn't need to keep any files
## Use defined class for return object giving marker sequence used as reference.
#alignedAlleles <- read.msf(alignedAlleleFile)
musclePath <- Sys.getenv("MUSCLE_PATH")
if(nchar(musclePath) < 1) {
stop(paste("MUSCLE_PATH","has not been set!"))
}
switch(alignFormat,
"msf" = {
alignedAlleles <- read.alignment(alignedAlleleFile, format="msf")
alignedAlleleFastaFile <- paste(markerName, "alignedAlleles.fasta", sep=".")
write.fasta(alignedAlleles[[3]], alignedAlleles[[2]], file.out=alignedAlleleFastaFile)
},
"fasta" = {
alignedAlleleFastaFile = alignedAlleleFile
},
stop("Unrecognised alignment file format\n")
)
if(userAlignment) { # user supplied alignment
markerToAlleleDbAlign <- alignedAlleleFastaFile
} else { # align the marker to the aligned alleles.
markerSeqFile <- paste(markerName, "markerSeq.fasta", sep=".")
write.fasta(markerSeq, markerName, file.out=markerSeqFile )
#muscle -profile -in1 existing_aln.afa -in2 new_seq.fa -out combined.afa
markerToAlleleDbAlign <- paste(markerName, "allignedToAlleles.fasta", sep=".")
# profile alignment of marker to existing allele alignment
muscleCommand <- paste(musclePath, "-quiet -profile -in1", alignedAlleleFastaFile, "-in2", markerSeqFile, "-out" ,markerToAlleleDbAlign )
system(muscleCommand)
}
### this section copied from getSubSeqsTable() Could be recoded as function?
# Extract portion corresponding to reference.
rawAlignment <- read.fasta(markerToAlleleDbAlign , as.string=T) # do not use read.alignment() - broken
alignedMarkerSeq <- s2c(rawAlignment[[markerName]])
#alignedMarkerSeq <- s2c(rawAlignment[[thisMarker]]) # was this a bug?
subStart <- min(grep("-",alignedMarkerSeq ,invert=T))
subEnd <- max(grep("-",alignedMarkerSeq ,invert=T))
alignedSubSeqs <- lapply(rawAlignment, FUN=function(x) substr(x[1], subStart, subEnd))
alignedSubTable <- data.frame(name=names(alignedSubSeqs ) , subSeq.aligned= as.character(unlist(alignedSubSeqs )))
alignedSubTable$subSeq.stripped <- gsub("-", "",alignedSubTable$subSeq.aligned )
# remove marker sequence from allele subalignment list.
alignedSubTable <- subset(alignedSubTable, name != markerName)
# TODO: 2 issues here. 1. concatentated allele name lists get truncated at 500 chars (probably by newline insertion).
# 2. blast is not returning the full name.
# HLA_A2 central region has 213 alleles all identical. The concatentated sequence IDs are 2030 chars long.
# Could try using an '_' as this might prevent word boundary splitting in one or both cases.
# Solves the first problem but still cannot blast with this. Need to also adjust blast usage.
alleleMap <- split(as.character(alignedSubTable$name), alignedSubTable$subSeq.stripped) # group allele nams sharing a common sequence.
##alleleMap <- paste(unlist(split(as.character(alignedSubTable$name), alignedSubTable$subSeq.stripped)),collapse="|")
# TODO: THis next line is what I want to do but it makes BLASTALL crash. Something to do with long sequence IDs in fasta files?
alleleMap <- lapply(alleleMap, FUN=function(x) paste(x,collapse="_")) # do not use '|' or '*' or ':'
#if(remTempFiles) {
# file.remove(markerSeqFile)
#}
#return(list(reference=as.SeqFastadna(markerSeq, markerName), alleleMap=alleleMap, inputAlleleCount = length(unlist(alleleMap)), uniqueSubAlleleCount=length(alleleMap)))
return(new("variantMap", reference=as.SeqFastadna(markerSeq, markerName), variantSource=sourceName, variantMap=alleleMap, inputVariantCount = length(unlist(alleleMap)), uniqueSubVariantCount=length(alleleMap)))
}
#' An S4 class that holds information about an mlgt analysis.
#'
#' Returned by \code{\link{prepareMlgtRun}}. Used as sole input for \code{\link{mlgt}}
#'
#' \describe{
#' \item{projectName}{In which project does this run belong}
#' \item{runName}{Which run was this. An identifier for the sequnece run}
#' \item{markers}{A \emph{list} of named sequences.}
#' \item{samples}{A vector of sample names}
#' \item{fTags}{A vector of named sequence of MIDs used to barcode samples at the 5' end.}
#' \item{rTags}{A vector of named sequence of MIDs used to barcode samples at the 3' end.}
#' \item{inputFastaFile}{The name of the file containing sequences. Currently only fasta format is supported. It is up to you to pre-filter the sequences.}
#' }
#'
#' @slot projectName In which project does this run belong
#' @slot runName Which run was this. An identifier for the sequnece run
#' @slot markers A \emph{list} of named sequences.
#' @slot samples A vector of sample names
#' @slot fTags A vector of named sequence of MIDs used to barcode samples at the 5' end.
#' @slot rTags A vector of named sequence of MIDs used to barcode samples at the 3' end.
#' @slot inputFastaFile The name of the file containing sequences. Currently only fasta format is supported. It is up to you to pre-filter the sequences.
#' @seealso \code{\link{prepareMlgtRun}}, \code{\link{mlgt}}
setClass("mlgtDesign",
representation(
projectName="character",
runName="character",
markers="list",
samples="character",
fTags="list",
rTags="list",
inputFastaFile="character",
markerBlastResults="character",
fTagBlastResults="character",
rTagBlastResults="character"
)
)
setMethod("show", "mlgtDesign", definition= function(object="mlgtDesign"){
cat("Design for mlgt run:\n")
cat(paste("Project:",object@projectName,"\n"))
cat(paste("Run:",object@runName,"\n"))
cat(paste("Samples:",length(object@samples),"\n"))
cat(paste("fTags:",length(object@fTags),"\n"))
cat(paste("rTags:",length(object@rTags),"\n"))
cat(paste("Markers:",length(object@markers),"\n"))
}
)
#' An S4 class to hold results from \code{\link{mlgt}}
#'
#' Extends \code{\link{mlgtDesign}}
#'
#' \describe{
#' \item{projectName}{In which project does this run belong}
#' \item{runName}{Which run was this. An identifier for the sequnece run}
#' \item{markers}{A \emph{list} of named sequences.}
#' \item{samples}{A vector of sample names}
#' \item{fTags}{A vector of named sequence of MIDs used to barcode samples at the 5' end.}
#' \item{rTags}{A vector of named sequence of MIDs used to barcode samples at the 3' end. May be same as \code{fTags}}
#' \item{inputFastaFile}{The name of the file containing sequences. Currently only fasta format is supported. It is up to you to pre-filter the sequences.}
#' \item{runSummaryTable}{A summary table with one row per marker}
#' \item{alleleDb}{A list of objects of class \code{\link{variantMap}}. Contains all variants returned by \code{\link{mlgt}}}
#' \item{markerSampleList}{A list of tables, one table per marker giving results for each sample/MID}
#' }
#'
#' @seealso \code{\link{mlgtDesign}}, \code{\link{prepareMlgtRun}}, \code{\link{mlgt}}
#'
setClass("mlgtResult",
representation(
runSummaryTable="data.frame",
alleleDb="list" ,
markerSampleList="list",
varCountTables="list"
),
contains="mlgtDesign"
)
setMethod("show", "mlgtResult", definition= function(object="mlgtResult"){
cat("Results for mlgt run:\n")
cat(paste("Project:",object@projectName,"\n"))
cat(paste("Run:",object@runName,"\n"))
cat(paste("Samples:",length(object@samples),"\n"))
cat(paste("fTags:",length(object@fTags),"\n"))
cat(paste("rTags:",length(object@rTags),"\n"))
cat(paste("Markers:",length(object@markers),"\n"))
print(object@runSummaryTable)
}
)
#' Return top blast hits
#'
#' Auxillary function
#'
#' @param blastTableFile The name of a file of tabulated blast results.
#' @return A reduced blast table with one hit per query
#' @export
getTopBlastHits <- function(blastTableFile) { # returns the first hit for each query in the table. May now be partially redundant if selecting for number of blast hits returned..
blastResults <- read.delim(blastTableFile, header=F)
## Fields:
# Query id,Subject id,% identity,alignment length,mismatches,gap openings,q. start,q. end,s. start,s. end,e-value,bit score
names(blastResults) <- c("query", "subject", "percent.id", "ali.length", "mismatches", "gap.openings", "q.start","q.end", "s.start","s.end", "e.value", "bit.score")
topHits <- blastResults[match(unique(blastResults$query), blastResults$query),]
}
#INTERNAL. Need to document?
#' Align and trim sequences for marker/sample pair
#'
#' A list of sequences mapped to both \option{thisMarker} and \option{thisSample} is created and these sequences are aligned to \option{markerSeq}.
#'
#' This internal function is called by \code{\link{mlgt}}
#'
#' @param thisMarker A specific marker name
#' @param thisSample A specific sample name
#' @param sampleMap A list of sequence IDs assigned to each marker. Each element named by marker name.
#' @param fMarkerMap A list of sequence IDs assigned to each sample using BLAST hits in forward orientation. Each element named by sample name.
#' @param rMarkerMap A list of sequence IDs assigned to each sample using BLAST hits in reverse orientation. Each element named by sample name.
#' @param markerSeq The sequence of \option{thisMarker}
#' @param maxVarsToAlign If total assigned sequences exceeds 'minTotalCount', then only the 'maxVarsToAlign' most abundant variants are used.
#' @param minTotalCount How many assigned sequences to allow before limiting the number of raw variants to allign.
#' @param errorCorrect Use error correection on alignment of raw variants
#' @param correctThreshold Maximum proportion of raw reads at which (minor allele) bases and gaps are corrected.
#' @param minLength Reads below this length are excluded (they are very likely to be primer-dimers).
#'
#' @return A table of unique variants and their counts. The sequences have been trimmed to the portion aligned with \option{markerSeq}
#'
getSubSeqsTable <- function(thisMarker, thisSample, sampleMap, fMarkerMap,rMarkerMap, markerSeq, maxVarsToAlign=30, minTotalCount=500, errorCorrect=FALSE, correctThreshold=0.01, minLength=70) {
if(exists("verbose")) cat("getSubSeqsTable",thisSample, thisMarker,"\n")
# check paths to auxillary programs
pathNames <- c("FASTACMD_PATH","MUSCLE_PATH")
for(thisPath in pathNames) {
if(nchar(Sys.getenv(thisPath)) < 1) {
stop(paste(thisPath,"has not been set!"))
}
}
musclePath <- Sys.getenv("MUSCLE_PATH")
fastacmdPath <- Sys.getenv("FASTACMD_PATH")
if(length(grep(" ",musclePath, fixed=T)) > 0 ) musclePath <- shQuote(musclePath)
if(length(grep(" ",fastacmdPath, fixed=T)) > 0 ) fastacmdPath <- shQuote(fastacmdPath)
thisVarCount <- new("varCount", rawTotal=0,
rawUniqueCount =0,
usedRawTotal=0,
usedRawUniqueCount=0,
subAlignTotal=0,
subAlignUniqueCount=0,
varCountTable=data.frame())
varCountTable <- data.frame()
#thisMarker <- "DPA1_E2"
#thisSample <- "MID-1"
fPairSeqList <- intersect(sampleMap[[thisSample]], fMarkerMap[[thisMarker]]) # fMarkerMap[[thisMarker]]
rPairSeqList <- intersect(sampleMap[[thisSample]], rMarkerMap[[thisMarker]])
# extract raw seqs from blastdb for forward hits. # THIS FUNCT CURRENTLY UNUSED BECAUSE NEED TO ASSESS IF ANYTHING TO QUERY BEFORE RUNNING fastacmd
extractRawSeqsCommand <- function(idList,strand=1, fileName) {
queryList <- paste(idList , collapse=",")
fastacmdCommand <- paste(fastacmdPath, "-p F -t T -d", "inputSeqs" , "-S", strand, "-o", fileName, "-s", queryList)
return(fastacmdCommand)
}
fRawSeqs <- rRawSeqs <- list()
## 12th Dec 11. Edited following rawseq extraction because failed when using large dataset. Replaced '-s' (queryList) option with '-i' (inputfile)
if(length(fPairSeqList ) > 0) {
fIdFileName <- paste("test", thisMarker, thisSample, "fIdFile.txt",sep=".")
write(fPairSeqList , file=fIdFileName )
fRawSeqFileName <- paste("test", thisMarker, thisSample, "fRawSeqExtract.fasta",sep=".")
strand <- 1
fastacmdCommand <- paste(fastacmdPath, "-p F -t T -d", "inputSeqs" , "-S", strand, "-o", fRawSeqFileName, "-i", fIdFileName)
system(fastacmdCommand)
fRawSeqs <- read.fasta(fRawSeqFileName , as.string=T)
}
if(length(rPairSeqList ) > 0) {
rIdFileName <- paste("test", thisMarker, thisSample, "rIdFile.txt",sep=".")
write(rPairSeqList , file=rIdFileName )
rRawSeqFileName <- paste("test", thisMarker, thisSample, "rRawSeqExtract.fasta",sep=".")
strand <- 2
fastacmdCommand <- paste(fastacmdPath, "-p F -t T -d", "inputSeqs" , "-S", strand, "-o", rRawSeqFileName, "-i", rIdFileName)
system(fastacmdCommand)
rRawSeqs <- read.fasta(rRawSeqFileName , as.string=T)
}
# Make file of unique seqs. Can name with sequence
### STRAND!!! - Done!
# ver 0.14 March2012 - New algorithm required. Take minimum unique raw variants to achieve:-
################ NO 50% (minPropReads) of reads
# or 30 most abundant unique variants (maxVarsToAlign)
# or 500 reads (minTotalCount), whichever is larger.
rawSeqs <- c(fRawSeqs ,rRawSeqs )
# filter out sequences shorter than minLength. Value of 0 means no filter.
if(minLength > 0) rawSeqs <- rawSeqs[which(nchar(rawSeqs) > minLength)]
totalRaw <- length(rawSeqs)
if(totalRaw < 1) {
#return(varCountTable)
return(thisVarCount)
}
rawSeqCountTable <- as.data.frame(table(unlist(rawSeqs)))
rawVariantCount <- nrow(rawSeqCountTable)
names(rawSeqCountTable) <- c("var", "count")
rawSeqCountTable <- rawSeqCountTable[order(rawSeqCountTable$count, decreasing=T),] # most abundant raw vars at top of list.
#minTotalCount <- ceiling(totalRaw * minPropReads) # want to catch at least this many raw reads.
#enoughReadsIndex <- cumsum(rawSeqCountTable$count)
useIndex <- min(maxVarsToAlign, nrow(rawSeqCountTable))
if(totalRaw > minTotalCount) {
#use only most abundant 30 (maxVarsToAlign) unique variants.
rawSeqCountTable <- rawSeqCountTable[1:useIndex,]
}
usedTotalRaw <- sum(rawSeqCountTable$count)
usedVarCount <- nrow(rawSeqCountTable)
cat(paste(thisSample,": Using", nrow(rawSeqCountTable), "variants, accounting for", usedTotalRaw, "of", totalRaw, "reads\n"))
rawVariantFile <- paste("test", thisMarker, thisSample, "raw.variants.fasta",sep=".") #"localVariants.fasta"
#rawVariantFile <- paste(runPath, rawVariantFileName, sep="/")
#v0.14# write.fasta(as.list(c(markerSeq,as.character(rawSeqCountTable$var))) ,c(thisMarker,as.character(rawSeqCountTable$var)),file.out=rawVariantFile ,open="w") # align marker AND raw variants
write.fasta(as.list(as.character(rawSeqCountTable$var)) ,as.character(rawSeqCountTable$var),file.out=rawVariantFile ,open="w") # align just raw variants
# Align all seqs
rawAlignFile <- paste("test", thisMarker, thisSample, "raw.align.fasta",sep=".") #"localAlign.fasta"
#rawAlignFile <- paste(runPath, rawAlignFileName, sep="/")
##Removed for ver0.14
#if(rawVariantCount > 800) {
# muscleCommand <- paste(musclePath, "-in", rawVariantFile , "-out", rawAlignFile , "-diags -quiet -maxiters 2" ) # faster alignment
# warning(paste("Using fast MUSCLE alignment for ", thisMarker, thisSample, rawVariantCount, "sequences\n"))
#} else {
muscleCommand <- paste(musclePath, "-in", rawVariantFile , "-out", rawAlignFile , "-diags -quiet" )
#}
#cat(paste(muscleCommand, "\n"))
system(muscleCommand)
#v0.14# error Correct if required
if(errorCorrect) {
alignedVars <- read.fasta(rawAlignFile, as.string=T)
seqCounts <- rawSeqCountTable$count[match(names(alignedVars),rawSeqCountTable$var)]
#cat(seqCounts)
#DONE MUST: strip off aligned marker and add back on - do not want this to be 'corrected' to match all other seqs.
#seqCounts <- varCountTable$count
## important to 'unpack' the alignment so that each sequence occurs the correct number of times.
sampleSeqs <- rep(alignedVars , seqCounts)
thisAlign <- as.alignment(sum(seqCounts), names(sampleSeqs), as.character(sampleSeqs))
if(exists("verbose")) cat(paste(length(unique(thisAlign$seq)),"/", thisAlign$nb,"unique seqs in original alignment, "))
newAlign <- errorCorrect.alignment(thisAlign, correctThreshold)
# need to repack this alignment
if(exists("verbose")) cat(paste(length(unique(newAlign$seq)),"/", newAlign$nb,"unique seqs in new alignment, "))
## DONE: repack the corrected alignment re-attribute the allele names. Update the markerSampleTable
newCountTable <- as.data.frame(table(unlist(newAlign$seq)),stringsAsFactors=FALSE)
rawSeqCountTable <- data.frame(alignedVar=newCountTable$Var1, count=as.numeric(newCountTable$Freq),stringsAsFactors=FALSE)
rawSeqCountTable$var <- gsub("-","",rawSeqCountTable$alignedVar)
rawSeqCountTable <- rawSeqCountTable[order(rawSeqCountTable$count,decreasing=T),]
#cat(paste("rawSeqCountTable rows:", nrow(rawSeqCountTable), "\n"))
rawAlignFile.corrected <- paste("test", thisMarker, thisSample, "raw.align.corrected.fasta",sep=".") #"localAlign.fasta"
#write.fasta(as.list(newAlign$seq), newAlign$nam, file.out=rawAlignFile.corrected )
write.fasta(as.list(rawSeqCountTable$alignedVar), rawSeqCountTable$var, file.out=rawAlignFile.corrected )
rawAlignFile <- rawAlignFile.corrected
}
#v0.14# Align marker sequence using profile alignment (not done as part of base alignment so that errorCorrect can be run on rawAlignment).
markerSeqFile <- paste(thisMarker, "markerSeq.fasta", sep=".")
write.fasta(markerSeq, thisMarker, file.out=markerSeqFile )
rawPlusMarkerFile <- paste("test", thisMarker, thisSample, "raw.marker.align.fasta",sep=".") #"localAlign.fasta"
muscleCommand <- paste(musclePath, "-profile -quiet -in1", rawAlignFile , "-in2", markerSeqFile , "-out", rawPlusMarkerFile )
system(muscleCommand)
#v0.14# Extract portion corresponding to reference.
rawAlignFile <- rawPlusMarkerFile
rawAlignment <- read.fasta(rawAlignFile, as.string=T) # do not use read.alignment() - broken
alignedMarkerSeq <- s2c(rawAlignment[[thisMarker]])
subStart <- min(grep("-",alignedMarkerSeq ,invert=T))
subEnd <- max(grep("-",alignedMarkerSeq ,invert=T))
alignedSubSeqs <- lapply(rawAlignment, FUN=function(x) substr(x[1], subStart, subEnd))
subAlignFile <- paste("test", thisMarker, thisSample, "sub.align.fasta",sep=".") #"localAlign.fasta"
#subAlignFile <- paste(runPath, subAlignFileName , sep="/")
write.fasta(alignedSubSeqs , names(alignedSubSeqs ), file.out=subAlignFile )
alignedSubTable <- data.frame(var = names(alignedSubSeqs ) , subSeq= as.character(unlist(alignedSubSeqs )))
# Re-apply count of each seq. There may be some duplicated subSeqs.
combTable <- merge(rawSeqCountTable ,alignedSubTable , by="var", all.x=T)
varCount <- by(combTable, as.character(combTable$subSeq), FUN=function(x) sum(x$count))
varCountTable <- data.frame(alignedVar=names(varCount), count=as.numeric(varCount),stringsAsFactors=FALSE) ## added stringsAsFactors=FALSE to enable passing of aligned list
varCountTable$var <- gsub("-","",varCountTable$alignedVar)
varCountTable <- varCountTable[order(varCountTable$count,decreasing=T),]
thisVarCount <- new("varCount", rawTotal=totalRaw,
rawUniqueCount = rawVariantCount ,
usedRawTotal = usedTotalRaw,
usedRawUniqueCount = usedVarCount,
subAlignTotal = sum(varCountTable$count),
subAlignUniqueCount = nrow(varCountTable),
varCountTable = varCountTable)
#return(varCountTable)
return(thisVarCount)
}
#mlgt <- function(object) attributes(object)
#setGeneric("mlgt")
#' Get variants for all markers/samples
#'
#' \code{mlgt} Works through all pairs of markers and samples. Aligns variants and trims aligned variants to the marker sequence. Potential 'alleles' are assigned from the most common variants within each sample.
#'
#' Depends upon \code{\link{prepareMlgtRun}} having been run in the current directory to generate \option{designObject} of class \code{\link{mlgtDesign}}.
#' The basic process for each marker/sample pair is to align all unique variants using MUSCLE and then extract the alignment portion aligned to the reference marker sequence, ignoring the rest.
#' The marker alignment is critical and \code{\link{mlgt}} has several options to optimise this alignment.
#' If the total number of reads is less than minTotalCount, then all variants are aligned. Otherwise, only the most abundant 30 unique variants are aligned.
#' Optionally, alignments are `error-correted' as per the separate function \code{\link{errorCorrect}}. Reads shorter than 'minLength' are filtered out.
#'
#' @param designObject an object of class \code{\link{mlgtDesign}}
#' @param minTotalCount How many assigned sequences to allow before limiting the number of raw variants to allign.
#' @param maxVarsToAlign If total assigned sequences exceeds 'minTotalCount', then only the 'maxVarsToAlign' most abundant variants are used.
#' @param errorCorrect Use error correection on alignment of raw variants
#' @param correctThreshold Maximum proportion of raw reads at which (minor allele) bases and gaps are corrected.
#' @param minLength Reads below this length are excluded (they are very likely to be primer-dimers).
#' @param varsToName How many variants from each sample should be tracked across samples (default=3) (NOT YET IMPLEMENTED)
#'
#' @return an object of class \code{\link{mlgtResult}} containing all variants and their counts, a summary table (all markers) and one summary table per marker.
#' @seealso \code{\link{prepareMlgtRun}}
#'
#' @export
#' @docType methods
#' @rdname mlgt-methods
#' @aliases mlgt.mlgtDesign
mlgt <- function(designObject, maxVarsToAlign=30, minTotalCount=500, errorCorrect=FALSE,correctThreshold=0.01, minLength=70, varsToName=3) attributes(designObject)
setGeneric("mlgt")
# TODO: use varsToName to determine columns varName.x and varFreq.x
# TODO: use varsToName to determine alToRecord
# e.g. varNamedDataFrame <- function(varName, n) {
# as.data.frame(matrix(NA, nrow=1, ncol=n,dimnames=list(NULL,paste("varName", 1:n, sep="."))))
# }
#test <- varNamedDataFrame(allele, 3) # then use cbind.
# TODO: replace use of "NA" with NA
# TODO: varCountTables=varCountTableList Seems to be allowing repeats of some sequences if their alignments hold different '-' gap positions.
# TODO: Not a problem for variantMap, which uses ungapped sequence, but untidy all the same.
mlgt.mlgtDesign <- function(designObject, maxVarsToAlign=30, minTotalCount=500, errorCorrect=FALSE,correctThreshold=0.01, minLength=70, varsToName=3) {
topHits <- getTopBlastHits("blastOut.markers.tab")
topHits$strand <- ifelse(topHits$s.end > topHits$s.start, 1,2)
fMarkerMap <- split(as.character(topHits$query[topHits$strand==1]), topHits$subject[topHits$strand==1])
rMarkerMap <- split(as.character(topHits$query[topHits$strand==2]), topHits$subject[topHits$strand==2])
## DONE: alter this section to allow different MIDs at either end and, hence, use result from both "blastOut.rTags.tab" and "blastOut.fTags.tab"
## when f and r MIDs are the same, the "blastOut.rTags.tab" and "blastOut.fTags.tab" will produce the same topHIts.
## when f and r MIDs are different, these files will differ and need to be combined.
## NEED TO MAKE SAMPLEMAP WITH HITS TO MID IN BOTH FORWARD AND REVERSE STRANDS like marker hits are split.
## Requires retention of 2 blast hits per sequence.
rTopSampleHits <- read.delim("blastOut.rTags.tab", header=F)
names(rTopSampleHits) <- c("query", "subject", "percentId", "aliLength", "mismatches", "gapOpenings", "q.start","q.end", "s.start","s.end", "p_value", "e_value")
rSampleMap <- split(as.character(rTopSampleHits$query), rTopSampleHits$subject)
fTopSampleHits <- read.delim("blastOut.fTags.tab", header=F)
names(fTopSampleHits) <- c("query", "subject", "percentId", "aliLength", "mismatches", "gapOpenings", "q.start","q.end", "s.start","s.end", "p_value", "e_value")
fSampleMap <- split(as.character(fTopSampleHits$query), fTopSampleHits$subject)
# combind sampleMaps to give sequences with MIDs in both orientations.
pairedSampleMap <- lapply(names(fSampleMap), FUN=function(x) intersect(fSampleMap[[x]], rSampleMap[[x]]))
names(pairedSampleMap) <- names(fSampleMap)
##########ITERATIONS
markerSampleList <- list()
runSummaryTable <- data.frame()
alleleDb <- list()
varCountTableList <- list()
if(errorCorrect) cat(paste("Using error correction at", correctThreshold, "\n"))
for(thisMarker in names(designObject@markers)) {
#for(thisMarker in names(markerMap)) {
#for(thisMarker in names(markerMap)[1:2]) { # temp to finish off
cat(paste(thisMarker,"\n"))
#cat("New Version\n")
#thisMarker <- "DQA1_E2"
## might need to combine all these to return a single item.
summaryList <- list()
summaryTable <- data.frame()
markerSequenceCount <- list("noSeq"=0) # BUG? requires some data otherwise won't sum properly with localSequenceCount.
alleleList <- list()
variantList <- list()
alleleCount <- 1
markerSeq <- unlist(getSequence(designObject@markers[[thisMarker]],as.string=T))
varCountTableList[[thisMarker]] <- data.frame()
for(thisSample in designObject@samples) {
#for(thisSample in names(pairedSampleMap)[1:4]) {
#print(thisSample)
testPairSeqList <- intersect(pairedSampleMap[[thisSample]],union(fMarkerMap[[thisMarker]], rMarkerMap[[thisMarker]]))
#testPairSeqList <- intersect(pairedSampleMap[[thisSample]], markerMap[[thisMarker]])
#testPairSeqList <- intersect(sampleMap[[thisSample]], markerMap[[thisMarker]])
seqTable <- data.frame()
localAlleleNames <- c("NA","NA","NA")
localAlleleFreqs <- c(0,0,0)
## go through all seq's mapped to this marker/sample pair.
## extract the corresponding sequence delimited by the top blast hits on the primers. IS THIS THE BEST WAY?
## Simple improvement: minimum blast hit length to primer to keep.
## internal Function
# TODO: use varsToName to determine columns varName.x and varFreq.x
recordNoSeqs <- function(summaryTable) { # to record no seqs before skipping out.
summaryRow <- data.frame(marker=thisMarker, sample=thisSample,
rawTotal=0, rawVars=0,
usedTotal=0, usedVars=0,
numbSeqs=0,numbVars=0,
varName.1="NA", varFreq.1= 0,
varName.2="NA", varFreq.2= 0,
varName.3="NA", varFreq.3= 0)
summaryTable <- rbind(summaryTable, summaryRow)
return(summaryTable)
}
if(length(testPairSeqList) < 1) {
#summaryList[[thisMarker]][[thisSample]] <- NA
summaryTable <- recordNoSeqs(summaryTable)
next ; # skip to next sample
}
## Ver. 0.14 - edited getSubSeqsTable to return object of class 'varCount' , which includes the required table.
# seqTable <- getSubSeqsTable(thisMarker, thisSample, pairedSampleMap, fMarkerMap,rMarkerMap, markerSeq)
thisVarCount <- getSubSeqsTable(thisMarker, thisSample, pairedSampleMap, fMarkerMap,rMarkerMap, markerSeq,
maxVarsToAlign=maxVarsToAlign, minTotalCount=minTotalCount, errorCorrect=errorCorrect,
correctThreshold=correctThreshold, minLength=minLength)
seqTable <- thisVarCount@varCountTable
#cat(paste("Raw total:",thisVarCount@rawTotal,"\n"))
# if no sequences returned, nothing to process.
if(nrow(seqTable) < 1 ) {
summaryTable <- recordNoSeqs(summaryTable)
#summaryList[[thisMarker]][[thisSample]] <- NA
next ; # go to next sample.
}
# store sequence and count of sequence as alignedVar (needed for alignment report)
# TODO: this could be source of error as alignedVar is not ALWAYS the same across samples for same variant.
# return to using seqTable$var BUT need another way of producing alignment report
varCountTableList[[thisMarker]][seqTable$alignedVar,thisSample] <- seqTable$count
#varCountTableList[[thisMarker]][seqTable$var,thisSample] <- seqTable$count
#localSequenceMap <- split(seqTable[,2], seqTable[,1])
#localSequenceCount <- lapply(localSequenceMap , length) # list named by sequence with counts.
#localSequenceCount <- localSequenceCount[order(as.numeric(localSequenceCount), decreasing=T)]
## test if variants are novel.
## Give allele names?
## Do with first three for now.
# TODO: use varsToName to determine alToRecord
alToRecord <- min(3,nrow(seqTable)) # required to cope with fewer than n variants.
if(alToRecord > 0) {
for (a in 1:alToRecord ) {
if(is.null(variantList[[seqTable$var[a]]])) { # novel
alleleName <- paste(thisMarker, alleleCount,sep=".")
variantList[[seqTable$var[a]]] <- alleleName
localAlleleNames[a] <- alleleName
localAlleleFreqs[a] <- seqTable$count[a]
alleleCount <- alleleCount + 1
} else { # pre-existing alllele
localAlleleNames[a] <- variantList[[seqTable$var[a]]]
localAlleleFreqs[a] <- seqTable$count[a]
}
}
}
# sequence correction?
# compile stats
if(nrow(seqTable) >0 ) { # cannot allow assignment from empty list as messes up class of list for remaining iterations
summaryList[[thisMarker]] <- list()
summaryList[[thisMarker]][[thisSample]] <- seqTable
}
# TODO: use varsToName to determine varName and varFreq columns.
summaryRow <- data.frame(marker=thisMarker, sample=thisSample,
rawTotal=thisVarCount@rawTotal, rawVars=thisVarCount@rawUniqueCount,
usedTotal=thisVarCount@usedRawTotal, usedVars=thisVarCount@usedRawUniqueCount,
numbSeqs=sum(seqTable$count),numbVars=nrow(seqTable),
varName.1=localAlleleNames[1], varFreq.1= localAlleleFreqs[1],
varName.2=localAlleleNames[2], varFreq.2= localAlleleFreqs[2],
varName.3=localAlleleNames[3], varFreq.3= localAlleleFreqs[3])
summaryTable <- rbind(summaryTable, summaryRow)
#sequence count across samples?
# need to sum from summaryTable or from summaryList.
#markerSequenceCount <-
#as.list(colSums(merge(m, n, all = TRUE), na.rm = TRUE)) # not working
localSequenceCount <- as.list(seqTable$count)
names(localSequenceCount) <- seqTable$var
markerSequenceCount <- as.list(colSums(merge(markerSequenceCount , localSequenceCount, all = TRUE), na.rm = TRUE))
# might need to instantiate the markerSequenceCount if empty.
} # end of sample loop
markerSampleList[[thisMarker]] <- summaryTable
## DONE: min(nchar(names(variantList))) throws warning when no variants in list. (Inf/-Inf)
minVarLength <- ifelse(length(markerSequenceCount) < 1, NA, min(nchar(names(markerSequenceCount))) )
maxVarLength <- ifelse(length(markerSequenceCount) < 1, NA, max(nchar(names(markerSequenceCount))) )
minAleLength <- ifelse(length(variantList) < 1, NA, min(nchar(names(variantList))) )
maxAleLength <- ifelse(length(variantList) < 1, NA, max(nchar(names(variantList))) )
runSummaryRow <- data.frame(marker=thisMarker, assignedSeqs=sum(summaryTable$numbSeqs), assignedVariants=sum(summaryTable$numbVars),
minVariantLength=minVarLength,
maxVariantLength=maxVarLength,
minAlleleLength=minAleLength, maxAlleleLength=maxAleLength )
runSummaryTable <- rbind(runSummaryTable, runSummaryRow)
if(length(variantList) > 0) {
# This line replaced. Not entirely tested the repurcussions. e.g. makeVarAlleleMap()?
#alleleDb[[thisMarker]] <- variantList # LATER: separate lists for alleles and variants?
#alleleDb[[thisMarker]] <- list(reference=as.SeqFastadna(markerSeq, thisMarker), alleleMap=variantList, inputAlleleCount = length(unlist(variantList)), uniqueSubAlleleCount=length(variantList))
alleleDb[[thisMarker]] <- new("variantMap", reference=as.SeqFastadna(markerSeq, thisMarker),
variantSource=paste(designObject@projectName, designObject@runName,sep="."),
variantMap=variantList, inputVariantCount = length(unlist(variantList)), uniqueSubVariantCount=length(variantList))
}
} # end of marker loop
localMlgtResult <- new("mlgtResult", designObject, runSummaryTable=runSummaryTable , alleleDb=alleleDb, markerSampleList=markerSampleList,
varCountTables=varCountTableList)
return(localMlgtResult)
} # end of mlgt function
#' @rdname mlgt-methods
#' @aliases mlgt,mlgtDesign-method
setMethod("mlgt",signature(designObject="mlgtDesign", maxVarsToAlign="ANY", minTotalCount="ANY", errorCorrect="ANY",correctThreshold="ANY", minLength="ANY", varsToName="ANY"), definition=mlgt.mlgtDesign)
#INTERNAL. Does this need documenting?
# Create a local BLAST db
#
# This internal utility uses \code{system(fomatdb)} to create a local BLAST database
#
# Requires the NCBI program formatdb to be installed and the environment variable formatdbPath to be set.
#
# @param inputFastaFile
# @param formatdbPath
# @param blastdbName
# @param indexDb Whether to generate an index for the db. Useful for large db of sequences, which are later to be extracted with fastacommand
#
#
setUpBlastDb <- function(inputFastaFile, formatdbPath, blastdbName, indexDb="F") {
formatdbCommand <- paste(formatdbPath, "-i", inputFastaFile , "-p F -o", indexDb ,"-n", blastdbName)
#cat(paste(formatdbCommand,"\n"))
system(formatdbCommand)
}
quoteIfSpaces <- function(pathString) {
if(length(grep(" ",pathString, fixed=T)) > 0 ) {
pathString <- shQuote(pathString)
}
return(pathString)
}
copyIfSpaces <- function(pathString) {
if(length(grep(" ",pathString, fixed=T)) > 0 ) {
newName <- make.names(basename(pathString))
file.copy(pathString,newName , overwrite=TRUE)
cat(paste("BLAST and MUSCLE cannot cope with whitespace in filenames.\nCopying",pathString,"to",newName,"\n"))
return(newName)
} else {
return(pathString)
}
}
#prepareMlgtRun <- function(object) attributes(object)
#prepareMlgtRun <- function(designObject) attributes(designObject)
#' Prepare to run mlgt
#'
#' Required before \code{\link{mlgt}} is used. Create BLAST databases and assign sequences using BLAST.
#'
#' This important function stores all the information about the analysis run AND populates the working directory
#' with multiple local Blast databases, which are later required by \code{\link{mlgt}}.
#' Once \code{prepareMlgtRun} has been run, \code{\link{mlgt}} can be run aswell as
#' \code{\link{printBlastResultGraphs}} and \code{\link{inspectBlastResults}}.
#'
#' @param designObject Only used internally.
#' @param projectName In which project does this run belong
#' @param runName Which run was this. An identifier for the sequnece run
#' @param markers A \emph{list} of named sequences.
#' @param samples A vector of sample names
#' @param fTags A vector of named sequence of MIDs used to barcode samples at the 5' end.
#' @param rTags A vector of named sequence of MIDs used to barcode samples at the 3' end.
#' @param inputFastaFile The name of the file containing sequences. Currently only fasta format is supported. It is up to you to pre-filter the sequences.
#' @param overwrite Should files in the current directory be overwritten? c("prompt", "yes", "no")
#'
#' @return An object of class \code{\link{mlgtDesign}} is returned. Also, several BLAST dbs and sets of BLAST results are created in the working directory.
#' These are essential for \code{\link{mlgt}} to run.
#'
#' @rdname prepareMlgtRun-methods
#' @export
#' @aliases prepareMlgtRun.listDesign,prepareMlgtRun.mlgtDesign
#' @seealso \code{\link{printBlastResultGraphs}} and \code{\link{inspectBlastResults}} can only be run AFTER \code{prepareMlgtRun}.
prepareMlgtRun <- function(designObject,projectName,runName, samples, markers,fTags,rTags, inputFastaFile, overwrite) attributes(designObject)
setGeneric("prepareMlgtRun")
prepareMlgtRun.listDesign <- function(projectName,runName, samples, markers,fTags,rTags, inputFastaFile,overwrite="prompt") {
# test inputFastaFile for spaces
inputFastaFile <- copyIfSpaces(inputFastaFile)
#if(length(grep(" ",inputFastaFile, fixed=T)) > 0 ) stop(paste("mlgt cannot handle path names with whitespace. Sorry.\n ->>",inputFastaFile,"\n"))
##inputFastaFile <- quoteIfSpaces(inputFastaFile)
designObject <- new("mlgtDesign", projectName=projectName, runName=runName,
samples=samples, markers=markers ,
fTags=fTags, rTags=rTags, inputFastaFile=inputFastaFile)
designObject <- prepareMlgtRun(designObject,overwrite=overwrite)
}
#' @rdname prepareMlgtRun-methods
#' @aliases prepareMlgtRun,missing,character,character,character,list,list,list,character,character-method
setMethod("prepareMlgtRun",
signature(designObject="missing",projectName="character", runName="character", samples="character",markers="list",
fTags="list", rTags="list", inputFastaFile="character", overwrite="character"),
definition=prepareMlgtRun.listDesign)
prepareMlgtRun.mlgtDesign <- function(designObject, overwrite="prompt") {
cat(paste(designObject@projectName,"\n"))
#check pathNames of auxillary programs.
pathNames <- c("BLASTALL_PATH","FORMATDB_PATH","FASTACMD_PATH","MUSCLE_PATH")
for(thisPath in pathNames) {
if(nchar(Sys.getenv(thisPath)) < 1) {
stop(paste(thisPath,"has not been set!"))
}
# shellQuote any paths containing spaces.
# Can't use variables in Sys.setenv
#if(length(grep(" ",Sys.getenv(thisPath), fixed=T)) > 0 ) Sys.setenv(thisPath= shQuote(thisPath))
}
formatdbPath <- Sys.getenv("FORMATDB_PATH")
fastacmdPath <- Sys.getenv("FASTACMD_PATH")
blastAllPath <- Sys.getenv("BLASTALL_PATH")
# shellQuote any paths containing spaces.
if(length(grep(" ",formatdbPath, fixed=T)) > 0 ) formatdbPath <- shQuote(formatdbPath)
if(length(grep(" ",fastacmdPath, fixed=T)) > 0 ) fastacmdPath <- shQuote(fastacmdPath)
if(length(grep(" ",blastAllPath, fixed=T)) > 0 ) blastAllPath <- shQuote(blastAllPath)
# runPath <- getwd() # could change this later
# if(length(grep(" ",runPath , fixed=T)) > 0 ) {
# stop("mlgt cannot yet cope with path names containing spaces. Please move to a folder with no spaces in path. Sorry. \n")
# }
# fTagsFastaFile <- paste(runPath,"fTags.fasta", sep="/")
# rTagsFastaFile <- paste(runPath,"rTags.fasta", sep="/")
# markersFastaFile <- paste(runPath,"markers.fasta", sep="/")
# rTagsBlastOutFile <- paste(runPath,"blastOut.rTags.tab", sep="/")
# fTagsBlastOutFile <- paste(runPath,"blastOut.fTags.tab", sep="/")
# blastOutFileName <- "blastOut.markers.tab"
# markerBlastOutFile <- paste(runPath, blastOutFileName, sep="/")
# removed concatenation of runPath because of issue with space character. All output must now go to working directory
fTagsFastaFile <- "fTags.fasta"
rTagsFastaFile <- "rTags.fasta"
markersFastaFile <- "markers.fasta"
rTagsBlastOutFile <- "blastOut.rTags.tab"
fTagsBlastOutFile <- "blastOut.fTags.tab"
blastOutFileName <- "blastOut.markers.tab"
markerBlastOutFile <- blastOutFileName #redundant?
existingFiles <- (file.exists(fTagsFastaFile ) | file.exists(rTagsFastaFile ) | file.exists(markersFastaFile ) |
file.exists(rTagsBlastOutFile) | file.exists(fTagsBlastOutFile) | file.exists(markerBlastOutFile))
if(existingFiles) {
overwrite <- tolower(overwrite)
# set up new directories if required.
if(overwrite == "prompt") overwrite <- readline("This folder already contains mlgt run files, do you want to write over this data? (yes/no)")
if(!(overwrite=="y" | overwrite=="n" | overwrite=="yes" | overwrite=="no")) {stop(paste("Unrecognised value for overwrite:", overwrite))}
overWriteBaseData <- switch(overwrite,
"yes"=TRUE,
"y"=TRUE,
"no"=FALSE,
"n"=FALSE)
if(!overWriteBaseData) {stop("This folder already contains mlgt run files. Exiting")}
}
cat("Checking parameters...\n")
#check names and sequences of samples, markers, and barcodes for duplication. Check barcodes for consistent length
fMinTagSize <- min(nchar(designObject@fTags))
if(!all(nchar(designObject@fTags) == fMinTagSize )) {
stop("fTags (barcodes) must all be of same length\n")
}
rMinTagSize <- min(nchar(designObject@rTags))
if(!all(nchar(designObject@rTags) == rMinTagSize )) {
stop("rTags (barcodes) must all be of same length\n")
}
if(anyDuplicated(as.character(designObject@fTags)) > 0 ) stop("Duplicated fTag sequences\n")
if(anyDuplicated(names(designObject@fTags)) > 0 ) stop("Duplicated fTag names\n")
if(anyDuplicated(as.character(designObject@rTags)) > 0 ) stop("Duplicated rTag sequences\n")
if(anyDuplicated(names(designObject@rTags)) > 0 ) stop("Duplicated rTag names\n")
if(anyDuplicated(as.character(designObject@markers)) > 0 ) stop("Duplicated marker sequences\n")
if(anyDuplicated(names(designObject@markers)) > 0 ) stop("Duplicated marker names\n")
if(anyDuplicated(designObject@samples) > 0 ) stop("Duplicated sample names\n")
#runPath <- getwd()
# set up blast DBs
cat("Setting up BLAST DBs...\n")
write.fasta(designObject@fTags, names(designObject@fTags), file.out=fTagsFastaFile)
setUpBlastDb(fTagsFastaFile , formatdbPath, blastdbName="fTags") # default is no index
write.fasta(designObject@rTags, names(designObject@rTags), file.out=rTagsFastaFile )
setUpBlastDb(rTagsFastaFile , formatdbPath, blastdbName="rTags") # default is no index
write.fasta(designObject@markers, names(designObject@markers), file.out=markersFastaFile )
setUpBlastDb(markersFastaFile , formatdbPath, blastdbName="markerSeqs", indexDb="T")
## input as blast DB with index (useful for fast sub-sequence retrieval?)
inputFastaFile <- designObject@inputFastaFile #
setUpBlastDb(inputFastaFile , formatdbPath, blastdbName="inputSeqs", indexDb="T")
# run preliminary blast
cat("Running BLAST searches...\n")
#rMinTagSize <- 10 # limit blast hits to perfect matches. ### TODO: SET GLOBALLY
dbName <- "rTags"
blastCommand <- paste(blastAllPath , "-p blastn -d", dbName , "-i", inputFastaFile , "-W", rMinTagSize ,"-m 8 -b 2 -S 3 -o", rTagsBlastOutFile )
system(blastCommand )
#fMinTagSize <- 10 # limit blast hits to perfect matches.
dbName <- "fTags"
blastCommand <- paste(blastAllPath , "-p blastn -d", dbName , "-i", inputFastaFile , "-W", fMinTagSize ,"-m 8 -b 2 -S 3 -o", fTagsBlastOutFile )
system(blastCommand )
## blast against markers
dbName <- "markerSeqs"
blastCommand <- paste(blastAllPath , "-p blastn -d", dbName , "-i", inputFastaFile , "-W", 11 , "-m 8 -b 1 -o", markerBlastOutFile )
system(blastCommand )
designObject@markerBlastResults <- markerBlastOutFile
designObject@fTagBlastResults <- fTagsBlastOutFile
designObject@rTagBlastResults <- rTagsBlastOutFile
return(designObject)
}
##setMethod("prepareMlgtRun","mlgtDesign", definition=prepareMlgtRun.mlgtDesign)
#setMethod("prepareMlgtRun",signature(designObject="mlgtDesign"), definition=prepareMlgtRun.mlgtDesign)
#TODO: test if signature with overwrite="ANY" will work. First attempt, no.
#' @rdname prepareMlgtRun-methods
#' @aliases prepareMlgtRun,mlgtDesign,missing,missing,missing,missing,missing,missing,missing,character-method
setMethod("prepareMlgtRun",
signature(designObject="mlgtDesign",projectName="missing", runName="missing", samples="missing",markers="missing",
fTags="missing", rTags="missing", inputFastaFile="missing", overwrite="character"),
definition=prepareMlgtRun.mlgtDesign)
#setGeneric("prepareMlgtRun","mlgtDesign", definition=prepareMlgtRun.mlgtDesign)
######################### genotyping & allele matching
#' Results from \code{\link{callGenotypes}}
#'
#' An S4 class containing a table and parameter values returned by \code{\link{callGenotypes}}
#'
#' \describe{
#' \item{projectName}{In which project does this run belong}
#' \item{runName}{Which run was this. An identifier for the sequence run}
#' \item{marker}{Which marker was this.}
#' \item{genotypeTable}{A data frame with variant counts, statistics, genotype calls and, optionally, allele names.}
#' \item{callMethod}{Which method was used to call genotypes}
#' \item{callParameters}{a named list containing parameter values used in the call}
#' \item{mappedToAlleles}{TRUE/FALSE whether an attempt was made to map the variants to a db on known alleles.}
#' \item{alleleDbName}{A list of objects of class \code{\link{variantMap}}. Contains all variants returned by \code{\link{mlgt}}}
#' }
#'
#' @seealso \code{\link{callGenotypes}}, \code{\link{writeGenotypeCallsToFile}}
setClass("genotypeCall",
representation(
projectName="character",
runName="character",
marker="character",
genotypeTable="data.frame",
callMethod="character",
callParameters="list",
mappedToAlleles="logical",
alleleDbName="character"
)
)
#INTERNAL. Does this need documentation?
makeVarAlleleMap <- function(allele.variantMap, variant.variantMap) {
varAlleleMap <- data.frame()
# to use stopifnot, need to ensure no empty maps are passed. Currently this is happening so taking out this check.
#stopifnot(allele.variantMap@reference == variant.variantMap@reference)
knownAlleleTable <- data.frame(alleleSeq=names(allele.variantMap@variantMap), knownAlleles=as.character(allele.variantMap@variantMap))
dataAlleleTable <- data.frame(alleleSeq=names(variant.variantMap@variantMap), varNames=as.character(variant.variantMap@variantMap))
varAlleleMap <- merge(knownAlleleTable, dataAlleleTable , by="alleleSeq")
}
# deprecated and/or defunct
makeVarAlleleMap.list <- function(alleleDb, varDb,alleleMarkers=names(alleleDb),varMarkers=names(varDb)) {
knownAlleleTable <- data.frame()
for(thisMarker in alleleMarkers) {
knownAlleleTable <- rbind(knownAlleleTable , data.frame(alleleSeq=names(alleleDb[[thisMarker]]@alleleMap), knownAlleles=as.character(alleleDb[[thisMarker]]@alleleMap)))
}
dataAlleleTable <- data.frame()
for(thisMarker in varMarkers) {
# this first line is what it SHOULD be like, once mlgtResult is updated to match the alleleDb format. Need new class: alleleDb
dataAlleleTable <- rbind(dataAlleleTable , data.frame(alleleSeq=names(varDb[[thisMarker]]@alleleMap), varNames=as.character(varDb[[thisMarker]]@alleleMap)))
#dataAlleleTable <- rbind(dataAlleleTable , data.frame(alleleSeq=names(varDb[[thisMarker]]), varNames=as.character(varDb[[thisMarker]])))
}
varAlleleMap <- merge(knownAlleleTable, dataAlleleTable , by="alleleSeq")
}
vectorOrRepeat <- function(paramValue, requiredLength) {
# Used by callGenotypes.mgltResult() to equalise lengths of parameter vectors when one has length > 1
if(length(paramValue) == requiredLength) {
return(paramValue)
} else {
if(length(paramValue) == 1) {
return(rep(paramValue, requiredLength))
} else {
stop(paste("Parameter has length",length(paramValue) ,"but does not match required length", requiredLength))
}
}
}
# replacement for vectorOrRepeat for cases where custom methods are allowed in callGenotypes().
# Returns a list of lists each identical except where user specified a vector of parameter values.
makeBigParamList <- function(..., markerCount) {
params <- list(...)
paramBigList <- list()
for(i in 1:markerCount) {
paramBigList[[i]] <- params
}
lengthList <- lapply(params , length)
vecParams <- which(lengthList > 1)
if(length(vecParams) > 0) {
vecNames <- names(params)[vecParams]
#cat(vecParams)
if(any(lengthList[vecParams] != markerCount)) { stop("Vector supplied that does not match length of markerList") }
for(i in 1:length(vecParams)) {
for(j in 1:markerCount) {
paramBigList[[j]][[vecNames[i]]] <- params[[vecNames[i]]][j]
}
}
}
return(paramBigList)
}
# Used for approximate (BLAST) variant to allele matching.
# returns a standard blast table with single best hit per query.
makeVarAlleleBlastMap <- function(allele.variantMap, variant.variantMap) {
pathNames <- c("BLASTALL_PATH","FORMATDB_PATH","FASTACMD_PATH","MUSCLE_PATH")
for(thisPath in pathNames) {
if(nchar(Sys.getenv(thisPath)) < 1) {
stop(paste(thisPath,"has not been set!"))
}
# shellQuote any paths containing spaces.
# Can't use variables in Sys.setenv
#if(length(grep(" ",Sys.getenv(thisPath), fixed=T)) > 0 ) Sys.setenv(thisPath= shQuote(thisPath))
}
formatdbPath <- Sys.getenv("FORMATDB_PATH")
fastacmdPath <- Sys.getenv("FASTACMD_PATH")
blastAllPath <- Sys.getenv("BLASTALL_PATH")
# shellQuote any paths containing spaces.
if(length(grep(" ",formatdbPath, fixed=T)) > 0 ) formatdbPath <- shQuote(formatdbPath)
if(length(grep(" ",fastacmdPath, fixed=T)) > 0 ) fastacmdPath <- shQuote(fastacmdPath)
if(length(grep(" ",blastAllPath, fixed=T)) > 0 ) blastAllPath <- shQuote(blastAllPath)
thisMarker <- getName(allele.variantMap@reference)
cat(thisMarker)
#export known variants to fasta (may need to sort out names)
knownAsFastaFile <- paste(thisMarker, "knownAlleles.fasta", sep=".")
# some sub-alleles may have zero length (they didn't align at all with marker)
thisVariantMap <- allele.variantMap@variantMap
thisVariantMap <- thisVariantMap[nchar(names(thisVariantMap)) > 0]
#write the known alleles to a fasta file. The concatentated names must be truncated to XX chars for blast to run.
write.fasta(as.list(names(thisVariantMap)),substring(as.character(thisVariantMap),1,60), file.out=knownAsFastaFile )
#create blast DB of known variants.
dbName <- paste(thisMarker,"knownAlleles",sep=".")
setUpBlastDb(knownAsFastaFile , formatdbPath, blastdbName=dbName )
#export new variants to fasta
newVarsAsFastaFile <- paste(thisMarker, "newVars.fasta", sep=".")
write.fasta(as.list(names(variant.variantMap@variantMap)),as.character(variant.variantMap@variantMap), file.out=newVarsAsFastaFile )
#blast new variants against known DB
newVarBlastResultFile <- paste(thisMarker, "blastOut.newVars.tab", sep=".")
blastCommand <- paste(blastAllPath , "-p blastn -d", dbName , "-i", newVarsAsFastaFile , "-W", 11 , "-m 8 -b 1 -o", newVarBlastResultFile)
system(blastCommand)
#open and retrieve the results.
topHits <- getTopBlastHits(newVarBlastResultFile)
#return as a useful lookuptable
}
## call genotypes on a table of variant counts. Can select specific markers/samples to return.
#' Default internal methods for \code{\link{callGenotypes}}
#'
#' This is the default method to call genotypes from a table of variant counts.
#' Methods:-
#' \describe{
#' \item{`callGenotypes.default'}{Three sequential steps for each marker/sample pair:
#' \enumerate{
#' \item {if the number of reads is less than \code{minTotalReads} the genotype is \emph{`tooFewReads'} }
#' \item {if the difference between the sum of counts of the top two variants and the count of the third most variant, expressed as proportion of total, is less than \code{minDiffToVarThree}, OR the third most abundant variant accounts for more than maxPropVarThree (default=0.1) of the reads, then the genotype is \emph{`complexVars'}}
#' \item {if the difference between the counts of top two variants, expressed as a proportion of the total, is greater than or equal to \code{minPropDiffHomHetThreshold}, then the genotype is \emph{HOMOZYGOTE}. Otherwise it is \emph{HETEROZYGOTE}. }
#' }
#' }
#' }
#'
#' @param table The table of sequence counts as in the markerSampleTable of an mlgtResult object.
#' @param minTotalReads Minimum number of reads before attempting to call genotypes
#' @param minDiffToVarThree Difference between sum of counts of top two variants and the count of the third most frequent variant, expressed as proportion of total.
#' @param minPropDiffHomHetThreshold Difference between counts of top two variants. One way to distinguish HOMOZYGOTES and HETEROZYGOTES.
#' @param maxPropVarThree Also call as 'complexVars' if the third variant accounts for more than this proportion of used reads (default=0.1)
#' @return A data.frame identical to those in markerSampleList but with additional columns giving parameter values,
#' and a 'status' column giving the genotype status.
callGenotypes.default <- function(table, minTotalReads=50, minDiffToVarThree=0.4,
minPropDiffHomHetThreshold=0.3, maxPropVarThree=0.1) {
#table$genotype
table$status <- "notCalled"
enoughReads <- table$numbSeqs >= minTotalReads
table$status[!enoughReads] <- "tooFewReads"
# difference between sum of vars 1 + 2 and var 3, as proportion of total
# > 0.5 is good. <0.3 not good. 0.4 as cut-off for now?
table$diffToVarThree <- with(table, ((varFreq.1+varFreq.2)-varFreq.3)/numbSeqs)
table$propThree <- with(table, (varFreq.3)/numbSeqs)
#distinctVars <- with(table, diffToVarThree >= minDiffToVarThree)
distinctVars <- with(table, (diffToVarThree >= minDiffToVarThree) & propThree < maxPropVarThree)
table$status[enoughReads & !distinctVars] <- "complexVars"
# difference between var 1 and var2 as proportion of total
# homozygote: >0.3, often > 0.5
# heterozygote: <0.25, often < 0.1
table$propDiffHomHet <- with(table, ((varFreq.1-varFreq.2)/numbSeqs))
eligible <- (enoughReads & distinctVars)
table$status[eligible] <- ifelse((table$propDiffHomHet[eligible] >= minPropDiffHomHetThreshold), "HOMOZYGOTE","HETEROZYGOTE")
#table$homozygote <- with(table, ((varFreq.1-varFreq.2)/numbSeqs) >= minPropDiffHomHetThreshold)
return(table)
}
## example custom function
callGenotypes.custom <- function(table) {
table$status <- "notCalled"
return(table)
}
## TODO: split callGenotypes into subfunctions. Perform alleles matching and approx allele matching first if elected.
## Then do the parameter estimatation and HOM/HET calls.
## Then choose the representative alleles (use.1, use.2) and give sequences.
## To make this customisable, would need to include '...' as first argument so that users can add in variables. T
## This function would then pass those variables to the user supplied function
## Some rules will have to be made on required input and output.
## e.g. result should still be list of class "genotypeCall" but used could specify what the table can contain.
## and the user supplied parameters could be stored within the callParameters slot.
## IMPORTANT, would also need to sort out the generic set-up given below (probably no longer needed).
# generic method for callGenotypes.
#' Make genotype calls
#'
#' Apply a genotype call method to a table or list of tables of variant data such as the \code{markerSampleList} table of an \code{\link{mlgtResult}}.
#'
#' After \code{\link{mlgt}} has generated tables of the most common variants assigned in each marker/sample pair, an attempt can be made to call genotypes.
#' This is kept separate because users might want to try different calling methods and have the option to map to a known set of alleles. Currently, only
#' one method is implemented (\emph{`custom'}). See \code{\link{callGenotypes.default}}.
#' This function also includes the option to map variants to a list of known alleles created using \code{\link{createKnownAlleleList}}. The basic method makes only perfect matches but a secondary method can be triggered (approxMatching=TRUE) to find the allele with the greatest similarity using a local BLAST search.
#'
#'
#' @param resultObject An object of class \code{\link{mlgtResult}}, as returned by \code{\link{mlgt}}
#' @param alleleDb A list of \code{\link{variantMap}} objects derived from known alleles. As made by
#' \code{\link{createKnownAlleleList}}
#' @param method How to call genotypes. Currently only "callGenotypes.default" is implemented. Users can define
#' their own methods as R functions (see the vignette).
#' @param markerList For which of the markers do you want to call genotypes (default is all)?
#' @param sampleList For which of the samples do you want to call genotypes (default is all)?
#' @param mapAlleles FALSE/TRUE. Whether to map variants to db \option{alleleDb} of known alleles.
#' @param approxMatching If TRUE, a BLAST search is also performed to find matches (slower). Additional columns are added to the genoytpeTable
#' @param numbAllelesToMatch How many of the named variants should be matched to the alleleDb. Default=2.
#' @param ... Other parameter values will be passed to custom methods such as \code{\link{callGenotypes.default}}
#'
#' @return list of call results including the call parameters and a table of calls (class \code{\link{genotypeCall}}). If an mlgtResult object was supplied then a list of \code{\link{genotypeCall}} objects will be returned, each named by marker.
#'
#' @export
#' @docType methods
#' @aliases callGenotypes.mlgtResult
#' @examples \dontrun{
#' data("mlgtResult", package="mlgt")
#' my.mlgt.Result
#' # the default method
#' my.genoytpes <- callGenotypes(my.mlgt.Result)
#' # using a custom method
#' callGenotypes.custom <- function(table, maxPropUniqueVars=0.5) {
#' table$status <- "notCalled"
#' table$propUniqueVars <- table$numbVar/table$numbSeq
#' table$status <- ifelse(table$propUniqueVars <= maxPropUniqueVars,"good", "bad")
#' return(table)
#' }
#' my.custom.Genotypes <- callGenotypes(my.mlgt.Result, method="callGenotypes.custom")
#' }
callGenotypes <- function(resultObject, method="callGenotypes.default",
markerList=names(resultObject@markers),
sampleList=resultObject@samples, mapAlleles=FALSE, alleleDb=NULL, approxMatching=FALSE,
numbAllelesToMatch=2, ... ) {
## FM requested marker specific parameters.
## test for vectors in any of the calling parameters.
## if all are single, apply genotyping to one large table of all results,
## if any are vectors, need to apply genotyping to each marker separately.
## Should mark if different thresholds used.
## need to test that the threshold vector matches the markerlist length.
runTable <- data.frame()
genotypeTable <- data.frame()
callResults <- list()
# if(length(minTotalReads) > 1 | length(minDiffToVarThree) > 1 | length(minPropDiffHomHetThreshold) > 1 ) {
# find parameters as vectors and test the lengths. Set those which are only 1 to be length of markerList.
#minTotalReads <- vectorOrRepeat(minTotalReads, length(markerList))
#minDiffToVarThree <- vectorOrRepeat(minDiffToVarThree, length(markerList))
#minPropDiffHomHetThreshold<- vectorOrRepeat(minPropDiffHomHetThreshold, length(markerList))
longParamList <- makeBigParamList(..., markerCount=length(markerList))
# multiple parameter values set. Genotype each marker separately
for(i in 1:length(markerList)) {
thisMarker <- markerList[i]
subTable <- resultObject@markerSampleList[[thisMarker]]
subTable <- subTable[match(sampleList,subTable$sample),]
numbAllelesToMatch.used <- numbAllelesToMatch
if(nrow(subTable) < 1) {
# do nothing with this marker
warning(paste("No data for:",thisMarker))
} else {
thisParamList <- longParamList[[i]]
thisParamList[['table']] <- subTable
genotypeTable <- do.call(method, thisParamList )
countNamedVars <- max(as.numeric(sub('varName.','',names(genotypeTable)[grep('varName',names(genotypeTable))])))
if(countNamedVars < numbAllelesToMatch) {
warning(paste("Cannot match more variants than already have names:", thisMarker))
numbAllelesToMatch.used <- countNamedVars
}
#genotypeTable <- callGenotypes.table(subTable , alleleDb=alleleDb, method=method,minTotalReads=minTotalReads[i],
# minDiffToVarThree=minDiffToVarThree[i],
# minPropDiffHomHetThreshold=minPropDiffHomHetThreshold[i], mapAlleles=mapAlleles)
#genotypeTable <- rbind(genotypeTable , subGenoTable)
if(mapAlleles) {
# 2-step strategy.
# 1. Try perfect matching first. Quick and perfect.
# Keep track of which alleles were matched this way
# 2. Match with BLAST (build blast DB of known alleles and blast all new variants (once) against this.
# Record best hit and quality of best hit (percentID, percentlength)
if(is.null(alleleDb)) {
warning("No alleleDb specified\n")
} else {
if(is.null(alleleDb[[thisMarker]])) {
warning(paste("No known alleles for",thisMarker))
for(k in 1:numbAllelesToMatch.used) {
#genotypeTable$allele.1 <- "noKnownAlleles"
#genotypeTable$allele.2 <- "noKnownAlleles"
genotypeTable[paste('allele',k,sep=".")] <- "noKnownAlleles"
}
if(approxMatching) { # need to match column names
for(k in 1:numbAllelesToMatch.used) {
genotypeTable[paste('allele',k,'approx',sep=".")] <- NA
}
#genotypeTable$allele.1.approx <- NA
#genotypeTable$allele.2.approx <- NA
}
} else {
if(is.null(resultObject@alleleDb[[thisMarker]])) {
warning(paste("No variants for",thisMarker))
#genotypeTable$allele.1 <- NA
#genotypeTable$allele.2 <- NA
for(k in 1:numbAllelesToMatch.used) {
genotypeTable[paste('allele',k,sep=".")] <- NA
}
if(approxMatching) { # need to match column names
for(k in 1:numbAllelesToMatch.used) {
genotypeTable[paste('allele',k,'approx',sep=".")] <- NA
}
}
} else {
#varAlleleMap <- makeVarAlleleMap(alleleDb, resultObject@alleleDb, alleleMarkers=markerList, varMarkers=markerList)
varAlleleMap <- makeVarAlleleMap(allele.variantMap=alleleDb[[thisMarker]], variant.variantMap=resultObject@alleleDb[[thisMarker]])
#genotypeTable$allele.1 <- varAlleleMap$knownAlleles[match(genotypeTable$varName.1, varAlleleMap$varNames)]
#genotypeTable$allele.2 <- varAlleleMap$knownAlleles[match(genotypeTable$varName.2, varAlleleMap$varNames)]
for(k in 1:numbAllelesToMatch.used) {
#cat(paste('varName',k,sep="."))
genotypeTable[paste('allele',k,sep=".")] <- varAlleleMap$knownAlleles[match(genotypeTable[,paste('varName',k,sep=".")], varAlleleMap$varNames)]
}
if(approxMatching) { # perform approx matching by BLAST
cat("Attempting to find approximate matches using BLAST\n")
varAlleleBlastMap <- makeVarAlleleBlastMap(allele.variantMap=alleleDb[[thisMarker]], variant.variantMap=resultObject@alleleDb[[thisMarker]])
for(k in 1:numbAllelesToMatch.used) {
genotypeTable[paste('allele',k,'approx',sep=".")] <- varAlleleBlastMap$subject[match(genotypeTable[,paste('varName',k,sep=".")], varAlleleBlastMap$query)]
}
#genotypeTable$allele.1.approx <- varAlleleBlastMap$subject[match(genotypeTable$varName.1, varAlleleBlastMap$query)]
#genotypeTable$allele.2.approx <- varAlleleBlastMap$subject[match(genotypeTable$varName.2, varAlleleBlastMap$query)]
}
}
}
}
}
callResults[[thisMarker]] <- new("genotypeCall",
projectName=resultObject@projectName,
runName=resultObject@runName,
marker=thisMarker ,
genotypeTable=genotypeTable,
callMethod=method,
callParameters=longParamList[[i]],
mappedToAlleles=mapAlleles,
alleleDbName="NeedToSetThis" )
}
}
return(callResults)
}
### ver 0.14 have removed generics for callGenotypes to make mixed use of '...' and named parameters.
# generic method for callGenotypes.
## Make genotype calls
##
## Apply a genotype call method to a table or list of tables of variant data such as the \code{markerSampleList} table of an \code{\link{mlgtResult}}.
##
## After \code{\link{mlgt}} has generated tables of the most common variants assigned in each marker/sample pair, an attempt can be made to call genotypes.
## This is kept separate because users might want to try different calling methods and have the option to map to a known set of alleles. Currently, only
## one method is implemented (\emph{`custom'}).
## Methods:-
## \describe{
## \item{`callGenotypes.default'}{Three sequential steps for each marker/sample pair:
## \enumerate{
## \item {if the number of reads is less than \code{minTotalReads} the genotype is \emph{`tooFewReads'} }
## \item {if the difference between the sum of counts of the top two variants and the count of the third most variant, expressed as proportion of total, is less than \code{minDiffToVarThree}, then the genotype is \emph{`complexVars'}}
## \item {if the difference between the counts of top two variants, expressed as a proportion of the total, is greater than or equal to \code{minPropDiffHomHetThreshold}, then the genotype is \emph{HOMOZYGOTE}. Otherwise it is \emph{HETEROZYGOTE}. }
## }
## }
## }
##
##
## @param resultObject An object of class \code{\link{mlgtResult}}, as returned by \code{\link{mlgt}}
## @param table [Separate usage] A table of variant counts.
## @param alleleDb A list of \code{\link{variantMap}} objects derived from known alleles. As made by
## \code{\link{createKnownAlleleList}}
## @param method How to call genotypes. Currently only "callGenotypes.default" is implemented. Users can define
## their own methods as R functions (see the vignette).
## @param markerList For which of the markers do you want to call genotypes (default is all)?
## @param sampleList For which of the samples do you want to call genotypes (default is all)?
## @param mapAlleles FALSE/TRUE. Whether to map variants to db \option{alleleDb} of known alleles.
##
## @return list of call results including the call parameters and a table of calls (class \code{\link{genotypeCall}}). If an mlgtResult object was supplied then a list of \code{\link{genotypeCall}} objects will be returned, each named by marker.
##
## @export
## @docType methods
## @aliases callGenotypes.mlgtResult
#setGeneric("callGenotypes", function(resultObject, table, alleleDb=NULL, method="custom", minTotalReads=50, maxPropUniqueVars=0.8,
# minPropToCall=0.1, minDiffToVarThree=0.4,
# minPropDiffHomHetThreshold=0.3, markerList=names(resultObject@markers),
# sampleList=resultObject@samples, mapAlleles=FALSE, ...)
# standardGeneric("callGenotypes")
# )
#setMethod("callGenotypes", signature(resultObject="missing", table="data.frame", alleleDb="ANY", method="ANY", minTotalReads="ANY", maxPropUniqueVars="ANY",
# minPropToCall="ANY", minDiffToVarThree="ANY",minPropDiffHomHetThreshold="ANY", markerList="ANY",
# sampleList="ANY", mapAlleles="ANY"),
# definition=callGenotypes.default )
#setMethod("callGenotypes", signature(resultObject="mlgtResult", table="missing", alleleDb="ANY", method="ANY", minTotalReads="ANY", maxPropUniqueVars="ANY",
# minPropToCall="ANY", minDiffToVarThree="ANY",minPropDiffHomHetThreshold="ANY", markerList="ANY",
# sampleList="ANY", mapAlleles="ANY"),
# definition=callGenotypes.mlgtResult )
#setMethod("callGenotypes", signature(resultObject="mlgtResult", table="missing"),
# definition=callGenotypes.mlgtResult )
# default for 'file' could be derived from project, run, marker attributes of genotypeCall.
writeGenotypeCallsToFile.genotypeCall <- function(genotypeCall, filePrefix="genoCalls", file=paste(filePrefix,genotypeCall@projectName,genotypeCall@runName,genotypeCall@marker,"tab",sep="."),
writeParams=FALSE, appendValue=FALSE) {
if(writeParams) {
cat("# Genotype calls generated by R package 'mlgt' (", packageVersion("mlgt"),")", date(),"\n",file=file, append=appendValue)
appendValue=TRUE
cat("# Project:", genotypeCall@projectName,"\n", file=file, append=appendValue)
cat("# Run", genotypeCall@runName,"\n", file=file, append=appendValue)
cat("# Marker", genotypeCall@marker,"\n", file=file, append=appendValue)
cat("# Call method:", genotypeCall@callMethod,"\n", file=file, append=appendValue)
cat("# Call parameters:-\n", file=file, append=appendValue)
for(i in 1:length(genotypeCall@callParameters)) {
thisParam <- unlist(genotypeCall@callParameters[i])
cat("#\t",names(thisParam),"=", thisParam,"\n", file=file, append=appendValue)
}
cat("# MappedToAlleles: ", genotypeCall@mappedToAlleles,"\n", file=file, append=appendValue)
cat("# AlleleDb: ", genotypeCall@alleleDbName,"\n", file=file, append=appendValue)
}
write.table(genotypeCall@genotypeTable, file=file, append=appendValue, row.names=F, quote=F, sep="\t")
cat("Results written to",file,"\n")
#return(invisible(1))
}
# Need function to write genotype calls as a single file.
writeGenotypeCallsToFile.list <- function(callList, filePrefix="genoCalls", file, singleFile=FALSE,writeParams=FALSE) {
if(singleFile) {
masterTable <- data.frame()
for(i in 1:length(callList)) {
masterTable <- rbind(masterTable , callList[[i]]@genotypeTable)
}
write.table(masterTable , file=file, row.names=F, quote=F, sep="\t")
cat("Results written to",file,"\n")
} else {
#invisible(lapply(callList, FUN=function(x) writeGenotypeCallsToFile.genotypeCall(x,writeParams=writeParams)))
cat(length(lapply(callList, FUN=function(x) writeGenotypeCallsToFile.genotypeCall(x,writeParams=writeParams, filePrefix=filePrefix))), "files written\n")
}
}
# DONE: allow write to single file when some markers mapped to alleles and some not. Consistent return of empty/NA/NaN columns?
# DONE: allow prefix to denote instance of filename - otherwise different genotype call sets will overwrite each other.
# generic method. Need to give defaults if defaults to be set in specific forms.
#' Write genotype calls to file
#'
#' A genotype call table or a list of tables can be written to tab-delimited file(s).
#'
#' This function is quite flexible and can output a single table of concatenated results or a series of individual files.
#' Call parameters can be included above each table but be careful doing this when \code{singleFile=TRUE}
#'
#' @param callList A \code{list} of genotypes calls.
#' @param genotypeCall Alternatively, supply a single table of genotype calls
#' @param filePrefix A prefix to add to the start of each file name. Useful to distinguish sets of genotype call results from same run.
#' @param file The file to write to. If none specified, function will attempt to make one. Ignored if \option{singleFile = TRUE}.
#' @param singleFile FALSE/TRUE whether to concatenate results from a list of genotypeCalls
#' @param writeParams List call parameter values at top of file? Beware using this option when \option{singleFile = TRUE}
#' @param appendValue Used internally to concatenate results.
#'
#' @return Writes tables in the current working directory.
#'
#' @rdname writeGenotypeCallsToFile-methods
#' @export
#' @aliases writeGenotypeCallsToFile.list,writeGenotypeCallsToFile.genotypeCall
#' @examples \dontrun{
#' data("mlgtResult", package="mlgt")
#' my.genoytpes <- callGenotypes(my.mlgt.Result)
#' writeGenotypeCallsToFile(my.genotypes)
#' }
setGeneric("writeGenotypeCallsToFile", function(callList, genotypeCall, filePrefix="genoCalls", file="", singleFile=FALSE, writeParams=FALSE, appendValue=FALSE) standardGeneric("writeGenotypeCallsToFile"))
#' @rdname writeGenotypeCallsToFile-methods
#' @aliases writeGenotypeCallsToFile,list,missing-method
setMethod("writeGenotypeCallsToFile", signature(callList="list", genotypeCall="missing", filePrefix="ANY", file="ANY", singleFile="ANY",
writeParams="ANY", appendValue="ANY"),
definition=writeGenotypeCallsToFile.list)
#' @rdname writeGenotypeCallsToFile-methods
#' @aliases writeGenotypeCallsToFile,missing,genotypeCall-method
setMethod("writeGenotypeCallsToFile", signature(callList="missing", genotypeCall="genotypeCall", filePrefix="ANY", file="ANY", singleFile="ANY",
writeParams="ANY", appendValue="ANY"),
definition=writeGenotypeCallsToFile.genotypeCall )
#writeGenotypeCallsToFile <- function(callList, genotypeCall, file="", singleFile=FALSE, writeParams=FALSE, appendValue=FALSE) attributes(callList)
########################## plotting
#' Plot BLAST statisitics for one marker
#'
#' \code{\link{prepareMlgtRun}} produces several BLAST tables. It is instructive to plot the BLAST results and assess the performance
#' of different markers.
#'
#' This function is used to plot a series of histograms based on BLAST statistics.
#'
#' @param blastTable The file of BLAST results.
#' @param subject The name of a single marker
#'
#' @return Plots three histograms based on the BLAST statistics 'Alignment length', 'Bit Score' and 'Percent Identity'
#' @export
#' @seealso \code{\link{printBlastResultGraphs}}
inspectBlastResults <- function(blastTable, subject) {
#topHits <- getTopBlastHits(resultFile)
#topHits$strand <- ifelse(topHits$s.end > topHits$s.start, 1,2)
hitCount <- length(which(blastTable$subject == subject))
if(hitCount > 0) {
#subject <- "DPA1_E2"
breakValue <- max(10, 10^(floor(log10(hitCount)))) # favour a large number of breaks. At least 10.
par(mfrow=c(1,3))
hist(blastTable$ali.length[blastTable$subject == subject], breaks=breakValue, xlab="Alignment Length", main=subject)
hist(blastTable$bit.score[blastTable$subject == subject], breaks=breakValue, xlab="Bit Score", main=subject)
hist(blastTable$percent.id[blastTable$subject == subject], breaks=breakValue, xlab="% identity", main=subject)
} else {
warning(paste("No data for ", subject))
}
}
#' Plot BLAST statistics for several markers to file
#'
#' Plot the BLAST statistics easily for all markers of an \code{\link{mlgtResult}} object.
#'
#'
#'
#' @param designObject An object of class \code{\link{mlgtDesign}} which will contain the name of the blast results file \code{designObject@@markerBlastResults}
#' @param markerList Which markers to output. Defaults to \code{designObject@@markers}
#' @param fileName Defaults to "blastResultGraphs.pdf"
#'
#' @return Plots BLAST results to a pdf file.
#' @export
#' @seealso \code{\link{inspectBlastResults}}
printBlastResultGraphs <- function(designObject, markerList=designObject@markers, fileName="blastResultGraphs.pdf") {
topHits <- getTopBlastHits(designObject@markerBlastResults)
pdf(fileName,height=4)
for(thisMarker in names(markerList)) {
inspectBlastResults(topHits, thisMarker )
}
dev.off()
}
########## Multiple methods for plotGenotypeEvidence
#
plotGenotypeEvidence.genotypeCall <- function(genotypeCall) {
genotypeTable <- genotypeCall@genotypeTable
thisMarker <- genotypeCall@marker
# next three lines are a temp fix to retrieve default call parameters, which are not retained by callGenotypes.default(). May remove this function anyway.
minTotalReads <- ifelse(exists("genotypeCall@callParameters[['minTotalReads']]"),genotypeCall@callParameters['minTotalReads'],50)
minDiffToVarThree <- ifelse(exists("genotypeCall@callParameters[['minDiffToVarThree']]"),genotypeCall@callParameters['minDiffToVarThree'],0.4)
minPropDiffHomHetThreshold <- ifelse(exists("genotypeCall@callParameters[['minPropDiffHomHetThreshold']]"),genotypeCall@callParameters['minPropDiffHomHetThreshold'],0.3)
if(sum(genotypeTable$numbSeqs) < 1) {
warning(paste("No seqs to plot for",thisMarker), call.=F)
} else {
statusList <- as.factor(genotypeTable$status)
pchList <- statusList
levels(pchList) <- (1:nlevels(pchList ))
#levels(pchList) <- 20+(1:nlevels(pchList ))
par(mfrow=c(2,3))
hist( genotypeTable$numbSeqs, breaks=20, main=thisMarker, xlab="numbSeqs"); abline(v=minTotalReads , lty=2)
hist( genotypeTable$diffToVarThree, breaks=20, main=thisMarker, xlab="diffToVarThree", xlim=c(0,1)); abline(v=minDiffToVarThree , lty=2)
hist(genotypeTable$propDiffHomHet, breaks=20, main=thisMarker, xlab="propDiffHomHet", xlim=c(0,1)) ; abline(v=minPropDiffHomHetThreshold , lty=2)
plot(genotypeTable$diffToVarThree,genotypeTable$propDiffHomHet, main=thisMarker, xlab="diffToVarThree", ylab="propDiffHomHet",xlim=c(0,1), ylim=c(0,1),pch=as.numeric(levels(pchList))[pchList]); abline(h=minPropDiffHomHetThreshold , lty=2); abline(v=minDiffToVarThree , lty=2)
legend("topleft", levels(as.factor(genotypeTable$status)), pch=as.numeric(levels(pchList)))
plot(genotypeTable$numbSeqs,genotypeTable$diffToVarThree, main=thisMarker, xlab="numbSeqs", ylab="diffToVarThree", ylim=c(0,1),pch=as.numeric(levels(pchList))[pchList]); abline(h=minDiffToVarThree , lty=2); abline(v=minTotalReads , lty=2)
plot(genotypeTable$numbSeqs,genotypeTable$propDiffHomHet, main=thisMarker, xlab="numbSeqs", ylab="propDiffHomHet", ylim=c(0,1),pch=as.numeric(levels(pchList))[pchList]); abline(h=minPropDiffHomHetThreshold , lty=2); abline(v=minTotalReads , lty=2)
}
}
plotGenotypeEvidence.genotypeCall.file <- function(genotypeCall, file) {
if(length(grep(".pdf$", file) ) < 1) {
file <- paste(file,"pdf", sep=".")
}
pdf(file)
plotGenotypeEvidence.genotypeCall(genotypeCall)
dev.off()
cat("Results output to", file, "\n")
}
# list must have a file specified for output
plotGenotypeEvidence.list <- function(callList, file) {
if(length(grep(".pdf$", file) ) < 1) {
file <- paste(file,"pdf", sep=".")
}
pdf(file)
for(thisCall in callList) {
#cat(thisCall@marker)
plotGenotypeEvidence.genotypeCall(thisCall)
}
dev.off()
cat("Results output to", file, "\n")
}
#' Plot genotyping evidence
#'
#' Plot the distributions of values used in calling genotypes.
#'
#' Currently only makes sense with "custom" method. The resulting plots are
#' \enumerate{
#' \item {Histogram of the number of sequences assigned to each sample}
#' \item {Histogram of diffToVarThree parameter. Used to decide whether to make the call}
#' \item {Histogram of propDiffHomHet parameter. Used to distinguish HOMOZYGOTES and HETEROZYGOTES}
#' \item {propDiffHomHet against diffToVarThree }
#' \item {diffToVarThree against number of sequences}
#' \item {propDiffHomHet against number of sequences}
#' }
#'
#' @param callList A \code{list} of genotypes calls.
#' @param genotypeCall A single table of genotype calls
#' @param file The file to write to.
#'
#' @return Creates six plots for each marker with a genotypeCall table. See \code{details}.
#'
#' @export
#' @seealso \code{\link{callGenotypes}}
#' @aliases plotGenotypeEvidence.list
#' @aliases plotGenotypeEvidence.genotypeCall.file
#' @aliases plotGenotypeEvidence.genotypeCall
#' @aliases plotGenotypeEvidence,missing,list,character-method
#' @aliases plotGenotypeEvidence,genoytpeCall,missing,missing-method
#' @aliases plotGenotypeEvidence,genoytpeCall,missing,character-method
#' @rdname plotGenotypeEvidence-methods
#' @examples \dontrun{
#' data("mlgtResult", package="mlgt")
#' my.genoytpes <- callGenotypes(my.mlgt.Result)
#' plotGenotypeEvidence(genotypeCall=my.genotypes[["DPA1_E2"]])
#' }
setGeneric("plotGenotypeEvidence", function(genotypeCall, callList, file) standardGeneric("plotGenotypeEvidence"))
#' @rdname plotGenotypeEvidence-methods
#' @aliases plotGenotypeEvidence,missing,list,character-method
setMethod("plotGenotypeEvidence", signature(genotypeCall="missing", callList="list", file="character"), definition=plotGenotypeEvidence.list)
#' @rdname plotGenotypeEvidence-methods
#' @aliases plotGenotypeEvidence,genotypeCall,missing,character-method
setMethod("plotGenotypeEvidence", signature(genotypeCall="genotypeCall", callList="missing", file="character"), definition=plotGenotypeEvidence.genotypeCall.file)
#' @rdname plotGenotypeEvidence-methods
#' @aliases plotGenotypeEvidence,genotypeCall,missing,missing-method
setMethod("plotGenotypeEvidence", signature(genotypeCall="genotypeCall", callList="missing", file="missing"), definition=plotGenotypeEvidence.genotypeCall)
#plotGenotypeEvidence <- function(callList, genotypeCall, file) attributes(genotypeCall)
#' Dump variants as fasta
#'
#' Output unique variants to one or more fasta files.
#'
#' This is a stop-gap function while I decide how best to handle output of full sequences.
#'
#' @param resultObject An object of class \code{\link{mlgtResult}} containing the sequence variants.
#' @param markers For which markers do you want to output sequences.
#' @param file An output file name. If not supplied, one is created.
#' @param singleFile Whether to output results for all markers to a single file or to one file per marker.
#'
#' @return Writes fasta files in the current directory.
#' @export
dumpVariantMap.mlgtResult <- function(resultObject, markers=names(resultObject@markers),
file=paste(resultObject@projectName,resultObject@runName,"seqDump",sep="."),
singleFile=TRUE) {
file <- sub("\\.fasta","",file)
writeOption <- ifelse(singleFile,"a","w") # used by write.fasta. "a" = append
baseFileName <- file
for(thisMarker in markers) {
useFile <- ifelse(singleFile,paste(baseFileName,"fasta",sep="."),paste(baseFileName,thisMarker,"fasta",sep="."))
theSeqs <- names(resultObject@alleleDb[[thisMarker]]@variantMap)
theNames <- as.character(resultObject@alleleDb[[thisMarker]]@variantMap)
write.fasta(lapply(theSeqs,s2c), theNames, file.out=useFile , open=writeOption )
}
}
#dumpVariantMap.variantMap
## TODO docs, internal
stripGapColumns <- function(alignment) {
gap_index <- which(con(alignment, method="threshold",threshold=(1-1e-07)) == '-') # bug in seqinr: threshold =1 returns NA for all.
if(length(gap_index) < 1) { # nothing to strip
if(exists("verbose")) cat("No gap columns to remove ")
return(alignment)
}
alignMatrix <- as.matrix(alignment)[,-c(gap_index)]
if(exists("verbose")) cat(paste("removed",length(gap_index),"gap columns "))
deGapSeqs <- apply(alignMatrix,1,c2s)
deGapAlign <- as.alignment(alignment$nb,alignment$nam,deGapSeqs)
return(deGapAlign)
}
## TODO docs, internal
## supply an UN-PACKKED alignment (including duplicated sequences)
errorCorrect.alignment <- function(alignment, correctThreshold=0.01) {
#alignment.corrected <- alignment
minDepth <- ceiling(1/correctThreshold) # no point attempting if less depth than this.
if(alignment$nb < minDepth) {
warning(paste("No correction possible with depth of", alignment$nb, "and correction threshold of", correctThreshold, "\n"))
return(alignment)
}
thisProfile <- consensus(alignment, method="profile")
thisConsensus <- con(alignment, method="threshold", threshold=correctThreshold )
totalSeqs <- alignment$nb
totalLetters <- nrow(thisProfile)
mafList <- apply(thisProfile, 2, FUN=function(x) (sort(x)[totalLetters-1] / totalSeqs))
correct_index <- intersect(which(mafList < correctThreshold), which(mafList > 0))
#remove NAs from index.
correct_index <- correct_index[!is.na(thisConsensus[correct_index])]
alignment.matrix <- as.matrix.alignment(alignment)
alignment.matrix[,c(correct_index)] <- t(apply(alignment.matrix,1,FUN=function(x) x[c(correct_index)] <- thisConsensus[correct_index]))
seqList.correct <- apply(alignment.matrix,1,c2s)
alignment.corrected <- as.alignment(nb=length(seqList.correct),nam=names(seqList.correct),seq=seqList.correct)
alignment.corrected <- stripGapColumns(alignment.corrected)
return(alignment.corrected)
}
## TODO docs, incorporate into mlgt() lots of duplicated code, README
##
## wrapper function to perform errorCorrect on an existing mlgtResult object
## this is basically mlgt() without any of the assignment and alignment and a call to errorCorrect()
## Examples:-
## my.corrected.mlgt.Result <- errorCorrect.mlgtResult(my.mlgt.Result)
## my.corrected.mlgt.Result <- errorCorrect.mlgtResult(my.mlgt.Result,correctThreshold=0.05)
## alignReport(my.mlgt.Result, fileName="alignReportOut.pdf", method="profile")
## alignReport(my.corrected.mlgt.Result, fileName="alignReportOut.corrected.pdf", method="profile")
## alignReport(my.mlgt.Result, fileName="alignReportOut.hist.pdf", method="hist")
## alignReport(my.corrected.mlgt.Result, fileName="alignReportOut.hist.corrected.pdf")
## my.genotypes <- callGenotypes(my.mlgt.Result)
## my.corrected.genotypes <- callGenotypes(my.corrected.mlgt.Result)
## my.genotypes[[thisMarker]]@genotypeTable
## my.corrected.genotypes[[thisMarker]]@genotypeTable
## error correction has little effect on the the sample dataset even with high threshold of 0.05. Most samples with > 100 seqs are called correctly anyway.
errorCorrect.mlgtResult <- function(mlgtResultObject, correctThreshold=0.01) {
markerSampleList <- list()
runSummaryTable <- data.frame()
alleleDb <- list()
varCountTableList <- list()
###ITERATIONS
for(thisMarker in names(mlgtResultObject@markers)) {
cat(paste(thisMarker,"\n"))
#thisMarker <- "DQA1_E2"
## might need to combine all these to return a single item.
summaryList <- list()
summaryTable <- data.frame()
markerSequenceCount <- list("noSeq"=0) # BUG? requires some data otherwise won't sum properly with localSequenceCount.
alleleList <- list()
variantList <- list()
alleleCount <- 1
markerSeq <- unlist(getSequence(mlgtResultObject@markers[[thisMarker]],as.string=T))
varCountTableList[[thisMarker]] <- data.frame()
thisTable <- mlgtResultObject@varCountTables[[thisMarker]]
for(thisSample in mlgtResultObject@samples) {
cat(paste(thisSample ," "))
## need to keep data from mlgtResultObject where no correction is made, but create new data where a correction is made.
#testPairSeqList <- intersect(pairedSampleMap[[thisSample]],union(fMarkerMap[[thisMarker]], rMarkerMap[[thisMarker]]))
seqTable <- data.frame()
localAlleleNames <- c("NA","NA","NA")
localAlleleFreqs <- c(0,0,0)
## go through all seq's mapped to this marker/sample pair.
## extract the corresponding sequence delimited by the top blast hits on the primers. IS THIS THE BEST WAY?
## Simple improvement: minimum blast hit length to primer to keep.
## internal Function
recordNoSeqs <- function(summaryTable) { # to record no seqs before skipping out.
summaryRow <- data.frame(marker=thisMarker, sample=thisSample, numbSeqs=0,numbVars=0,
varName.1="NA", varFreq.1= 0,
varName.2="NA", varFreq.2= 0,
varName.3="NA", varFreq.3= 0)
summaryTable <- rbind(summaryTable, summaryRow)
return(summaryTable)
}
if(is.na(match(thisSample,names(thisTable)))) {
summaryTable <- recordNoSeqs(summaryTable)
next;
}
valueIndex <- !is.na(thisTable[,thisSample])
seqCounts <- thisTable[valueIndex,thisSample]
## important to 'unpack' the alignment so that each sequence occurs the correct number of times.
sampleSeqs <- rep(row.names(thisTable)[valueIndex ], seqCounts)
thisAlign <- as.alignment(sum(seqCounts), sampleSeqs, sampleSeqs)
cat(paste(length(unique(thisAlign$seq)),"/", thisAlign$nb,"unique seqs in original alignment, "))
newAlign <- errorCorrect.alignment(thisAlign, correctThreshold)
cat(paste(length(unique(newAlign$seq)),"/", newAlign$nb,"unique seqs in new alignment, "))
## DONE: repack the corrected alignment re-attribute the allele names. Update the markerSampleTable
varCountTable <- as.data.frame(table(unlist(newAlign$seq)),stringsAsFactors=FALSE)
seqTable <- data.frame(alignedVar=varCountTable$Var1, count=as.numeric(varCountTable$Freq),stringsAsFactors=FALSE)
seqTable$var <- gsub("-","",seqTable$alignedVar)
seqTable <- seqTable[order(seqTable$count,decreasing=T),]
#dim(seqTable)
# if no sequences returned, nothing to process.
if(nrow(seqTable) < 1 ) {
summaryTable <- recordNoSeqs(summaryTable)
cat(" no variants\n")
#summaryList[[thisMarker]][[thisSample]] <- NA
next ; # go to next sample.
}
# store sequence and count of sequence as alignedVar (needed for alignment report)
varCountTableList[[thisMarker]][seqTable$alignedVar,thisSample] <- seqTable$count
## test if variants are novel.
## Give allele names?
## Do with first three for now.
alToRecord <- min(3,nrow(seqTable))
if(alToRecord > 0) {
for (a in 1:alToRecord ) {
if(is.null(variantList[[seqTable$var[a]]])) { # novel
alleleName <- paste(thisMarker, alleleCount,sep=".")
variantList[[seqTable$var[a]]] <- alleleName
localAlleleNames[a] <- alleleName
localAlleleFreqs[a] <- seqTable$count[a]
alleleCount <- alleleCount + 1
} else { # pre-existing alllele
localAlleleNames[a] <- variantList[[seqTable$var[a]]]
localAlleleFreqs[a] <- seqTable$count[a]
}
}
}
# compile stats
if(nrow(seqTable) >0 ) { # cannot allow assignment from empty list as messes up class of list for remaining iterations
summaryList[[thisMarker]] <- list()
summaryList[[thisMarker]][[thisSample]] <- seqTable
}
summaryRow <- data.frame(marker=thisMarker, sample=thisSample, numbSeqs=sum(seqTable$count),numbVars=nrow(seqTable),
varName.1=localAlleleNames[1], varFreq.1= localAlleleFreqs[1],
varName.2=localAlleleNames[2], varFreq.2= localAlleleFreqs[2],
varName.3=localAlleleNames[3], varFreq.3= localAlleleFreqs[3])
summaryTable <- rbind(summaryTable, summaryRow)
#sequence count across samples?
# need to sum from summaryTable or from summaryList.
#markerSequenceCount <-
#as.list(colSums(merge(m, n, all = TRUE), na.rm = TRUE)) # not working
localSequenceCount <- as.list(seqTable$count)
names(localSequenceCount) <- seqTable$var
markerSequenceCount <- as.list(colSums(merge(markerSequenceCount , localSequenceCount, all = TRUE), na.rm = TRUE))
# might need to instantiate the markerSequenceCount if empty.
cat("\n")
} # end of sample loop
markerSampleList[[thisMarker]] <- summaryTable
## DONE: min(nchar(names(variantList))) throws warning when no variants in list. (Inf/-Inf)
minVarLength <- ifelse(length(markerSequenceCount) < 1, NA, min(nchar(names(markerSequenceCount))) )
maxVarLength <- ifelse(length(markerSequenceCount) < 1, NA, max(nchar(names(markerSequenceCount))) )
minAleLength <- ifelse(length(variantList) < 1, NA, min(nchar(names(variantList))) )
maxAleLength <- ifelse(length(variantList) < 1, NA, max(nchar(names(variantList))) )
runSummaryRow <- data.frame(marker=thisMarker, assignedSeqs=sum(summaryTable$numbSeqs), assignedVariants=sum(summaryTable$numbVars),
minVariantLength=minVarLength,
maxVariantLength=maxVarLength,
minAlleleLength=minAleLength, maxAlleleLength=maxAleLength )
runSummaryTable <- rbind(runSummaryTable, runSummaryRow)
if(length(variantList) > 0) {
# This line replaced. Not entirely tested the repurcussions. e.g. makeVarAlleleMap()?
#alleleDb[[thisMarker]] <- variantList # LATER: separate lists for alleles and variants?
#alleleDb[[thisMarker]] <- list(reference=as.SeqFastadna(markerSeq, thisMarker), alleleMap=variantList, inputAlleleCount = length(unlist(variantList)), uniqueSubAlleleCount=length(variantList))
alleleDb[[thisMarker]] <- new("variantMap", reference=as.SeqFastadna(markerSeq, thisMarker),
variantSource=paste(mlgtResultObject@projectName, mlgtResultObject@runName,sep="."),
variantMap=variantList, inputVariantCount = length(unlist(variantList)), uniqueSubVariantCount=length(variantList))
}
} # end of marker loop
localMlgtResult <- new("mlgtResult", mlgtResultObject, runSummaryTable=runSummaryTable , alleleDb=alleleDb, markerSampleList=markerSampleList,
varCountTables=varCountTableList)
return(localMlgtResult)
}
#' Alignment error correction
#'
#' Correct very low frequency site variants.
#'
#' You may want to alter some of the sequences if you believe that sequences at very low frequency
#' (within the set of sequences from a marker/sample pair) represent sequencing errors.
#' \code{errorCorrect()} is implemented as an additional step after running \code{\link{mlgt}}, however, it is recommended to include error correction within \code{\link{mlgt}} using the errorCorrect=TRUE option.
#' Using \code{\link{alignReport}} beforehand may help you decide whether to do this.
#'
#' @param mlgtResultObject An object of class \code{\link{mlgtResult}}
#' @param correctThreshold The maximimum Minor Allele Frequency (MAF) at which variants will be corrected.
#'
#' @return A new \code{\link{mlgtResult}} object with errors 'corrected'
#' @rdname errorCorrect-methods
#' @export
#' @seealso \code{\link{alignReport}}
#'
setGeneric("errorCorrect", function(mlgtResultObject, alignment, correctThreshold=0.01) standardGeneric("errorCorrect"))
#' @rdname errorCorrect-methods
#' @aliases errorCorrect,missing,list-method
setMethod("errorCorrect", signature(mlgtResultObject="missing",alignment="list", correctThreshold="ANY"),
definition=errorCorrect.alignment)
#' @rdname errorCorrect-methods
#' @aliases errorCorrect,mlgtResult,missing-method
setMethod("errorCorrect", signature(mlgtResultObject="mlgtResult", alignment="missing", correctThreshold="ANY"),
definition=errorCorrect.mlgtResult)
# TODO: rewrite alignReport() so that it does not rely upon varCountTables.
# Use re-alignment through muscle. Seems very slow.
# ALT: store alignments within mlgtResult - gonna be huge, for limited return.
# ALT.2: store a varCountTable and an AlignedVarTable (the second would be larger but could be used to reconstruct any alignment for any sample/marker.
## Generate stats per site along the alignments. WITHIN a marker/sample pair.
## DONE: Docs needed, add e.g. to README
## This function is a bit weird in that it collects a table of info and, optionally, generates some graphs.
## What if people want to export the tables of results to file AND the images?
## EXAMPLES:-
## alignReport(my.mlgt.Result,markers=thisMarker, samples=thisSample, method="profile")
## alignReport(my.mlgt.Result,markers=thisMarker, samples=thisSample, method="hist", fileName="testOutHist")
## alignReport(my.mlgt.Result, method="profile", fileName="testOutMultiProfile")
## alignReport(my.mlgt.Result,markers="DPA1_E2", samples="MID-17", method="profile")
## alignReport(my.mlgt.Result,markers="DPA1_E2", samples="MID-1", method="hist")
## alignReport(my.mlgt.Result,markers="DPA1_E2", samples="MID-22", method="hist") # good example where change would be useful
## alignReport(my.mlgt.Result,markers="DPA1_E2", samples="MID-1", method="profile", correctThreshold=0.02)
## my.alignReport <- alignReport(my.mlgt.Result)
#' Report on alignment
#'
#' Inspect site frequency spectra for alignments.
#'
#' Produce different kinds of reports to assess quality of data for each marker/sample pair.
#' Can be a good way to assess whether \code{\link{errorCorrect}} should be applied.
#'
#'
#' @param mlgtResultObject an object of class \code{\link{mlgtResult}}
#' @param markers Which markers to output
#' @param samples Which samples to output
#' @param correctThreshold A hypothetical level at which you migth correct low frequence variants. Default = 0.01.
#' @param consThreshold (1- correctThreshold)
#' @param profPlotWidth How many residues to plot in \code{profile} mode. Default=60.
#' @param fileName Give a filename to export result to (pdf).
#' @param method One of c("table", "profile", "hist"). "hist" plot a histogram of MAF frequencies. "profile" plots a coloured barplot represnting the allele frequencies at each site.
#' @param warn Issue warnings (default = TRUE)
#'
#' @return A data frame for each marker listing site statistics.
#' @seealso \code{\link{errorCorrect}}
#' @export
#' @examples \dontrun{
#' data("mlgtResult", package="mlgt")
#' alignReport(my.mlgt.Result,markers="DPA1_E2", samples="MID-22", method="profile")
#' alignReport(my.mlgt.Result,markers="DPA1_E2", samples="MID-22", method="hist")
#' }
alignReport <- function(mlgtResultObject, markers=names(mlgtResultObject@markers), samples=mlgtResultObject@samples,
correctThreshold = 0.01, consThreshold = (1 - correctThreshold), profPlotWidth = 60, fileName=NULL, method="table", warn=TRUE) {
# need method for both plots (save processing time) but how to do without generating profiles twice.
# need to tidy and label profile plots.
reportList <- list()
if(!is.null(fileName)) {
if(length(grep(".pdf$", fileName)) < 1 & !is.null(fileName)) {
fileName <- paste(fileName,"pdf", sep=".")
}
pdf(fileName)
}
colTable <- data.frame(profChar = c("-","a","c","g","t"),
profCol = c("grey","green", "blue", "yellow", "red"))
for(thisMarker in markers) {
thisTable <- mlgtResultObject@varCountTables[[thisMarker]]
cat(paste(thisMarker,"\n"))
if(nrow(thisTable) < 1) { # drops this marker if no data. Might be better to return and empty table?
if(warn) {
warning(paste("No data for", thisMarker))
}
#reportTable[thisSample,c("numbSeqs","numbVars")] <- 0
#reportTable[thisSample,c("alignLength","invar.sites","mafBelowThreshold","mafAboveThreshold")] <- NA
next;
}
reportTable <- data.frame()
for(thisSample in samples) {
if(is.na(match(thisSample,names(thisTable)))) {
if(warn) {
warning(paste("No variants for", thisSample, "and", thisMarker))
}
#reportTable[thisSample,c("invar.sites","mafBelowThreshold","mafAboveThreshold")] <- NA
reportTable[thisSample,"numbSeqs"] <- 0
reportTable[thisSample,"numbVars"] <- 0
reportTable[thisSample,"alignLength"] <- NA
reportTable[thisSample,"invar.sites"] <- NA
reportTable[thisSample,"mafAboveThreshold"] <- NA
reportTable[thisSample,"mafBelowThreshold"] <- NA
next;
}
#cat(paste(thisSample ," "))
valueIndex <- !is.na(thisTable[,thisSample])
seqCounts <- thisTable[valueIndex,thisSample]
sampleSeqs <- rep(row.names(thisTable)[valueIndex ], seqCounts)
thisAlign <- as.alignment(sum(seqCounts), sampleSeqs, sampleSeqs)
if(thisAlign$nb < 2) { # too few sequences to plot.
#reportTable[thisSample,c("invar.sites","mafBelowThreshold","mafAboveThreshold")] <- NA
reportTable[thisSample,"numbSeqs"] <- 1
reportTable[thisSample,"numbVars"] <- 1
reportTable[thisSample,"alignLength"] <- nchar(thisAlign$seq[1])
reportTable[thisSample,"invar.sites"] <- NA
reportTable[thisSample,"mafAboveThreshold"] <- NA
reportTable[thisSample,"mafBelowThreshold"] <- NA
next;
}
thisProfile <- consensus(thisAlign , method="profile")
thisConsensus <- con(thisAlign, method="threshold", threshold=consThreshold)
totalSeqs <- sum(seqCounts)
totalLetters <- nrow(thisProfile)
mafList <- apply(thisProfile, 2, FUN=function(x) (sort(x)[totalLetters-1] / totalSeqs))
reportTable[thisSample, "numbSeqs"] <- totalSeqs
reportTable[thisSample, "numbVars"] <- length(seqCounts)
reportTable[thisSample, "alignLength"] <- ncol(thisProfile)
reportTable[thisSample, "invar.sites"] <- sum(mafList == 0)
## variable sites with minor allele > correction threshold.
reportTable[thisSample, "mafAboveThreshold"] <- sum(mafList >= correctThreshold )
## varaible sites with minor alleles < correction threshold.
reportTable[thisSample, "mafBelowThreshold"] <- reportTable[thisSample, "alignLength"] - (reportTable[thisSample, "invar.sites"] + reportTable[thisSample, "mafAboveThreshold"])
if(method=="profile") {
profColours <- as.character(colTable$profCol[match(row.names(thisProfile),colTable$profChar)])
## splits the plotting across so many lines. Buffers final plot to constant length.
profLen <- ncol(thisProfile)
n_plot <- ceiling(profLen / profPlotWidth )
plotProfile <- thisProfile
plotConsensus <- toupper(thisConsensus)
remainder <- profLen %% profPlotWidth
if(remainder > 0) {
extLen <- profLen + (profPlotWidth - remainder)
profExtension <- matrix(0,nrow=nrow(thisProfile), ncol=(profPlotWidth - remainder),
dimnames=list(row.names(thisProfile),c((profLen+1): extLen)))
plotProfile <- cbind(thisProfile,profExtension)
plotConsensus <- c(toupper(thisConsensus), rep("",remainder))
}
old.o <- par(mfrow=c((n_plot+1),1), mar=c(2,4,2,2))
plot.new()
title(paste(thisMarker, thisSample, sep=" : "), line=0)
title("", line=0,adj=0, sub=paste(c("Total sites","Invariant sites","MAF above threshold","MAF below threshold"),reportTable[thisSample,3:6],sep=": ",collapse="\n") )
legend("right", legend=toupper(colTable$profChar),fill=as.character(colTable$profCol), horiz=T)
for(i in 1:n_plot) {
start <- ((i-1)*profPlotWidth) + 1
#index <- start:(min(start+profPlotWidth, profLen))
index <- start:((start+profPlotWidth)-1)
barplot(plotProfile[,index ], col=profColours , names.arg=toupper(plotConsensus[index]) )
}
par(old.o)
}
if(method=="hist") {
#if(!is.null(fileName)) pdf(fileName)
if(sum(mafList > 0) > 0) {
hist(mafList[mafList > 0], breaks=200, xlim=c(0,0.5), xlab="Site-specific minor allele frequency", sub="non-zero values only",main=paste(thisMarker, thisSample, sep=":"))
abline(v=correctThreshold, lty=2)
}
}
}
reportList[[thisMarker]] <- reportTable
}
if(!is.null(fileName)) {
dev.off()
cat(paste("Alignment figures(s) plotted to", fileName,"\n"))
}
#print(reportList)
return(reportList)
}
## TODO: as per alleleReport() above, need to use proper varCountTable with ungapped sequences.
## DONE docs, README entry
## Examples
## dumpVariants(my.mlgt.Result,fileSuffix="variantDump.fasta")
## dumpVariants(my.corrected.mlgt.Result, markers="FLA_DRB", samples="cat348" )
## dumpVariants(my.corrected.mlgt.Result,fileSuffix="corrected.0.05.variantDump.fasta")
## dumpVariants(my.corrected.mlgt.Result,fileSuffix="corrected.0.05.variantDump.unique.fasta", uniqueOnly=T)
#' Print sequence to file
#'
#' A function to output all sequences or just unique sequences to a fasta file
#'
#' The sequence variants stored within an object of class \code{\link{mlgtResult}}
#' are not very easy to extract. This function will output all variants or all
#' variant for specific markers and samples into fasta files. Users can select to only
#' output unique sequences or the full alignment including duplicated sequences.
#' One file will be created for each marker/sample pair.
#'
#' @param mlgtResultObject an object of class \code{\link{mlgtResult}}
#' @param markers Which markers to output
#' @param samples Which samples to output
#' @param fileSuffix Add a common suffix to the file names. Usefull for keeping track of different sets of sequences.
#' @param uniqueOnly Only output single copy of each sequence. A count for each sequence are appended to the names.
#'
#' @export
#'
dumpVariants <- function(mlgtResultObject, markers=names(mlgtResultObject@markers),
samples=mlgtResultObject@samples, fileSuffix="variantDump.fasta", uniqueOnly=FALSE) {
for(thisMarker in markers) {
thisTable <- mlgtResultObject@varCountTables[[thisMarker]]
for(thisSample in samples) {
if(is.na(match(thisSample,names(thisTable)))) {
warning(paste("Nothing to output for", thisMarker, thisSample))
next;
}
fileName <- paste(thisMarker,thisSample,fileSuffix, sep=".")
valueIndex <- !is.na(thisTable[,thisSample])
seqCounts <- thisTable[valueIndex,thisSample]
if(uniqueOnly) { # export one copy of each sequence, append count to name line
sampleSeqs <- row.names(thisTable)[valueIndex]
seqNames <- paste(sampleSeqs,seqCounts)
thisAlign <- as.alignment(length(seqCounts), seqNames, sampleSeqs)
} else { # export copies of seqs as per counts.
## important to 'unpack' the alignment so that each sequence occurs the correct number of times.
sampleSeqs <- rep(row.names(thisTable)[valueIndex ], seqCounts)
thisAlign <- as.alignment(sum(seqCounts), sampleSeqs, sampleSeqs)
}
write.fasta(sequences=lapply(thisAlign$seq,s2c), names=thisAlign$nam, file.out=fileName)
cat(paste("Variants written to", fileName,"\n"))
}
}
}
# TODO: as alignReport() above, use true ungapped varCountTable
## used by combineMlgtResults()
mergeMlgtResults.complex <- function(result1, result2) {
master <- result1
# need to check if samples shared between results.
# If not, then perform complex join. Combining results where approriate.
# If they are, then test if marker/sample pairs shared. If yes, then stop(), otherwise perform complex join.
master@markers <- c(master@markers,result2@markers)
master@markers <- master@markers[!duplicated(master@markers)]
newRunSummaryTable <- data.frame()
for(thisMarker in names(master@markers)) {
markerSampleOverlap <- intersect(master@markerSampleList[[thisMarker]]$sample,result2@markerSampleList[[thisMarker]]$sample)
if(length(markerSampleOverlap) > 0) {
# STOP!
stop(paste("Cannot join results sharing marker results for same samples\n",thisMarker,markerSampleOverlap,"\n"))
}
# need to combine alleleDBs and variantMaps first so that new consistent allele names can propagate to the markerSampleList
#master@alleleDb <- as.list(merge(master@alleleDb, result2@alleleDb))
#master@alleleDb <- mergeAlleleDbs(master@alleleDb)
masterAlleleTable <- data.frame(seq=names(unlist(master@alleleDb[[thisMarker]]@variantMap)),
masterName=as.character(unlist(master@alleleDb[[thisMarker]]@variantMap)), stringsAsFactors=F )
alleleTable2 <- data.frame(seq=names(unlist(result2@alleleDb[[thisMarker]]@variantMap)),
alleleName=as.character(unlist(result2@alleleDb[[thisMarker]]@variantMap)), stringsAsFactors=F )
masterMatchTable <- merge(masterAlleleTable, alleleTable2, by="seq", all=T)
# some alleles will be new and these need to be added to master table and given new allele names
maxAllele <- max(na.omit(as.numeric(sub(paste(thisMarker,".",sep=""),"",masterMatchTable$masterName))))
newAlleleCount <-sum(is.na(masterMatchTable$masterName))
masterMatchTable$masterName[is.na(masterMatchTable$masterName)] <- paste(thisMarker, (1:newAlleleCount + maxAllele), sep=".")
#create new variantMap from masterMatchTable
newVarMap <- as.list(masterMatchTable$masterName)
names(newVarMap) <- masterMatchTable$seq
master@alleleDb[[thisMarker]]@variantMap <- newVarMap
# update allele Names in result2 table
nameCols <- grep("varName", names(result2@markerSampleList[[thisMarker]]))
for(n in nameCols) {
result2@markerSampleList[[thisMarker]][,n] <- masterMatchTable$masterName[match(result2@markerSampleList[[thisMarker]][,n] , masterMatchTable$alleleName)]
}
master@markerSampleList[[thisMarker]] <- rbind(master@markerSampleList[[thisMarker]],result2@markerSampleList[[thisMarker]])
# Combine result across varCountTables.
#master@varCountTables <- as.list(merge(master@varCountTables, result2@varCountTables))
# varCountTables[[thisMarker]][seqTable$alignedVar,thisSample] <- seqTable$count
frame2 <- result2@varCountTables[[thisMarker]]
for(thisCol in names(frame2)) {
index <- which(!is.na(frame2[,thisCol] ))
counts <- frame2[index,thisCol]
names <- row.names(frame2)[index]
master@varCountTables[[thisMarker]][names,thisCol] <- counts
}
index1 <- match(thisMarker, master@runSummaryTable$marker)
index2 <- match(thisMarker, result2@runSummaryTable$marker)
runSummaryRow <- data.frame(marker=thisMarker, assignedSeqs=sum(master@markerSampleList[[thisMarker]]$numbSeqs), assignedVariants=sum(master@markerSampleList[[thisMarker]]$numbVars),
minVariantLength=min(master@runSummaryTable$minVariantLength[index1], result2@runSummaryTable$minVariantLength[index2] ),
maxVariantLength=max(master@runSummaryTable$maxVariantLength[index1], result2@runSummaryTable$maxVariantLength[index2] ),
minAlleleLength=min(master@runSummaryTable$minAlleleLength[index1], result2@runSummaryTable$minAlleleLength[index2] ),
maxAlleleLength=max(master@runSummaryTable$maxAlleleLength[index1], result2@runSummaryTable$maxAlleleLength[index2] ) )
newRunSummaryTable <- rbind(newRunSummaryTable,runSummaryRow )
}
master@samples <- union(master@samples,result2@samples)
master@runSummaryTable <- newRunSummaryTable
# keep the following unless different between results.
if(!identical(master@fTags,result2@fTags)) { master@fTags <- list() } # @fTags. List of class SeqFastadna
if(!identical(master@rTags,result2@rTags)) { master@rTags<- list() } # @rTags. List of class SeqFastadna
if(!identical(master@inputFastaFile,result2@inputFastaFile)) { master@inputFastaFile <- '' } # @inputFastaFile
if(!identical(master@markerBlastResults,result2@markerBlastResults)) { master@markerBlastResults <- '' } # @markerBlastResults
if(!identical(master@fTagBlastResults,result2@fTagBlastResults)) { master@fTagBlastResults <- '' } # @fTagBlastResults
if(!identical(master@rTagBlastResults,result2@rTagBlastResults)) { master@rTagBlastResults <- '' } # @rTagBlastResults
if(!identical(master@runName,result2@runName)) { master@runName<- 'CombinedResults' } # @runName
# @projectName is taken as the first result. May need to change this.
return(master)
}
## used by combineMlgtResults()
mergeMlgtResults.simple <- function(result1, result2) {
master <- result1
master@markers <- c(master@markers,result2@markers)
master@markers <- master@markers[!duplicated(master@markers)]
master@markerSampleList <- c(master@markerSampleList, result2@markerSampleList)
master@markerSampleList <- master@markerSampleList[!duplicated(master@markerSampleList)]
master@alleleDb <- c(master@alleleDb, result2@alleleDb)
master@alleleDb <- master@alleleDb[!duplicated(master@alleleDb)]
master@varCountTables <- c(master@varCountTables, result2@varCountTables)
master@varCountTables <- master@varCountTables[!duplicated(master@varCountTables)]
master@samples <- union(master@samples,result2@samples)
master@runSummaryTable <- rbind(master@runSummaryTable, result2@runSummaryTable)
# keep the following unless different between results.
if(!identical(master@fTags,result2@fTags)) { master@fTags <- list() } # @fTags. List of class SeqFastadna
if(!identical(master@rTags,result2@rTags)) { master@rTags<- list() } # @rTags. List of class SeqFastadna
if(!identical(master@inputFastaFile,result2@inputFastaFile)) { master@inputFastaFile <- '' } # @inputFastaFile
if(!identical(master@markerBlastResults,result2@markerBlastResults)) { master@markerBlastResults <- '' } # @markerBlastResults
if(!identical(master@fTagBlastResults,result2@fTagBlastResults)) { master@fTagBlastResults <- '' } # @fTagBlastResults
if(!identical(master@rTagBlastResults,result2@rTagBlastResults)) { master@rTagBlastResults <- '' } # @rTagBlastResults
if(!identical(master@runName,result2@runName)) { master@runName<- 'CombinedResults' } # @runName
# @projectName is taken as the first result. May need to change this.
return(master)
}
## I imagine most of the time, combining results can be done after mlgt is run by simple concatenation of genotype tables.
## This might be the case if certain markers are rerun.
## However, there are instances where combination within mlgt is desirable. e.g. after a parallel run.
## Re-runs of certain marker samples could also be accomodated, but care would be have to be taken to update the correct results.
## 1. to combine and summarise results across runs.
## 2. to re-combine results after running parallel processing.
## Lots of the merging should be in common.
## Need checks that samples/markers are not duplicated (option to rename?)
## Needs to be fast enough for point 2 above to be worthwhile.
## Even if markers don't overlap, need to check that samples and mids are the same or different.
## Or do I? MIDs should be allowed to differ between runs.
#' Combine two or more mlgtResult objects
#'
#' Combine results from one or more runs, or combine partial results after a parallel job.
#'
#' In some cases, you may want to combine multiple \code{\link{mlgtResult}} objects
#' into a single object.
#' Can combine results using the same markers as long as the samples used have different names between results.
#' Can combine results using different sets (subsets) of markers.
#' Will fail if the same marker/sample combination appears in more than one \code{\link{mlgtResult}}.
#' Can be used to recombine the list of result obtained by running \code{\link{mlgt}} in parallel
#' on subsets of the full marker list.
#'
#'
#' @param resultList A list of objects of class \code{\link{mlgtResult}}
#' @param projectName Do you want to provide your own projectName
#' @param runName Do you want to provide your own runName
#'
#' @return An object of class \code{\link{mlgtResult}}
#' @export
#'
combineMlgtResults <- function(resultList,projectName=resultList[[1]]@projectName, runName="combinedMlgtResults") {
# set first result as master
master <- resultList[[1]]
for(i in 2:length(resultList)) {
# cycle through remaining results adding each to master
# check that sample/marker combinations do not overlap
#Any overlap in markers?
markerOverlap <- intersect(names(master@markers),names(resultList[[i]]@markers))
if(length(markerOverlap) > 0) { # overlapping markers, test for sample/marker overlap and maybe complex join.
# need to check if overlapping marker sequences are identical
cat("Complex join\n")
if(!identical(master@markers[markerOverlap],resultList[[i]]@markers[markerOverlap])) {
#STOP
stop("Cannot combine: markers with same name have different sequences.\n")
}
master <- mergeMlgtResults.complex(master, resultList[[i]])
} else { # no overlap in markers, 'simple' join
cat("Simple join\n")
master <- mergeMlgtResults.simple(master, resultList[[i]])
}
}
return(master)
}
#' @name my.mlgt.Result
#' @title An example \code{\link{mlgtResult}} object.
#' @description This is the result of running \code{\link{mlgt}} on the sample data given in the README.
#' @docType data
#' @usage my.mlgt.Result
#' @format a \code{\link{mlgtResult}} object.
#' @source Package mlgt
#' @author Dave T. Gerrard, 2012-04-01
NULL
|
gen2ped <-
function(nfunnels=1, nperfam=50, nssdgen=6, nseeds=1, iripgen=0)
{
if (nfunnels != 1)
stop("Only able to generate a single funnel")
obs <- vector()
# start with founders
ped <- rbind(c(1,0,0), c(2,0,0))
n1 <- nrow(ped)+1
ped <- rbind(ped, cbind(c((nrow(ped)+1):(nrow(ped)+nperfam)), rep(1, nperfam), rep(2, nperfam)))
n2 <- nrow(ped)
# at this point have done all the mixing, need to do AI and then selfing
if (iripgen>0)
{
for (i in 1:iripgen)
{
for (j in n1:n2)
{
ped <- rbind(ped, c(nrow(ped)+1, j, sample(setdiff(n1:n2, j), 1)))
}
n1 <- n2+1
n2 <- nrow(ped)
}
}
#now the selfing
obs <- rep(0, nrow(ped))
for (i in 1:nperfam)
{
#pick out relevant line at end of AI step
index <- i+n1-1
for (j in 1:nseeds)
{
obs <- c(obs, rep(0, nssdgen-1), 1)
ped <- rbind(ped, c(nrow(ped)+1, index, index))
if (nssdgen>1)
{
ped <- rbind(ped, cbind(c((nrow(ped)+1):(nrow(ped)+nssdgen-1)), c(nrow(ped):(nrow(ped)+nssdgen-2)), c(nrow(ped):(nrow(ped)+nssdgen-2))))
}
}
}
# fourth column is whether individual was genotyped
ped <- cbind(ped, obs)
ped <- as.data.frame(ped)
names(ped) <- c("id", "Male", "Female", "Observed")
return(ped)
}
| /R/gen2ped.R | no_license | lmw40/mpMap | R | false | false | 1,303 | r | gen2ped <-
function(nfunnels=1, nperfam=50, nssdgen=6, nseeds=1, iripgen=0)
{
if (nfunnels != 1)
stop("Only able to generate a single funnel")
obs <- vector()
# start with founders
ped <- rbind(c(1,0,0), c(2,0,0))
n1 <- nrow(ped)+1
ped <- rbind(ped, cbind(c((nrow(ped)+1):(nrow(ped)+nperfam)), rep(1, nperfam), rep(2, nperfam)))
n2 <- nrow(ped)
# at this point have done all the mixing, need to do AI and then selfing
if (iripgen>0)
{
for (i in 1:iripgen)
{
for (j in n1:n2)
{
ped <- rbind(ped, c(nrow(ped)+1, j, sample(setdiff(n1:n2, j), 1)))
}
n1 <- n2+1
n2 <- nrow(ped)
}
}
#now the selfing
obs <- rep(0, nrow(ped))
for (i in 1:nperfam)
{
#pick out relevant line at end of AI step
index <- i+n1-1
for (j in 1:nseeds)
{
obs <- c(obs, rep(0, nssdgen-1), 1)
ped <- rbind(ped, c(nrow(ped)+1, index, index))
if (nssdgen>1)
{
ped <- rbind(ped, cbind(c((nrow(ped)+1):(nrow(ped)+nssdgen-1)), c(nrow(ped):(nrow(ped)+nssdgen-2)), c(nrow(ped):(nrow(ped)+nssdgen-2))))
}
}
}
# fourth column is whether individual was genotyped
ped <- cbind(ped, obs)
ped <- as.data.frame(ped)
names(ped) <- c("id", "Male", "Female", "Observed")
return(ped)
}
|
# Program: UI file of Shiny project to pull stock tickers from Yahoo Finance
# Author: Dan Stair
# Date: November 2015
library(shiny)
library(dygraphs)
shinyUI(pageWithSidebar(
headerPanel("A Simple Comparison of Tech Stocks"),
sidebarPanel(
h3("Select stocks to compare!"),
br(),
textInput(inputId="stock1", label = "Pick a first stock:", value = "AMZN"),
textInput(inputId="stock2", label = "Pick a second stock:", value = "MSFT"),
dateRangeInput("dateRange", "Please input a date range between 1/2/2008 and 11/20/2015.",
start = "2015-01-02",
end = "2015-11-20",
min = "2008-01-02",
max = "2015-11-20"),
br(),
strong("The fine print / detailed instructions:"),
br(),
p("1) Any ticker in Yahoo Finance should work, but this app was tested
using MSFT, AMZN, AAPL, and GSPC (S&P 500)"),
p("2) The date range you input will immediately download the appropriate data from Yahoo Finance."),
br(),
strong("How to interpret the output:"),
p("1) You should see two charts, one with stock prices and the other with weekly rates of return"),
p("2) Note the colors of each stock are matched, so if MSFT is in blue in the top chart
it will be in blue on the bottom chart as well"),
p("3) You can zoom in on either chart interactively using the slider below the chart,
or by clicking on either chart and dragging and dragging horizontally to select
a time frame. Either action is instantaneous as it does not download any additional data"),
p("4) Have fun!")
),
mainPanel(
dygraphOutput("dygraph_price"),
br(),
br(),
dygraphOutput("dygraph_corr")
)
)) | /ui.R | no_license | dstair/Rshiny | R | false | false | 1,799 | r | # Program: UI file of Shiny project to pull stock tickers from Yahoo Finance
# Author: Dan Stair
# Date: November 2015
library(shiny)
library(dygraphs)
shinyUI(pageWithSidebar(
headerPanel("A Simple Comparison of Tech Stocks"),
sidebarPanel(
h3("Select stocks to compare!"),
br(),
textInput(inputId="stock1", label = "Pick a first stock:", value = "AMZN"),
textInput(inputId="stock2", label = "Pick a second stock:", value = "MSFT"),
dateRangeInput("dateRange", "Please input a date range between 1/2/2008 and 11/20/2015.",
start = "2015-01-02",
end = "2015-11-20",
min = "2008-01-02",
max = "2015-11-20"),
br(),
strong("The fine print / detailed instructions:"),
br(),
p("1) Any ticker in Yahoo Finance should work, but this app was tested
using MSFT, AMZN, AAPL, and GSPC (S&P 500)"),
p("2) The date range you input will immediately download the appropriate data from Yahoo Finance."),
br(),
strong("How to interpret the output:"),
p("1) You should see two charts, one with stock prices and the other with weekly rates of return"),
p("2) Note the colors of each stock are matched, so if MSFT is in blue in the top chart
it will be in blue on the bottom chart as well"),
p("3) You can zoom in on either chart interactively using the slider below the chart,
or by clicking on either chart and dragging and dragging horizontally to select
a time frame. Either action is instantaneous as it does not download any additional data"),
p("4) Have fun!")
),
mainPanel(
dygraphOutput("dygraph_price"),
br(),
br(),
dygraphOutput("dygraph_corr")
)
)) |
#
# This is the server logic of a Shiny web application. You can run the
# application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
library(data.table)
library(ggplot2)
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
varIndex <- reactive({
return(switch(input$variable,
"eruptions" = 1,
"waiting" = 2,
"density" = 3))
})
varName <- reactive({
return(switch(input$variable,
"eruptions" = "Eruptions",
"waiting" = "Waiting Time (in minutes)",
"density" = "Density"))
})
slider <- reactive({
graphType <- input$graphType
if(graphType == "Histogram") {
sliderInput("bins",
"Number of intervals to group data:",
min = 1,
max = 50,
value = 20)
} else {
return(NULL)
}
})
output$overview1 <- renderText({
"Package ggplot2 contians faithfuld dataset which contains data on
eruptions from Old Faithful Geyser along with density estimates. This dataset
records three variables, viz. Eruptions, Density and Waiting time between
eruptions, measured in minutes.
"
})
output$overview2 <- renderText({
"Here we plot Histograms or Line Graphs or Box-and-whisker Plots of one of
these three variables. Using various controls in the navigation pane on the
left side, please select one of these three variables to explore, the type
of graph to be displayed and color of the graph. For histogram, there is an
additional way of selecting the number of intervals to be used for the graph.
By default, 20 intervals will be used to group the data for displaying histogram.
"
})
output$histSlider <- renderUI({
slider()
})
output$summary <- renderTable({
mydf <- as.data.frame(faithfuld)
x <- mydf[, varIndex()]
summat <- as.matrix(summary(x))
rownames(summat) <- c("Minimum", "1st quartile", "Median",
"Mean", "3rd quartile", "Maximum")
colnames(summat) <- "Summary"
return(summat)
}, rownames = TRUE)
output$distPlot <- renderPlot({
#gather other inputs
color <- input$graphCol
graphType <- input$graphType
mydf <- as.data.frame(faithfuld)
x <- mydf[, varIndex()]
if(graphType == "Histogram" & !is.null(input$bins)) {
# generate bins based on input$bins from ui.R
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x,
breaks = bins,
col = color,
border = 'white',
main = paste("Histogram of ", varName()),
xlab = varName())
} else if(graphType == "LineGraph") {
#draw Line Graph
plot(x,
type = "l",
col = color,
main = paste("LIne Graph of ", varName()),
xlab = "Index",
ylab = varName())
} else if(graphType == "Box-And-Whisker-Plot") {
#draw Box-and-Whisker Plot
boxplot(x,
col = color,
main = paste("Box and Whisket Plot of ", varName()),
xlab = varName())
}
})
})
| /server.R | no_license | cyanophyta/DDP_Project_ShinyApps | R | false | false | 3,491 | r | #
# This is the server logic of a Shiny web application. You can run the
# application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
library(data.table)
library(ggplot2)
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
varIndex <- reactive({
return(switch(input$variable,
"eruptions" = 1,
"waiting" = 2,
"density" = 3))
})
varName <- reactive({
return(switch(input$variable,
"eruptions" = "Eruptions",
"waiting" = "Waiting Time (in minutes)",
"density" = "Density"))
})
slider <- reactive({
graphType <- input$graphType
if(graphType == "Histogram") {
sliderInput("bins",
"Number of intervals to group data:",
min = 1,
max = 50,
value = 20)
} else {
return(NULL)
}
})
output$overview1 <- renderText({
"Package ggplot2 contians faithfuld dataset which contains data on
eruptions from Old Faithful Geyser along with density estimates. This dataset
records three variables, viz. Eruptions, Density and Waiting time between
eruptions, measured in minutes.
"
})
output$overview2 <- renderText({
"Here we plot Histograms or Line Graphs or Box-and-whisker Plots of one of
these three variables. Using various controls in the navigation pane on the
left side, please select one of these three variables to explore, the type
of graph to be displayed and color of the graph. For histogram, there is an
additional way of selecting the number of intervals to be used for the graph.
By default, 20 intervals will be used to group the data for displaying histogram.
"
})
output$histSlider <- renderUI({
slider()
})
output$summary <- renderTable({
mydf <- as.data.frame(faithfuld)
x <- mydf[, varIndex()]
summat <- as.matrix(summary(x))
rownames(summat) <- c("Minimum", "1st quartile", "Median",
"Mean", "3rd quartile", "Maximum")
colnames(summat) <- "Summary"
return(summat)
}, rownames = TRUE)
output$distPlot <- renderPlot({
#gather other inputs
color <- input$graphCol
graphType <- input$graphType
mydf <- as.data.frame(faithfuld)
x <- mydf[, varIndex()]
if(graphType == "Histogram" & !is.null(input$bins)) {
# generate bins based on input$bins from ui.R
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x,
breaks = bins,
col = color,
border = 'white',
main = paste("Histogram of ", varName()),
xlab = varName())
} else if(graphType == "LineGraph") {
#draw Line Graph
plot(x,
type = "l",
col = color,
main = paste("LIne Graph of ", varName()),
xlab = "Index",
ylab = varName())
} else if(graphType == "Box-And-Whisker-Plot") {
#draw Box-and-Whisker Plot
boxplot(x,
col = color,
main = paste("Box and Whisket Plot of ", varName()),
xlab = varName())
}
})
})
|
#will compare IPD from a list of particleDataFrames. Calculates the ratio of IPD
#' Plot interparticle distance between runs
#'
#' This function plots interparticle distance between runs for each free
#' parameter
#'
#'
#' @param particleDataFrame particleDataFrame output from doRun
#' @param verbose Commented screen output
#' @return Returns a plot with IPD between runs per generation
#' @author Brian O'Meara and Barb Banbury
#' @references O'Meara and Banbury, unpublished
compareListIPD<-function(particleDataFrame, verbose=F){ #list of particleDataFrames
params<-dim(particleDataFrame[[1]][7:dim(particleDataFrame[[1]])[2]])[2]
plot.new()
nf<-layout(matrix(1:params, nrow=1, byrow=TRUE), respect=TRUE)
layout.show(nf)
data1<-vector("list")
maxgen<-c()
for (list in 1:length(particleDataFrame)) {
data1[[list]]<-subset(particleDataFrame[[list]][which(particleDataFrame[[list]][,6]>0),], )
maxgen<-append(maxgen, max(data1[[list]]$generation))
}
for (param in 1:params){
genvector<-vector()
IPDvector<-vector()
for (gen in 1:max(maxgen)){
IPDmatrix<-matrix(nrow=length(data1), ncol=length(data1))
for (row in 1: dim(IPDmatrix)[1]){
for (col in 1: dim(IPDmatrix)[2]){
IPDmatrix[row, col]<-(median(interparticleDistance(data1[[row]][which(data1[[row]]$generation==gen),6+param], data1[[col]][which(data1[[col]]$generation==gen),6+param]))^2) / median(interparticleDistance(data1[[row]][which(data1[[row]]$generation==gen),6+param], data1[[col]][which(data1[[col]]$generation==gen),6+param]))*2
if (is.na(IPDmatrix[row, col])){ #protect against NAs, since we are dividing above (if sd(A and or B[param] = 0 then it will NA))
IPDmatrix[row, col]<-0
}
}
}
#print(paste("param = ", param))
#print(paste("generation = ", gen))
genvector<-append(genvector, rep(gen, length(unique(as.vector(IPDmatrix)))))
IPDvector<-append(IPDvector, unique(as.vector(IPDmatrix)))
#print(genvector)
#print(IPDvector)
if(verbose){
print(paste("param=", names(data1[[1]][6+param])))
print(cbind(genvector, IPDvector))
}
}
#pdf(paste("compareListIPD", jobName, ".pdf", sep=""))
plot(genvector, IPDvector, xlab="generation", ylab="IPD", sub=names(data1[[1]][6+param]))
}
}
| /R/compareListIPD.R | no_license | JakeJing/treevo | R | false | false | 2,260 | r | #will compare IPD from a list of particleDataFrames. Calculates the ratio of IPD
#' Plot interparticle distance between runs
#'
#' This function plots interparticle distance between runs for each free
#' parameter
#'
#'
#' @param particleDataFrame particleDataFrame output from doRun
#' @param verbose Commented screen output
#' @return Returns a plot with IPD between runs per generation
#' @author Brian O'Meara and Barb Banbury
#' @references O'Meara and Banbury, unpublished
compareListIPD<-function(particleDataFrame, verbose=F){ #list of particleDataFrames
params<-dim(particleDataFrame[[1]][7:dim(particleDataFrame[[1]])[2]])[2]
plot.new()
nf<-layout(matrix(1:params, nrow=1, byrow=TRUE), respect=TRUE)
layout.show(nf)
data1<-vector("list")
maxgen<-c()
for (list in 1:length(particleDataFrame)) {
data1[[list]]<-subset(particleDataFrame[[list]][which(particleDataFrame[[list]][,6]>0),], )
maxgen<-append(maxgen, max(data1[[list]]$generation))
}
for (param in 1:params){
genvector<-vector()
IPDvector<-vector()
for (gen in 1:max(maxgen)){
IPDmatrix<-matrix(nrow=length(data1), ncol=length(data1))
for (row in 1: dim(IPDmatrix)[1]){
for (col in 1: dim(IPDmatrix)[2]){
IPDmatrix[row, col]<-(median(interparticleDistance(data1[[row]][which(data1[[row]]$generation==gen),6+param], data1[[col]][which(data1[[col]]$generation==gen),6+param]))^2) / median(interparticleDistance(data1[[row]][which(data1[[row]]$generation==gen),6+param], data1[[col]][which(data1[[col]]$generation==gen),6+param]))*2
if (is.na(IPDmatrix[row, col])){ #protect against NAs, since we are dividing above (if sd(A and or B[param] = 0 then it will NA))
IPDmatrix[row, col]<-0
}
}
}
#print(paste("param = ", param))
#print(paste("generation = ", gen))
genvector<-append(genvector, rep(gen, length(unique(as.vector(IPDmatrix)))))
IPDvector<-append(IPDvector, unique(as.vector(IPDmatrix)))
#print(genvector)
#print(IPDvector)
if(verbose){
print(paste("param=", names(data1[[1]][6+param])))
print(cbind(genvector, IPDvector))
}
}
#pdf(paste("compareListIPD", jobName, ".pdf", sep=""))
plot(genvector, IPDvector, xlab="generation", ylab="IPD", sub=names(data1[[1]][6+param]))
}
}
|
#2017-03-01
options(warn = -1)
options(stringsAsFactors = F)
suppressMessages(library('reshape2'))
suppressMessages(library('argparser'))
suppressMessages(library('plyr'))
suppressMessages(library('dplyr'))
suppressMessages(library('omplotr'))
p <- arg_parser('reads quality plot')
p <- add_argument(p,'--rq_dir',help = 'reads quality stats file directory.')
argv <- parse_args(parser = p)
# read parameters
rq_dir <- argv$rq_dir
all_files <- list.files(rq_dir)
rq_files <- all_files[grep("*reads_quality.txt", all_files)]
split_str <- function(strings, Split) {
for (i in 1:nchar(strings)) {
if (substr(strings, i, i) == Split) {
return(c(substr(strings, 1, i - 1), substr(strings, i + 1, nchar(strings))))
}
}
}
reads_quality_plot2 <- function(plot_data, output=NULL, title="") {
sample_number <- length(unique(plot_data$sample))
max_qual <- max(plot_data$quality)
p <- ggplot(plot_data, aes(X.Base, quality)) +
geom_bar(width = 0.75, stat = 'identity',
fill = 'lightblue') +
theme_onmath() +
scale_x_continuous(breaks = seq(0, 300, 50)) +
geom_vline(xintercept = 150,
color = 'grey50',
lty = 2, size=0.5) +
xlab("Postion") + ylab("Quality") +
coord_cartesian(ylim=c(20,max_qual)) +
ggtitle(title)
if (sample_number > 1) {
facet_wrap_ncol = round(sqrt(sample_number))
p <- p + facet_wrap(~sample, ncol = facet_wrap_ncol)
}
if (! is.null(output)) {
plot_height <- 6 + sample_number/4
plot_width <- 8 + sample_number/4
save_ggplot(p, output,
width=plot_width,
height=plot_height)
}
return(p)
}
rq_file_list <- list()
for (i in seq(length(rq_files))) {
each_sample_rq_df <- read.delim(paste(rq_dir, rq_files[i], sep='/'))
sample_id <- split_str(rq_files[i], Split='.')[1]
each_sample_rq_df$sample <- sample_id
each_sample_rq_df[is.na(each_sample_rq_df)] <- 0
rq_file_list[[i]] <- each_sample_rq_df
each_sample_out_name <- paste(sample_id, 'reads_quality.bar', sep = '.')
each_sample_out_path <- file.path(rq_dir, each_sample_out_name)
reads_quality_plot2(each_sample_rq_df, each_sample_out_path, title=sample_id)
}
#rq_file_df <- ldply(rq_file_list, data.frame)
#samples <- unique(rq_file_df$sample)
#sample_number <- length(samples)
#selected_num <- ifelse(sample_number < 9, sample_number, 9)
#selected_df <- filter(rq_file_df, sample %in% samples[1:selected_num])
#rq_plot_out <- file.path(rq_dir, 'reads_quality.bar.report')
#selected_df$sample <- factor(selected_df$sample, levels = samples)
#reads_quality_plot2(selected_df, rq_plot_out)
| /script/reads_qc/reads_quality_plot.R | no_license | bioShaun/om-nf-rnaseq | R | false | false | 2,733 | r | #2017-03-01
options(warn = -1)
options(stringsAsFactors = F)
suppressMessages(library('reshape2'))
suppressMessages(library('argparser'))
suppressMessages(library('plyr'))
suppressMessages(library('dplyr'))
suppressMessages(library('omplotr'))
p <- arg_parser('reads quality plot')
p <- add_argument(p,'--rq_dir',help = 'reads quality stats file directory.')
argv <- parse_args(parser = p)
# read parameters
rq_dir <- argv$rq_dir
all_files <- list.files(rq_dir)
rq_files <- all_files[grep("*reads_quality.txt", all_files)]
split_str <- function(strings, Split) {
for (i in 1:nchar(strings)) {
if (substr(strings, i, i) == Split) {
return(c(substr(strings, 1, i - 1), substr(strings, i + 1, nchar(strings))))
}
}
}
reads_quality_plot2 <- function(plot_data, output=NULL, title="") {
sample_number <- length(unique(plot_data$sample))
max_qual <- max(plot_data$quality)
p <- ggplot(plot_data, aes(X.Base, quality)) +
geom_bar(width = 0.75, stat = 'identity',
fill = 'lightblue') +
theme_onmath() +
scale_x_continuous(breaks = seq(0, 300, 50)) +
geom_vline(xintercept = 150,
color = 'grey50',
lty = 2, size=0.5) +
xlab("Postion") + ylab("Quality") +
coord_cartesian(ylim=c(20,max_qual)) +
ggtitle(title)
if (sample_number > 1) {
facet_wrap_ncol = round(sqrt(sample_number))
p <- p + facet_wrap(~sample, ncol = facet_wrap_ncol)
}
if (! is.null(output)) {
plot_height <- 6 + sample_number/4
plot_width <- 8 + sample_number/4
save_ggplot(p, output,
width=plot_width,
height=plot_height)
}
return(p)
}
rq_file_list <- list()
for (i in seq(length(rq_files))) {
each_sample_rq_df <- read.delim(paste(rq_dir, rq_files[i], sep='/'))
sample_id <- split_str(rq_files[i], Split='.')[1]
each_sample_rq_df$sample <- sample_id
each_sample_rq_df[is.na(each_sample_rq_df)] <- 0
rq_file_list[[i]] <- each_sample_rq_df
each_sample_out_name <- paste(sample_id, 'reads_quality.bar', sep = '.')
each_sample_out_path <- file.path(rq_dir, each_sample_out_name)
reads_quality_plot2(each_sample_rq_df, each_sample_out_path, title=sample_id)
}
#rq_file_df <- ldply(rq_file_list, data.frame)
#samples <- unique(rq_file_df$sample)
#sample_number <- length(samples)
#selected_num <- ifelse(sample_number < 9, sample_number, 9)
#selected_df <- filter(rq_file_df, sample %in% samples[1:selected_num])
#rq_plot_out <- file.path(rq_dir, 'reads_quality.bar.report')
#selected_df$sample <- factor(selected_df$sample, levels = samples)
#reads_quality_plot2(selected_df, rq_plot_out)
|
#' Returns the parent TSN for the entered TSN.
#'
#' @export
#' @inheritParams accepted_names
#' @template tsn
#' @return a data.frame
#' @examples \dontrun{
#' parent_tsn(tsn = 202385)
#' parent_tsn(tsn = 202385, raw = TRUE)
#' parent_tsn(tsn = 202385, wt = "xml")
#' }
parent_tsn <- function(tsn, wt = "json", raw = FALSE, ...) {
out <- itis_GET("getParentTSNFromTSN", list(tsn = tsn), wt, ...)
if (raw || wt == "xml") return(out)
x <- parse_raw(out)
res <- tc(pick_cols(x, c("parentTsn", "tsn")))
tibble::as_tibble(
if (length(names(res)) == 1) NULL else res
)
}
| /R/parent_tsn.R | permissive | ropensci/ritis | R | false | false | 582 | r | #' Returns the parent TSN for the entered TSN.
#'
#' @export
#' @inheritParams accepted_names
#' @template tsn
#' @return a data.frame
#' @examples \dontrun{
#' parent_tsn(tsn = 202385)
#' parent_tsn(tsn = 202385, raw = TRUE)
#' parent_tsn(tsn = 202385, wt = "xml")
#' }
parent_tsn <- function(tsn, wt = "json", raw = FALSE, ...) {
out <- itis_GET("getParentTSNFromTSN", list(tsn = tsn), wt, ...)
if (raw || wt == "xml") return(out)
x <- parse_raw(out)
res <- tc(pick_cols(x, c("parentTsn", "tsn")))
tibble::as_tibble(
if (length(names(res)) == 1) NULL else res
)
}
|
# Simple model linking exponential tumour growth to an
# exponential survival function
g<- log(2)/62 # 62 day (2 months) doubling time
k <- 0.001 # rate parameter
t<-seq(0,500,by=1) # time-frame
# plot dynamics
plot(t,exp(g*t),type="l",xlab="Time (Days)",ylab="Tumour Burden")
# doubling time slows modestly
lines(t,exp(0.9*g*t),col=2)
# 100 is the death number
abline(h=100,lty=2)
# the above two options give following survival time using threshold
# y = exp(g*t), 100 = exp(g*t), t = log(100)/g
log(100)/g # 412 days
log(100)/(0.9*g)# 458 days
# lets now account for cumulative risk - as is what is observed
S<- exp(-k*exp(g*t)*t)
plot(t,S,type="l", ylab="Survival Probability",xlab = "Time (Days)")
S<- exp(-k*exp(0.9*g*t)*t)
lines(t,S,col=2)
# the above will depend on your choice of K, but there is something else to
# remember here, tumour burden doesn't really explain that much of the
# survival variance, so in reality....
k0<- 0.01
k1<- 0.001
S<- exp(-(k0+k1*exp(g*t))*t)
plot(t,S,type="l", ylab="Survival Probability",xlab = "Time (Days)")
S<- exp(-(k0+k1*exp(0.9*g*t))*t)
lines(t,S,col=2)
# This may make your results stronger - have a play | /Scaborough_et_al.R | no_license | mcbi9hm2/Scaborough_et_al_2020 | R | false | false | 1,201 | r | # Simple model linking exponential tumour growth to an
# exponential survival function
g<- log(2)/62 # 62 day (2 months) doubling time
k <- 0.001 # rate parameter
t<-seq(0,500,by=1) # time-frame
# plot dynamics
plot(t,exp(g*t),type="l",xlab="Time (Days)",ylab="Tumour Burden")
# doubling time slows modestly
lines(t,exp(0.9*g*t),col=2)
# 100 is the death number
abline(h=100,lty=2)
# the above two options give following survival time using threshold
# y = exp(g*t), 100 = exp(g*t), t = log(100)/g
log(100)/g # 412 days
log(100)/(0.9*g)# 458 days
# lets now account for cumulative risk - as is what is observed
S<- exp(-k*exp(g*t)*t)
plot(t,S,type="l", ylab="Survival Probability",xlab = "Time (Days)")
S<- exp(-k*exp(0.9*g*t)*t)
lines(t,S,col=2)
# the above will depend on your choice of K, but there is something else to
# remember here, tumour burden doesn't really explain that much of the
# survival variance, so in reality....
k0<- 0.01
k1<- 0.001
S<- exp(-(k0+k1*exp(g*t))*t)
plot(t,S,type="l", ylab="Survival Probability",xlab = "Time (Days)")
S<- exp(-(k0+k1*exp(0.9*g*t))*t)
lines(t,S,col=2)
# This may make your results stronger - have a play |
#' Read TRIM data files
#'
#' Read data files intended for the original TRIM programme.
#'
#' @section The TRIM data file format:
#'
#' TRIM input data is stored in a \code{ASCII} encoded file where headerless columns
#' are separated by one or more spaces. Below are the columns as \code{read_tdf} expects
#' them.
#'
#' \tabular{lll}{
#' \bold{Variable} \tab\bold{status} \tab \bold{R type}\cr
#' \code{site} \tab requiered \tab \code{integer}\cr
#' \code{time} \tab required \tab \code{integer}\cr
#' \code{count} \tab required \tab \code{numeric}\cr
#' \code{weight} \tab optional \tab \code{numeric}\cr
#' \code{<covariate1>}\tab optional\tab \code{integer}\cr
#' \code{...}\tab\tab\cr
#' \code{<covariateN>}\tab optional\tab \code{integer}\cr
#' }
#'
#'
#' @param x a filename or a \code{\link{trimcommand}} object
#' @param missing \code{[integer]} missing value indicator.
#' Missing values are translated to \code{\link[base]{NA}}.
#' @param weight \code{[logical]} indicate presence of a weight column
#' @param ncovars \code{[logical]} The number of covariates in the file
#' @param labels \code{[character]} (optional) specify labels for the covariates.
#' Defaults to \code{cov<i>} (\code{i=1,2,...,ncovars}) if none are specified.
#' @param ... (unused)
#'
#' @return A \code{data.frame}.
#'
#' @family modelspec
#' @export
read_tdf <- function(x,...){
UseMethod("read_tdf")
}
#' @rdname read_tdf
#' @export
read_tdf.character <- function(x, missing = -1, weight = FALSE, ncovars=0, labels=character(0),...){
tdfread(file=x, missing=missing, weight=weight,ncovars=ncovars, labels=labels)
}
#' @rdname read_tdf
#' @export
read_tdf.trimcommand <- function(x,...){
tdfread(x$file, missing = x$missing, weight = x$weight, ncovars = x$ncovars, labels=x$labels)
}
# workhorse function for the S3 interfaces
tdfread <- function(file, missing, weight, ncovars, labels){
if ( ncovars > 0 && length(labels) == 0 ){
labels <- paste0("cov",seq_len(ncovars))
} else if ( ncovars != length(labels)) {
stop(sprintf("Length of 'labels' (%d) unequal to 'ncovars' (%d)",length(labels),ncovars))
}
colclasses <- c(site = "integer", time = "integer", count="numeric")
if (weight) colclasses['weight'] <- "numeric"
# add labels and names for covariates
colclasses <- c(colclasses, setNames(rep("integer",ncovars), labels))
# by default, one or more blanks (space, tab) are used as separators
tab <- tryCatch(
read.table(file, header=FALSE, colClasses=colclasses, col.names = names(colclasses))
, error=function(e) snifreport(file, colclasses))
if (nrow(tab)==0) stop(sprintf("file \"%s\" appears to be empty", file))
if (nrow(tab) > 0) tab[tab == missing] <- NA
tab
}
snifreport <- function(file, colclasses){
if (!file.exists(file)) stop(sprintf("Could not find file %s",file))
ncl <- length(colclasses)
lns <- readLines(file,n=5)
if (length(lns)==0) stop(sprintf("file \"%s\" appears to be empty", file))
cls <- paste(paste0(names(colclasses),"<",colclasses,">"),collapse=" ")
msg <- sprintf("\n\rExpected %s columns: %s\nStart of file looks like this:\n",ncl,cls)
msg <- paste0(msg,paste(sprintf("\r%s\n",lns), collapse=""))
stop(msg, call.=FALSE)
}
#' Compute a summary of counts
#'
#'
#' Summarize counts over a trim input dataset. Sites without counts are removed
#' before any counting takes place (since these will not be used when calling
#' \code{\link{trim}}). For the remaining records, the total number of
#' zero-counts, positive counts, total number of observed counts and the total
#' number of missings are reported.
#'
#' @param x A \code{data.frame} with annual counts per site.
#' @param eps \code{[numeric]} Numbers smaller then \code{eps} are treated a zero.
#' @param site.id \code{[character|numeric]} index of the column containing the site id's
#' @param time.id \code{[character|numeric]} index of the column containing the time codes
#' @param count.id \code{[character|numeric]} index of the column containing the counts
#'
#' @return A \code{list} of class \code{count.summary} containing individual names.
#' @export
#' @examples
#' data(skylark)
#' count_summary(skylark)
#'
#' s <- count_summary(skylark)
#' s$zero_counts # obtain number of zero counts
count_summary <- function(x, count.id="count", site.id="site", time.id="time", eps=1e-8){
site_count <- tapply(X = x[,count.id], INDEX = x[site.id], FUN=sum, na.rm=TRUE)
ii <- abs(site_count) < eps
sites_wout_counts <- character(0)
if (any(ii)){
sites_wout_counts <- names(site_count[ii])
x <- x[!x[,site.id] %in% sites_wout_counts,,drop=FALSE]
}
cnt <- x[,count.id]
L <- list(
sites = length(unique(x[,site.id]))
, sites_without_counts = sites_wout_counts
, zero_counts = sum(cnt<eps,na.rm=TRUE)
, positive_counts = sum(cnt>0, na.rm=TRUE)
, total_observed = sum(!is.na(cnt))
, missing_counts = sum(is.na(cnt))
)
L$total_counts <- with(L, total_observed + missing_counts)
structure(L, class=c("count.summary","list"))
}
#' print a count summary
#'
#' @param x An R object
#' @param ... unused
#'
#' @export
#' @keywords internal
print.count.summary <- function(x,...){
printf("Total number of sites %8d\n", x$sites)
printf("Sites without positive counts (%d): %s\n"
, length(x$sites_without_counts)
, paste(x$sites_without_counts,collapse=", ")
)
printf("Number of observed zero counts %8d\n",x$zero_counts)
printf("Number of observed positive counts %8d\n",x$positive_counts)
printf("Total number of observed counts %8d\n",x$total_observed)
printf("Number of missing counts %8d\n",x$missing_counts)
printf("Total number of counts %8d\n",x$total_counts)
}
| /pkg/R/read_tdf.R | no_license | Rousettus/rtrim | R | false | false | 5,792 | r |
#' Read TRIM data files
#'
#' Read data files intended for the original TRIM programme.
#'
#' @section The TRIM data file format:
#'
#' TRIM input data is stored in a \code{ASCII} encoded file where headerless columns
#' are separated by one or more spaces. Below are the columns as \code{read_tdf} expects
#' them.
#'
#' \tabular{lll}{
#' \bold{Variable} \tab\bold{status} \tab \bold{R type}\cr
#' \code{site} \tab requiered \tab \code{integer}\cr
#' \code{time} \tab required \tab \code{integer}\cr
#' \code{count} \tab required \tab \code{numeric}\cr
#' \code{weight} \tab optional \tab \code{numeric}\cr
#' \code{<covariate1>}\tab optional\tab \code{integer}\cr
#' \code{...}\tab\tab\cr
#' \code{<covariateN>}\tab optional\tab \code{integer}\cr
#' }
#'
#'
#' @param x a filename or a \code{\link{trimcommand}} object
#' @param missing \code{[integer]} missing value indicator.
#' Missing values are translated to \code{\link[base]{NA}}.
#' @param weight \code{[logical]} indicate presence of a weight column
#' @param ncovars \code{[logical]} The number of covariates in the file
#' @param labels \code{[character]} (optional) specify labels for the covariates.
#' Defaults to \code{cov<i>} (\code{i=1,2,...,ncovars}) if none are specified.
#' @param ... (unused)
#'
#' @return A \code{data.frame}.
#'
#' @family modelspec
#' @export
read_tdf <- function(x,...){
UseMethod("read_tdf")
}
#' @rdname read_tdf
#' @export
read_tdf.character <- function(x, missing = -1, weight = FALSE, ncovars=0, labels=character(0),...){
tdfread(file=x, missing=missing, weight=weight,ncovars=ncovars, labels=labels)
}
#' @rdname read_tdf
#' @export
read_tdf.trimcommand <- function(x,...){
tdfread(x$file, missing = x$missing, weight = x$weight, ncovars = x$ncovars, labels=x$labels)
}
# workhorse function for the S3 interfaces
tdfread <- function(file, missing, weight, ncovars, labels){
if ( ncovars > 0 && length(labels) == 0 ){
labels <- paste0("cov",seq_len(ncovars))
} else if ( ncovars != length(labels)) {
stop(sprintf("Length of 'labels' (%d) unequal to 'ncovars' (%d)",length(labels),ncovars))
}
colclasses <- c(site = "integer", time = "integer", count="numeric")
if (weight) colclasses['weight'] <- "numeric"
# add labels and names for covariates
colclasses <- c(colclasses, setNames(rep("integer",ncovars), labels))
# by default, one or more blanks (space, tab) are used as separators
tab <- tryCatch(
read.table(file, header=FALSE, colClasses=colclasses, col.names = names(colclasses))
, error=function(e) snifreport(file, colclasses))
if (nrow(tab)==0) stop(sprintf("file \"%s\" appears to be empty", file))
if (nrow(tab) > 0) tab[tab == missing] <- NA
tab
}
snifreport <- function(file, colclasses){
if (!file.exists(file)) stop(sprintf("Could not find file %s",file))
ncl <- length(colclasses)
lns <- readLines(file,n=5)
if (length(lns)==0) stop(sprintf("file \"%s\" appears to be empty", file))
cls <- paste(paste0(names(colclasses),"<",colclasses,">"),collapse=" ")
msg <- sprintf("\n\rExpected %s columns: %s\nStart of file looks like this:\n",ncl,cls)
msg <- paste0(msg,paste(sprintf("\r%s\n",lns), collapse=""))
stop(msg, call.=FALSE)
}
#' Compute a summary of counts
#'
#'
#' Summarize counts over a trim input dataset. Sites without counts are removed
#' before any counting takes place (since these will not be used when calling
#' \code{\link{trim}}). For the remaining records, the total number of
#' zero-counts, positive counts, total number of observed counts and the total
#' number of missings are reported.
#'
#' @param x A \code{data.frame} with annual counts per site.
#' @param eps \code{[numeric]} Numbers smaller then \code{eps} are treated a zero.
#' @param site.id \code{[character|numeric]} index of the column containing the site id's
#' @param time.id \code{[character|numeric]} index of the column containing the time codes
#' @param count.id \code{[character|numeric]} index of the column containing the counts
#'
#' @return A \code{list} of class \code{count.summary} containing individual names.
#' @export
#' @examples
#' data(skylark)
#' count_summary(skylark)
#'
#' s <- count_summary(skylark)
#' s$zero_counts # obtain number of zero counts
count_summary <- function(x, count.id="count", site.id="site", time.id="time", eps=1e-8){
site_count <- tapply(X = x[,count.id], INDEX = x[site.id], FUN=sum, na.rm=TRUE)
ii <- abs(site_count) < eps
sites_wout_counts <- character(0)
if (any(ii)){
sites_wout_counts <- names(site_count[ii])
x <- x[!x[,site.id] %in% sites_wout_counts,,drop=FALSE]
}
cnt <- x[,count.id]
L <- list(
sites = length(unique(x[,site.id]))
, sites_without_counts = sites_wout_counts
, zero_counts = sum(cnt<eps,na.rm=TRUE)
, positive_counts = sum(cnt>0, na.rm=TRUE)
, total_observed = sum(!is.na(cnt))
, missing_counts = sum(is.na(cnt))
)
L$total_counts <- with(L, total_observed + missing_counts)
structure(L, class=c("count.summary","list"))
}
#' print a count summary
#'
#' @param x An R object
#' @param ... unused
#'
#' @export
#' @keywords internal
print.count.summary <- function(x,...){
printf("Total number of sites %8d\n", x$sites)
printf("Sites without positive counts (%d): %s\n"
, length(x$sites_without_counts)
, paste(x$sites_without_counts,collapse=", ")
)
printf("Number of observed zero counts %8d\n",x$zero_counts)
printf("Number of observed positive counts %8d\n",x$positive_counts)
printf("Total number of observed counts %8d\n",x$total_observed)
printf("Number of missing counts %8d\n",x$missing_counts)
printf("Total number of counts %8d\n",x$total_counts)
}
|
# numvarSum function ----------------------------------------------
# this summarizes a numerical variable (n, na(missing, mean, median, sd,
# variance, min, max, and se) when given a data frame or tibble and
# variable: q14_rpt_fun(df, var)
numvarSum <- function(df, expr) {
expr <- enquo(expr) # turns expr into a quosure
summarise(df,
n = sum((!is.na(!!expr))), # non-missing
na = sum((is.na(!!expr))), # missing
mean = mean(!!expr, na.rm = TRUE), # unquotes mean()
median = median(!!expr, na.rm = TRUE), # unquotes median()
sd = sd(!!expr, na.rm = TRUE), # unquotes sd()
variance = var(!!expr, na.rm = TRUE), # unquotes var()
min = min(!!expr, na.rm = TRUE), # unquotes min()
max = max(!!expr, na.rm = TRUE), # unquotes max()
se = sd/sqrt(n)) # standard error
}
| /Code/numvarSum.R | no_license | mjfrigaard/dubnation-twitter-data | R | false | false | 861 | r | # numvarSum function ----------------------------------------------
# this summarizes a numerical variable (n, na(missing, mean, median, sd,
# variance, min, max, and se) when given a data frame or tibble and
# variable: q14_rpt_fun(df, var)
numvarSum <- function(df, expr) {
expr <- enquo(expr) # turns expr into a quosure
summarise(df,
n = sum((!is.na(!!expr))), # non-missing
na = sum((is.na(!!expr))), # missing
mean = mean(!!expr, na.rm = TRUE), # unquotes mean()
median = median(!!expr, na.rm = TRUE), # unquotes median()
sd = sd(!!expr, na.rm = TRUE), # unquotes sd()
variance = var(!!expr, na.rm = TRUE), # unquotes var()
min = min(!!expr, na.rm = TRUE), # unquotes min()
max = max(!!expr, na.rm = TRUE), # unquotes max()
se = sd/sqrt(n)) # standard error
}
|
#cat("################################################",sep="\n")
#cat(" R called from Pajek ",sep="\n")
#cat(" http://vlado.fmf.uni-lj.si/pub/networks/pajek/ ",sep="\n")
#cat(" Vladimir Batagelj & Andrej Mrvar ",sep="\n")
#cat(" University of Ljubljana, Slovenia ",sep="\n")
#cat("-----------------------------------------------------------------------",sep="\n")
#cat(" The following networks/matrices read:",sep="\n")
n1<-matrix(nrow=13,ncol=13,seq(0,0,length=169))
G=0
F=0
n1[13,5]<-1; G[13]=5
n1[1,5]<-1; G[1]=5
n1[1,6]<-2; F[1]=6
n1[2,6]<-1; G[2]=6
n1[2,7]<-2; F[2]=7
n1[3,7]<-1; G[3]=7
n1[3,8]<-2; F[3]=8
n1[4,8]<-1; G[4]=8
n1[4,5]<-2; F[4]=5
n1[5,9]<-1; G[5]=9
n1[5,10]<-2; F[5]=10
n1[6,10]<-1; G[6]=10
n1[6,11]<-2; F[6]=11
n1[7,11]<-1; G[7]=11
n1[7,12]<-2; F[7]=12
n1[8,12]<-1; G[8]=12
n1[8,9]<-2; F[8]=9
G[9]=0
G[10]=0
G[11]=0
G[12]=0
F[13]=0
F[9]=0
F[10]=0
F[11]=0
F[12]=0
F[13]=0
colnames(n1)<-c("Child 1","Child 2","Child 3","Child 4","Couple 5","Couple 6","Couple 7","Couple 8","Couple 9","Andestor 10","Couple 11","Andestor 12","Child 13")
rownames(n1)<-c("Child 1","Child 2","Child 3","Child 4","Couple 5","Couple 6","Couple 7","Couple 8","Couple 9","Andestor 10","Couple 11","Andestor 12","Child 13")
comment(n1)<-"C:/Program Files/R/R-2.6.2/0KinPajFiles/KinSim3gen.net (13)"
#cat(" n1 : C:/Program Files/R/R-2.6.2/0KinPajFiles/KinSim3gen.net (13)",sep="\n")
#cat("",sep="\n")
#cat(" The following vectors read:",sep="\n")
v1<-c(1,1,1,1,2,2,2,2,3,3,3,3,1)
comment(v1)<-"From partition 1 (13)"
#cat(" v1 : From partition 1 (13)",sep="\n")
v2<-c(0.77000000,0.59000000,0.41000000,0.23000000,0.77000000,0.59000000,0.41000000,0.23000000,0.77000000,0.59000000,0.41000000,0.23000000,0.92710000)
comment(v2)<-"x-coordinate of N1 (13)"
#cat(" v2 : x-coordinate of N1 (13)",sep="\n")
#cat("",sep="\n")
#cat(" Use objects() to get list of available objects ",sep="\n")
#cat(" Use comment(?) to get information about selected object ",sep="\n")
savevector<-function(v,direct){write(c(paste("*Vertices",length(v)), v), file = direct, ncolumns=1)}
#cat(" Use savevector(v?,'???.vec') to save vector to Pajek input file ",sep="\n")
comment(savevector)<-"Save vector to file that can be read by Pajek"
savematrix <- function(n,direct,twomode=1){
if ((dim(n)[1] == dim(n)[2]) & (twomode!=2))
{ write(paste("*Vertices",dim(n)[1]), file = direct);
write(paste(seq(1,length=dim(n)[1]),' "',rownames(n),'"',sep=""), file = direct,append=TRUE);
write("*Matrix", file = direct,append=TRUE);
write(t(n),file = direct,ncolumns=dim(n)[1],append=TRUE) }
else
{ write(paste("*Vertices",sum(dim(n)),dim(n)[1]), file = direct);
write(paste(1:dim(n)[1],' "',rownames(n),'"',sep=""), file = direct,append=TRUE);
write(paste(seq(dim(n)[1]+1,length=dim(n)[2]),' "',colnames(n),'"',sep=""), file = direct,append=TRUE);
write("*Matrix", file = direct, append=TRUE);
write(t(n),file = direct, ncolumns=dim(n)[2],append=TRUE)} }
#cat(" Use savematrix(n?,'???.net') to save matrix to Pajek input file (.MAT) ",sep="\n")
#cat(" savematrix(n?,'???.net',2) to request a 2-mode matrix (.MAT) ",sep="\n")
comment(savematrix)<-"Save matrix to file that can be read by Pajek (as *Matrix)"
savenetwork <- function(n,direct,twomode=1){
if ((dim(n)[1] == dim(n)[2]) & (twomode!=2))
{ write(paste("*Vertices",dim(n)[1]), file = direct);
write(paste(seq(1,length=dim(n)[1]),' "',rownames(n),'"',sep=""), file = direct,append=TRUE);
write("*Arcs", file = direct,append=TRUE);
for (i in 1:dim(n)[1]) {
for (j in 1:dim(n)[2]) {
if (n[i,j]!=0) {write(paste(i,j,n[i,j]),file = direct,append=TRUE)}
}
} }
else
{ write(paste("*Vertices",sum(dim(n)),dim(n)[1]), file = direct);
write(paste(1:dim(n)[1],' "',rownames(n),'"',sep=""), file = direct,append=TRUE);
write(paste(seq(dim(n)[1]+1,length=dim(n)[2]),' "',colnames(n),'"',sep=""), file = direct,append=TRUE);
write("*Edges", file = direct,append=TRUE);
for (i in 1:dim(n)[1]) {
for (j in 1:dim(n)[2]) {
if (n[i,j]!=0) {write(paste(i,j+dim(n)[1],n[i,j]),file = direct,append=TRUE)}
}
} } }
#cat(" Use savenetwork(n?,'???.net') to save matrix to Pajek input file (.NET) ",sep="\n")
#cat(" savenetwork(n?,'???.net',2) to request a 2-mode network (.NET) ",sep="\n")
comment(savenetwork)<-"Save matrix to file that can be read by Pajek (as *Arcs)"
loadvector <- function(direct){
vv<-read.table(file=direct,skip=1)
if (dim(vv)[2]==1)
vv<-vv[[1]]
vv
}
#cat(" Use v?<-loadvector('???.vec') to load vector(s) from Pajek input file ",sep="\n")
comment(loadvector)<-"Load vector(s) from file that was produced by Pajek"
loadmatrix <- function(direct){
nn<-read.table(file=direct,nrows=1)
if (length(nn) == 2)
{ xx<-read.table(file=direct,skip=1,nrows=nn[[2]],fill=TRUE)
n<-read.table(file=direct,skip=nn[[2]]+2)
rownames(n)<-xx[[2]]
colnames(n)<-xx[[2]] }
else
{xxrow<-read.table(file=direct,skip=1,nrows=nn[[3]],fill=TRUE)
xxcol<-read.table(file=direct,skip=nn[[3]]+1,nrows=nn[[2]]-nn[[3]],fill=TRUE)
n<-read.table(file=direct,skip=nn[[2]]+2)
rownames(n)<-xxrow[[2]]
colnames(n)<-xxcol[[2]] }
as.matrix(n)
}
#cat(" Use n?<-loadmatrix('???.mat') to load matrix from Pajek input file ",sep="\n")
comment(loadmatrix)<-"Load matrix from file that was produced by Pajek"
#cat("-----------------------------------------------------------------------",sep="\n")
#cat("",sep="\n")
| /PajekR-KinSimGF_without_cats.R | no_license | sjdayday/net | R | false | false | 5,479 | r | #cat("################################################",sep="\n")
#cat(" R called from Pajek ",sep="\n")
#cat(" http://vlado.fmf.uni-lj.si/pub/networks/pajek/ ",sep="\n")
#cat(" Vladimir Batagelj & Andrej Mrvar ",sep="\n")
#cat(" University of Ljubljana, Slovenia ",sep="\n")
#cat("-----------------------------------------------------------------------",sep="\n")
#cat(" The following networks/matrices read:",sep="\n")
n1<-matrix(nrow=13,ncol=13,seq(0,0,length=169))
G=0
F=0
n1[13,5]<-1; G[13]=5
n1[1,5]<-1; G[1]=5
n1[1,6]<-2; F[1]=6
n1[2,6]<-1; G[2]=6
n1[2,7]<-2; F[2]=7
n1[3,7]<-1; G[3]=7
n1[3,8]<-2; F[3]=8
n1[4,8]<-1; G[4]=8
n1[4,5]<-2; F[4]=5
n1[5,9]<-1; G[5]=9
n1[5,10]<-2; F[5]=10
n1[6,10]<-1; G[6]=10
n1[6,11]<-2; F[6]=11
n1[7,11]<-1; G[7]=11
n1[7,12]<-2; F[7]=12
n1[8,12]<-1; G[8]=12
n1[8,9]<-2; F[8]=9
G[9]=0
G[10]=0
G[11]=0
G[12]=0
F[13]=0
F[9]=0
F[10]=0
F[11]=0
F[12]=0
F[13]=0
colnames(n1)<-c("Child 1","Child 2","Child 3","Child 4","Couple 5","Couple 6","Couple 7","Couple 8","Couple 9","Andestor 10","Couple 11","Andestor 12","Child 13")
rownames(n1)<-c("Child 1","Child 2","Child 3","Child 4","Couple 5","Couple 6","Couple 7","Couple 8","Couple 9","Andestor 10","Couple 11","Andestor 12","Child 13")
comment(n1)<-"C:/Program Files/R/R-2.6.2/0KinPajFiles/KinSim3gen.net (13)"
#cat(" n1 : C:/Program Files/R/R-2.6.2/0KinPajFiles/KinSim3gen.net (13)",sep="\n")
#cat("",sep="\n")
#cat(" The following vectors read:",sep="\n")
v1<-c(1,1,1,1,2,2,2,2,3,3,3,3,1)
comment(v1)<-"From partition 1 (13)"
#cat(" v1 : From partition 1 (13)",sep="\n")
v2<-c(0.77000000,0.59000000,0.41000000,0.23000000,0.77000000,0.59000000,0.41000000,0.23000000,0.77000000,0.59000000,0.41000000,0.23000000,0.92710000)
comment(v2)<-"x-coordinate of N1 (13)"
#cat(" v2 : x-coordinate of N1 (13)",sep="\n")
#cat("",sep="\n")
#cat(" Use objects() to get list of available objects ",sep="\n")
#cat(" Use comment(?) to get information about selected object ",sep="\n")
savevector<-function(v,direct){write(c(paste("*Vertices",length(v)), v), file = direct, ncolumns=1)}
#cat(" Use savevector(v?,'???.vec') to save vector to Pajek input file ",sep="\n")
comment(savevector)<-"Save vector to file that can be read by Pajek"
savematrix <- function(n,direct,twomode=1){
if ((dim(n)[1] == dim(n)[2]) & (twomode!=2))
{ write(paste("*Vertices",dim(n)[1]), file = direct);
write(paste(seq(1,length=dim(n)[1]),' "',rownames(n),'"',sep=""), file = direct,append=TRUE);
write("*Matrix", file = direct,append=TRUE);
write(t(n),file = direct,ncolumns=dim(n)[1],append=TRUE) }
else
{ write(paste("*Vertices",sum(dim(n)),dim(n)[1]), file = direct);
write(paste(1:dim(n)[1],' "',rownames(n),'"',sep=""), file = direct,append=TRUE);
write(paste(seq(dim(n)[1]+1,length=dim(n)[2]),' "',colnames(n),'"',sep=""), file = direct,append=TRUE);
write("*Matrix", file = direct, append=TRUE);
write(t(n),file = direct, ncolumns=dim(n)[2],append=TRUE)} }
#cat(" Use savematrix(n?,'???.net') to save matrix to Pajek input file (.MAT) ",sep="\n")
#cat(" savematrix(n?,'???.net',2) to request a 2-mode matrix (.MAT) ",sep="\n")
comment(savematrix)<-"Save matrix to file that can be read by Pajek (as *Matrix)"
savenetwork <- function(n,direct,twomode=1){
if ((dim(n)[1] == dim(n)[2]) & (twomode!=2))
{ write(paste("*Vertices",dim(n)[1]), file = direct);
write(paste(seq(1,length=dim(n)[1]),' "',rownames(n),'"',sep=""), file = direct,append=TRUE);
write("*Arcs", file = direct,append=TRUE);
for (i in 1:dim(n)[1]) {
for (j in 1:dim(n)[2]) {
if (n[i,j]!=0) {write(paste(i,j,n[i,j]),file = direct,append=TRUE)}
}
} }
else
{ write(paste("*Vertices",sum(dim(n)),dim(n)[1]), file = direct);
write(paste(1:dim(n)[1],' "',rownames(n),'"',sep=""), file = direct,append=TRUE);
write(paste(seq(dim(n)[1]+1,length=dim(n)[2]),' "',colnames(n),'"',sep=""), file = direct,append=TRUE);
write("*Edges", file = direct,append=TRUE);
for (i in 1:dim(n)[1]) {
for (j in 1:dim(n)[2]) {
if (n[i,j]!=0) {write(paste(i,j+dim(n)[1],n[i,j]),file = direct,append=TRUE)}
}
} } }
#cat(" Use savenetwork(n?,'???.net') to save matrix to Pajek input file (.NET) ",sep="\n")
#cat(" savenetwork(n?,'???.net',2) to request a 2-mode network (.NET) ",sep="\n")
comment(savenetwork)<-"Save matrix to file that can be read by Pajek (as *Arcs)"
loadvector <- function(direct){
vv<-read.table(file=direct,skip=1)
if (dim(vv)[2]==1)
vv<-vv[[1]]
vv
}
#cat(" Use v?<-loadvector('???.vec') to load vector(s) from Pajek input file ",sep="\n")
comment(loadvector)<-"Load vector(s) from file that was produced by Pajek"
loadmatrix <- function(direct){
nn<-read.table(file=direct,nrows=1)
if (length(nn) == 2)
{ xx<-read.table(file=direct,skip=1,nrows=nn[[2]],fill=TRUE)
n<-read.table(file=direct,skip=nn[[2]]+2)
rownames(n)<-xx[[2]]
colnames(n)<-xx[[2]] }
else
{xxrow<-read.table(file=direct,skip=1,nrows=nn[[3]],fill=TRUE)
xxcol<-read.table(file=direct,skip=nn[[3]]+1,nrows=nn[[2]]-nn[[3]],fill=TRUE)
n<-read.table(file=direct,skip=nn[[2]]+2)
rownames(n)<-xxrow[[2]]
colnames(n)<-xxcol[[2]] }
as.matrix(n)
}
#cat(" Use n?<-loadmatrix('???.mat') to load matrix from Pajek input file ",sep="\n")
comment(loadmatrix)<-"Load matrix from file that was produced by Pajek"
#cat("-----------------------------------------------------------------------",sep="\n")
#cat("",sep="\n")
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/RcppExports.R, R/package.R
\docType{package}
\name{fasterize}
\alias{fasterize}
\title{Rasterize an sf object of polygons}
\usage{
fasterize(
sf,
raster,
field = NULL,
fun = "last",
background = NA_real_,
by = NULL
)
}
\arguments{
\item{sf}{an \code{\link[sf:sf]{sf::sf()}} object with a geometry column of POLYGON and/or
MULTIPOLYGON objects.}
\item{raster}{A raster object. Used as a template for the raster output.
Can be created with \code{\link[raster:raster]{raster::raster()}}.
The fasterize package provides a method to create a raster object from
an sf object.}
\item{field}{character. The name of a column in \code{sf},
providing a value for each of the polygons rasterized. If NULL (default),
all polygons will be given a value of 1.}
\item{fun}{character. The name of a function by which to combine overlapping
polygons. Currently takes "sum", "first", "last", "min", "max", "count", or
"any". Future versions may include more functions or the ability to pass
custom R/C++ functions. If you need to summarize by a different function,
use \verb{by=} to get a RasterBrick and then \code{\link[raster:stackApply]{raster::stackApply()}} or
\code{\link[raster:calc]{raster::calc()}} to summarize.}
\item{background}{numeric. Value to put in the cells that are not covered by
any of the features of x. Default is NA.}
\item{by}{character. The name of a column in \code{sf} by which to aggregate
layers. If set, fasterize will return a RasterBrick with as many layers
as unique values of the \code{by} column.}
}
\value{
A raster of the same size, extent, resolution and projection as the
provided raster template.
}
\description{
Rasterize set of polygons
Fast sf-to-raster conversion
}
\details{
This is a high-performance replacement for \code{\link[raster:rasterize]{raster::rasterize()}}.
The algorithm is based on the method described in course materials provided
by \href{https://labs.wsu.edu/wayne-cochran/}{Wayne O. Cochran}. The algorithm
is originally attributed to
Wylie et al. (1967) \doi{10.1145/1465611.1465619}.
}
\examples{
library(sf)
library(fasterize)
p1 <- rbind(c(-180,-20), c(-140,55), c(10, 0), c(-140,-60), c(-180,-20))
hole <- rbind(c(-150,-20), c(-100,-10), c(-110,20), c(-150,-20))
p1 <- list(p1, hole)
p2 <- list(rbind(c(-10,0), c(140,60), c(160,0), c(140,-55), c(-10,0)))
p3 <- list(rbind(c(-125,0), c(0,60), c(40,5), c(15,-45), c(-125,0)))
pols <- st_sf(value = rep(1,3),
geometry = st_sfc(lapply(list(p1, p2, p3), st_polygon)))
r <- raster(pols, res = 1)
r <- fasterize(pols, r, field = "value", fun="sum")
plot(r)
}
\references{
Wylie, C., Romney, G., Evans, D., & Erdahl, A. (1967).
Half-tone perspective drawings by computer. Proceedings of the November
14-16, 1967, Fall Joint Computer Conference. AFIPS '67 (Fall).
\doi{10.1145/1465611.1465619}
}
| /man/fasterize.Rd | permissive | ecohealthalliance/fasterize | R | false | true | 2,904 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/RcppExports.R, R/package.R
\docType{package}
\name{fasterize}
\alias{fasterize}
\title{Rasterize an sf object of polygons}
\usage{
fasterize(
sf,
raster,
field = NULL,
fun = "last",
background = NA_real_,
by = NULL
)
}
\arguments{
\item{sf}{an \code{\link[sf:sf]{sf::sf()}} object with a geometry column of POLYGON and/or
MULTIPOLYGON objects.}
\item{raster}{A raster object. Used as a template for the raster output.
Can be created with \code{\link[raster:raster]{raster::raster()}}.
The fasterize package provides a method to create a raster object from
an sf object.}
\item{field}{character. The name of a column in \code{sf},
providing a value for each of the polygons rasterized. If NULL (default),
all polygons will be given a value of 1.}
\item{fun}{character. The name of a function by which to combine overlapping
polygons. Currently takes "sum", "first", "last", "min", "max", "count", or
"any". Future versions may include more functions or the ability to pass
custom R/C++ functions. If you need to summarize by a different function,
use \verb{by=} to get a RasterBrick and then \code{\link[raster:stackApply]{raster::stackApply()}} or
\code{\link[raster:calc]{raster::calc()}} to summarize.}
\item{background}{numeric. Value to put in the cells that are not covered by
any of the features of x. Default is NA.}
\item{by}{character. The name of a column in \code{sf} by which to aggregate
layers. If set, fasterize will return a RasterBrick with as many layers
as unique values of the \code{by} column.}
}
\value{
A raster of the same size, extent, resolution and projection as the
provided raster template.
}
\description{
Rasterize set of polygons
Fast sf-to-raster conversion
}
\details{
This is a high-performance replacement for \code{\link[raster:rasterize]{raster::rasterize()}}.
The algorithm is based on the method described in course materials provided
by \href{https://labs.wsu.edu/wayne-cochran/}{Wayne O. Cochran}. The algorithm
is originally attributed to
Wylie et al. (1967) \doi{10.1145/1465611.1465619}.
}
\examples{
library(sf)
library(fasterize)
p1 <- rbind(c(-180,-20), c(-140,55), c(10, 0), c(-140,-60), c(-180,-20))
hole <- rbind(c(-150,-20), c(-100,-10), c(-110,20), c(-150,-20))
p1 <- list(p1, hole)
p2 <- list(rbind(c(-10,0), c(140,60), c(160,0), c(140,-55), c(-10,0)))
p3 <- list(rbind(c(-125,0), c(0,60), c(40,5), c(15,-45), c(-125,0)))
pols <- st_sf(value = rep(1,3),
geometry = st_sfc(lapply(list(p1, p2, p3), st_polygon)))
r <- raster(pols, res = 1)
r <- fasterize(pols, r, field = "value", fun="sum")
plot(r)
}
\references{
Wylie, C., Romney, G., Evans, D., & Erdahl, A. (1967).
Half-tone perspective drawings by computer. Proceedings of the November
14-16, 1967, Fall Joint Computer Conference. AFIPS '67 (Fall).
\doi{10.1145/1465611.1465619}
}
|
\name{itis_taxrank}
\alias{itis_taxrank}
\title{Retrieve taxonomic rank name from given TSN.}
\usage{
itis_taxrank(query = NULL, ...)
}
\arguments{
\item{query}{TSN for a taxonomic group (numeric). If
query is left as default (NULL), you get all possible
rank names, and their TSN's (using function
\code{\link{getranknames}}. There is slightly different
terminology for Monera vs. Plantae vs. Fungi vs. Animalia
vs. Chromista, so there are separate terminologies for
each group.}
\item{...}{Further arguments passed on to
\code{\link{gettaxonomicranknamefromtsn}}}
}
\value{
Taxonomic rank names or data.frame of all ranks.
}
\description{
Retrieve taxonomic rank name from given TSN.
}
\details{
You can print messages by setting verbose=FALSE.
}
\examples{
\dontrun{
# All ranks
itis_taxrank()
# A single TSN
itis_taxrank(query=202385)
# without message
itis_taxrank(query=202385, verbose=FALSE)
# Many TSN's
itis_taxrank(query=c(202385,183833,180543))
}
}
| /man/itis_taxrank.Rd | permissive | dlebauer/taxize_ | R | false | false | 982 | rd | \name{itis_taxrank}
\alias{itis_taxrank}
\title{Retrieve taxonomic rank name from given TSN.}
\usage{
itis_taxrank(query = NULL, ...)
}
\arguments{
\item{query}{TSN for a taxonomic group (numeric). If
query is left as default (NULL), you get all possible
rank names, and their TSN's (using function
\code{\link{getranknames}}. There is slightly different
terminology for Monera vs. Plantae vs. Fungi vs. Animalia
vs. Chromista, so there are separate terminologies for
each group.}
\item{...}{Further arguments passed on to
\code{\link{gettaxonomicranknamefromtsn}}}
}
\value{
Taxonomic rank names or data.frame of all ranks.
}
\description{
Retrieve taxonomic rank name from given TSN.
}
\details{
You can print messages by setting verbose=FALSE.
}
\examples{
\dontrun{
# All ranks
itis_taxrank()
# A single TSN
itis_taxrank(query=202385)
# without message
itis_taxrank(query=202385, verbose=FALSE)
# Many TSN's
itis_taxrank(query=c(202385,183833,180543))
}
}
|
library(datasets)
####### data sets ########
cntPerClass_ArticialData <- 100
sdev <- 1
createData2Clusters <- function(mean1=2, mean2=5, sd=sdev)
{
set.seed(123) # for reproducibility
cnt <- cntPerClass_ArticialData
c1_x1=rnorm(n=cnt, mean = mean1, sd=sd)
c1_x2=rnorm(n=cnt, mean = mean1, sd=sd)
c2_x1=rnorm(n=cnt, mean = mean2, sd=sd)
c2_x2=rnorm(n=cnt, mean = mean2, sd=sd)
x1 <- c(c1_x1,c2_x1)
x2 <- c(c1_x2,c2_x2)
dat <- data.frame(x1=x1, x2=x2, class = as.factor( c( rep(1,length(c1_x1)), rep(2, length(c2_x1)))) )
return(dat)
}
createDataXOR <- function(mean1=2, mean2=6,sd=sdev)
{
set.seed(123) # for reproducibility
#class 1
cnt <- cntPerClass_ArticialData
cluster1_x1=rnorm(n=cnt, mean = mean1, sd=sd)
cluster1_x2=rnorm(n=cnt, mean = mean2, sd=sd)
cluster2_x1=rnorm(n=cnt, mean = mean2, sd=sd)
cluster2_x2=rnorm(n=cnt, mean = mean1, sd=sd)
x1 <- c(cluster1_x1,cluster2_x1)
x2 <- c(cluster1_x2,cluster2_x2)
#class 2
clusters_cl2 <- createData2Clusters(mean1, mean2)
clusters_cl2$class <- rep(1, length(clusters_cl2$x1))
dat <- data.frame(x1=x1, x2=x2, class = rep(2,length(x1)) )
dat <- rbind(dat, clusters_cl2)
dat$class <- as.factor(dat$class)
return(dat)
}
createDataCircle <- function(sd = sdev)
{
set.seed(123) # for reproducibility
cnt <- cntPerClass_ArticialData
c1_x1=rnorm(n=cnt, mean = 0)
c1_x2=rnorm(n=cnt, mean = 0)
# circle x^2 + y^2 = r^2
circle=seq(from=0, to=4*pi, 0.2)
c2_x1 <- rep(0, length(circle))
c2_x2 <- rep(0, length(circle))
radius <- 4
for(i in 1:length(circle))
{
deg <- circle[i]
noisex1 = rnorm(n=1, mean = 0, sd = sd )
c2_x1[i] <-radius * cos(deg) + noisex1
noisex2 = rnorm(n=1, mean = 0, sd = sd )
c2_x2[i] <-radius * sin(deg) + noisex2
}
x1 <- c(c1_x1,c2_x1)
x2 <- c(c1_x2,c2_x2)
dat <- data.frame(x1=x1, x2=x2, class = as.factor(c( rep(1,length(c1_x1)), rep(2, length(c2_x1)))) )
return(dat)
}
twoClusters <- createData2Clusters()
XOR <- createDataXOR()
circle <- createDataCircle()
# scale one dimension, to see effects of not scaling the data
twoClusters_stretched <- twoClusters
twoClusters_stretched$x2 <- twoClusters$x2 * 100
XOR_stretched <- XOR
XOR_stretched$x2 <- XOR$x2 * 100
circle_stretched <- circle
circle_stretched$x2 <- circle$x2 * 100
#load red wine data from UCI ML repository (3 classes)
wine_red <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data",
header = FALSE, sep = ",")
names(wine_red) <- c("class","Alcohol","Malic acid","Ash","Alcalinity of ash","Magnesium","Total phenols","Flavanoids","Nonflavanoid phenols","Proanthocyanins","Color intensity","Hue","OD280/OD315","Proline")
#load wine data from UCI ML repository
wine_white <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv",
header = TRUE, sep = ";")
wine_white <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv",
header = TRUE, sep = ";")
glass <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/glass/glass.data",
header = FALSE, sep = ",")
glass <- glass[,-1] # remove id
names(glass) <- c("RI", "Na", "Mg", "Al", "Si", "K", "Ca", "Ba", "Fe", "class")
wifi <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/00422/wifi_localization.txt",
header = FALSE, sep = "\t")
# write own data for test... write.csv(iris, "iris.csv", quote=FALSE, row.names=FALSE)
loaded_CSV_file <- NULL
| /datasets.R | no_license | ml-and-vis/EduML | R | false | false | 3,811 | r | library(datasets)
####### data sets ########
cntPerClass_ArticialData <- 100
sdev <- 1
createData2Clusters <- function(mean1=2, mean2=5, sd=sdev)
{
set.seed(123) # for reproducibility
cnt <- cntPerClass_ArticialData
c1_x1=rnorm(n=cnt, mean = mean1, sd=sd)
c1_x2=rnorm(n=cnt, mean = mean1, sd=sd)
c2_x1=rnorm(n=cnt, mean = mean2, sd=sd)
c2_x2=rnorm(n=cnt, mean = mean2, sd=sd)
x1 <- c(c1_x1,c2_x1)
x2 <- c(c1_x2,c2_x2)
dat <- data.frame(x1=x1, x2=x2, class = as.factor( c( rep(1,length(c1_x1)), rep(2, length(c2_x1)))) )
return(dat)
}
createDataXOR <- function(mean1=2, mean2=6,sd=sdev)
{
set.seed(123) # for reproducibility
#class 1
cnt <- cntPerClass_ArticialData
cluster1_x1=rnorm(n=cnt, mean = mean1, sd=sd)
cluster1_x2=rnorm(n=cnt, mean = mean2, sd=sd)
cluster2_x1=rnorm(n=cnt, mean = mean2, sd=sd)
cluster2_x2=rnorm(n=cnt, mean = mean1, sd=sd)
x1 <- c(cluster1_x1,cluster2_x1)
x2 <- c(cluster1_x2,cluster2_x2)
#class 2
clusters_cl2 <- createData2Clusters(mean1, mean2)
clusters_cl2$class <- rep(1, length(clusters_cl2$x1))
dat <- data.frame(x1=x1, x2=x2, class = rep(2,length(x1)) )
dat <- rbind(dat, clusters_cl2)
dat$class <- as.factor(dat$class)
return(dat)
}
createDataCircle <- function(sd = sdev)
{
set.seed(123) # for reproducibility
cnt <- cntPerClass_ArticialData
c1_x1=rnorm(n=cnt, mean = 0)
c1_x2=rnorm(n=cnt, mean = 0)
# circle x^2 + y^2 = r^2
circle=seq(from=0, to=4*pi, 0.2)
c2_x1 <- rep(0, length(circle))
c2_x2 <- rep(0, length(circle))
radius <- 4
for(i in 1:length(circle))
{
deg <- circle[i]
noisex1 = rnorm(n=1, mean = 0, sd = sd )
c2_x1[i] <-radius * cos(deg) + noisex1
noisex2 = rnorm(n=1, mean = 0, sd = sd )
c2_x2[i] <-radius * sin(deg) + noisex2
}
x1 <- c(c1_x1,c2_x1)
x2 <- c(c1_x2,c2_x2)
dat <- data.frame(x1=x1, x2=x2, class = as.factor(c( rep(1,length(c1_x1)), rep(2, length(c2_x1)))) )
return(dat)
}
twoClusters <- createData2Clusters()
XOR <- createDataXOR()
circle <- createDataCircle()
# scale one dimension, to see effects of not scaling the data
twoClusters_stretched <- twoClusters
twoClusters_stretched$x2 <- twoClusters$x2 * 100
XOR_stretched <- XOR
XOR_stretched$x2 <- XOR$x2 * 100
circle_stretched <- circle
circle_stretched$x2 <- circle$x2 * 100
#load red wine data from UCI ML repository (3 classes)
wine_red <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data",
header = FALSE, sep = ",")
names(wine_red) <- c("class","Alcohol","Malic acid","Ash","Alcalinity of ash","Magnesium","Total phenols","Flavanoids","Nonflavanoid phenols","Proanthocyanins","Color intensity","Hue","OD280/OD315","Proline")
#load wine data from UCI ML repository
wine_white <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv",
header = TRUE, sep = ";")
wine_white <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv",
header = TRUE, sep = ";")
glass <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/glass/glass.data",
header = FALSE, sep = ",")
glass <- glass[,-1] # remove id
names(glass) <- c("RI", "Na", "Mg", "Al", "Si", "K", "Ca", "Ba", "Fe", "class")
wifi <- read.csv("http://archive.ics.uci.edu/ml/machine-learning-databases/00422/wifi_localization.txt",
header = FALSE, sep = "\t")
# write own data for test... write.csv(iris, "iris.csv", quote=FALSE, row.names=FALSE)
loaded_CSV_file <- NULL
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/latex_print.R
\name{knit_print.tex}
\alias{knit_print.tex}
\alias{knit_print.matrix}
\title{Print tex or matrix class as latex}
\usage{
\method{knit_print}{tex}(x, inline = FALSE, ...)
\method{knit_print}{matrix}(x, inline = FALSE, ...)
}
\arguments{
\item{x}{`tex` or `matrix` to be printed}
\item{inline}{Choose between inline versus in-chunk. The default is set to be `inline = FALSE`, in-chunk.}
\item{...}{Additional arguments passed to the S3 method.}
}
\description{
`knitr_print()` will print an object with math form in the r markdown chunk or inline. It can be an tex or a matrix. In the chunk, `results = 'asis'` option should be assigned to that chunk.
Printing matrix becomes more compact than before. It will be printed math form in the inline, i.e. `r matrix`. Here, the function does not have to be written.
If in-chunk option is choosed, normal matrix form in R console will be printed.
}
\examples{
A <- matrix(1:9, nrow = 3)
library(knitr) # to use knit_print() function directly, knitr package needed
knit_print(as_tex(A))
knit_print(as_tex(A), inline = TRUE)
knit_print(A)
knit_print(A, inline = TRUE)
## In case of matrix, $`r A`$ or $$`r A`$$ works.
## vignette will provide the details.
}
\seealso{
\code{\link{bmatrix}} Printing matrix latex form by using the function
}
| /man/knit_print.Rd | permissive | ygeunkim/rmdtool | R | false | true | 1,377 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/latex_print.R
\name{knit_print.tex}
\alias{knit_print.tex}
\alias{knit_print.matrix}
\title{Print tex or matrix class as latex}
\usage{
\method{knit_print}{tex}(x, inline = FALSE, ...)
\method{knit_print}{matrix}(x, inline = FALSE, ...)
}
\arguments{
\item{x}{`tex` or `matrix` to be printed}
\item{inline}{Choose between inline versus in-chunk. The default is set to be `inline = FALSE`, in-chunk.}
\item{...}{Additional arguments passed to the S3 method.}
}
\description{
`knitr_print()` will print an object with math form in the r markdown chunk or inline. It can be an tex or a matrix. In the chunk, `results = 'asis'` option should be assigned to that chunk.
Printing matrix becomes more compact than before. It will be printed math form in the inline, i.e. `r matrix`. Here, the function does not have to be written.
If in-chunk option is choosed, normal matrix form in R console will be printed.
}
\examples{
A <- matrix(1:9, nrow = 3)
library(knitr) # to use knit_print() function directly, knitr package needed
knit_print(as_tex(A))
knit_print(as_tex(A), inline = TRUE)
knit_print(A)
knit_print(A, inline = TRUE)
## In case of matrix, $`r A`$ or $$`r A`$$ works.
## vignette will provide the details.
}
\seealso{
\code{\link{bmatrix}} Printing matrix latex form by using the function
}
|
Calc_Kmeans <-
function(n_x, Kmeans_Config, Data_Geostat, Data_Extrap){
old.options <- options()
options( "warn" = -1 )
on.exit( options(old.options) )
if( paste0("Kmeans.RData") %in% list.files(getwd()) ){
load( file=paste(DateFile,"Kmeans.RData",sep=""))
}else{
Kmeans = list( "tot.withinss"=Inf )
for(i in 1:Kmeans_Config[["nstart"]]){
if(Kmeans_Config[["Locs"]]=="Samples"){
Tmp = kmeans( x=Data_Geostat[,c('E_km','N_km')], centers=n_x, iter.max=Kmeans_Config[["iter.max"]], nstart=1, trace=0)
}
if(Kmeans_Config[["Locs"]]=="Domain"){
Tmp = kmeans( x=Data_Extrap[,c('E_km','N_km')], centers=n_x, iter.max=Kmeans_Config[["iter.max"]], nstart=1, trace=0) # K$tot.withinss
}
print( paste0('Num=',i,' Current_Best=',round(Kmeans$tot.withinss,1),' New=',round(Tmp$tot.withinss,1)) )#,' Time=',round(Time,4)) )
if( Tmp$tot.withinss < Kmeans$tot.withinss ){
Kmeans = Tmp
}
}
}
return( Kmeans )
}
| /R/Calc_Kmeans.R | no_license | James-Thorson/spatial_condition_factor | R | false | false | 1,000 | r | Calc_Kmeans <-
function(n_x, Kmeans_Config, Data_Geostat, Data_Extrap){
old.options <- options()
options( "warn" = -1 )
on.exit( options(old.options) )
if( paste0("Kmeans.RData") %in% list.files(getwd()) ){
load( file=paste(DateFile,"Kmeans.RData",sep=""))
}else{
Kmeans = list( "tot.withinss"=Inf )
for(i in 1:Kmeans_Config[["nstart"]]){
if(Kmeans_Config[["Locs"]]=="Samples"){
Tmp = kmeans( x=Data_Geostat[,c('E_km','N_km')], centers=n_x, iter.max=Kmeans_Config[["iter.max"]], nstart=1, trace=0)
}
if(Kmeans_Config[["Locs"]]=="Domain"){
Tmp = kmeans( x=Data_Extrap[,c('E_km','N_km')], centers=n_x, iter.max=Kmeans_Config[["iter.max"]], nstart=1, trace=0) # K$tot.withinss
}
print( paste0('Num=',i,' Current_Best=',round(Kmeans$tot.withinss,1),' New=',round(Tmp$tot.withinss,1)) )#,' Time=',round(Time,4)) )
if( Tmp$tot.withinss < Kmeans$tot.withinss ){
Kmeans = Tmp
}
}
}
return( Kmeans )
}
|
library(shiny)
# Define UI
ui = (fluidPage(
# Numeric input
numericInput("num", label = h3("Insert a number and you get its squared value"), value = 2),
hr(),
fluidRow(column(3, verbatimTextOutput("value")))
))
# Define server logic
server = (function(input, output) {
output$value <- renderPrint({
(input$num)^2 })
})
# Return a Shiny app object
shinyApp(ui = ui, server = server) | /app.R | no_license | Novopino/Developing-data-products | R | false | false | 435 | r | library(shiny)
# Define UI
ui = (fluidPage(
# Numeric input
numericInput("num", label = h3("Insert a number and you get its squared value"), value = 2),
hr(),
fluidRow(column(3, verbatimTextOutput("value")))
))
# Define server logic
server = (function(input, output) {
output$value <- renderPrint({
(input$num)^2 })
})
# Return a Shiny app object
shinyApp(ui = ui, server = server) |
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/compute_functions.R
\name{instanceGroupManagers.update}
\alias{instanceGroupManagers.update}
\title{Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is updated even if the instances in the group have not yet been updated. You must separately verify the status of the individual instances with the listmanagedinstances method.}
\usage{
instanceGroupManagers.update(InstanceGroupManager, project, zone,
instanceGroupManager, requestId = NULL)
}
\arguments{
\item{InstanceGroupManager}{The \link{InstanceGroupManager} object to pass to this method}
\item{project}{Project ID for this request}
\item{zone}{The name of the zone where you want to create the managed instance group}
\item{instanceGroupManager}{The name of the instance group manager}
\item{requestId}{begin_interface: MixerMutationRequestBuilder Request ID to support idempotency}
}
\description{
Autogenerated via \code{\link[googleAuthR]{gar_create_api_skeleton}}
}
\details{
Authentication scopes used by this function are:
\itemize{
\item https://www.googleapis.com/auth/cloud-platform
\item https://www.googleapis.com/auth/compute
}
Set \code{options(googleAuthR.scopes.selected = c(https://www.googleapis.com/auth/cloud-platform, https://www.googleapis.com/auth/compute)}
Then run \code{googleAuthR::gar_auth()} to authenticate.
See \code{\link[googleAuthR]{gar_auth}} for details.
}
\seealso{
\href{https://developers.google.com/compute/docs/reference/latest/}{Google Documentation}
Other InstanceGroupManager functions: \code{\link{InstanceGroupManager}},
\code{\link{instanceGroupManagers.insert}},
\code{\link{instanceGroupManagers.patch}},
\code{\link{regionInstanceGroupManagers.insert}},
\code{\link{regionInstanceGroupManagers.patch}},
\code{\link{regionInstanceGroupManagers.update}}
}
| /googlecomputealpha.auto/man/instanceGroupManagers.update.Rd | permissive | GVersteeg/autoGoogleAPI | R | false | true | 1,946 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/compute_functions.R
\name{instanceGroupManagers.update}
\alias{instanceGroupManagers.update}
\title{Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is updated even if the instances in the group have not yet been updated. You must separately verify the status of the individual instances with the listmanagedinstances method.}
\usage{
instanceGroupManagers.update(InstanceGroupManager, project, zone,
instanceGroupManager, requestId = NULL)
}
\arguments{
\item{InstanceGroupManager}{The \link{InstanceGroupManager} object to pass to this method}
\item{project}{Project ID for this request}
\item{zone}{The name of the zone where you want to create the managed instance group}
\item{instanceGroupManager}{The name of the instance group manager}
\item{requestId}{begin_interface: MixerMutationRequestBuilder Request ID to support idempotency}
}
\description{
Autogenerated via \code{\link[googleAuthR]{gar_create_api_skeleton}}
}
\details{
Authentication scopes used by this function are:
\itemize{
\item https://www.googleapis.com/auth/cloud-platform
\item https://www.googleapis.com/auth/compute
}
Set \code{options(googleAuthR.scopes.selected = c(https://www.googleapis.com/auth/cloud-platform, https://www.googleapis.com/auth/compute)}
Then run \code{googleAuthR::gar_auth()} to authenticate.
See \code{\link[googleAuthR]{gar_auth}} for details.
}
\seealso{
\href{https://developers.google.com/compute/docs/reference/latest/}{Google Documentation}
Other InstanceGroupManager functions: \code{\link{InstanceGroupManager}},
\code{\link{instanceGroupManagers.insert}},
\code{\link{instanceGroupManagers.patch}},
\code{\link{regionInstanceGroupManagers.insert}},
\code{\link{regionInstanceGroupManagers.patch}},
\code{\link{regionInstanceGroupManagers.update}}
}
|
# Data cleaning for health app
# Aug 2021
library(tidyverse)
library(janitor)
library(here)
# Read in area code and local authority name detail
area_names <- read_csv(here("data/clean_data/council codes.csv")) %>%
clean_names() %>%
rename(area_code = ca)
# Scottish Health Survey Overview -----------------------------------------
scotland_health_survey <- read_csv(here("data/raw_data/scotland_health_survey.csv")) %>%
clean_names()
# Filter health indicators for those related to activity
scotland_health_survey_clean <- scotland_health_survey %>%
filter(scottish_health_survey_indicator %in% c(
"Any cardiovascular condition: Has a cardiovascular condition",
"Any cardiovascular condition: No cardiovascular condition",
"Life satisfaction: Above the mode (9 to 10-Extremely satisfied)",
"Life satisfaction: Below the mode (0-Extremely dissatisfied to 7)",
"Life satisfaction: Mode (8)",
"Obesity: Not obese",
"Obesity: Obese",
"Overweight: Not overweight or obese",
"Overweight: Overweight (including obese)",
"Overweight: Overweight (including obese)",
"Summary activity levels: Low activity",
"Summary activity levels: Meets recommendations",
"Summary activity levels: Some activity",
"Summary activity levels: Very low activity"),
measurement == "Percent")
scotland_health_survey_clean <- scotland_health_survey_clean %>%
rename(year = date_code,
percentage = value,
area_code = feature_code) %>%
select(area_code, year, scottish_health_survey_indicator, sex, percentage) %>%
arrange(year, scottish_health_survey_indicator, sex)
write_csv(scotland_health_survey_clean,
here("data/clean_data/scotland_health_survey_clean.csv"))
# Greenspace -------------------------------------------------------------
greenspace_clean <- read_csv(here("data/raw_data/greenspace.csv")) %>%
clean_names() %>%
filter(measurement == "Percent") %>%
rename("value_percent" = "value",
"area_code" = "feature_code") %>%
select(-"measurement", -"units") %>%
filter(!str_detect(area_code, pattern = "S08")) %>%
replace_na(list(ca_name = "Scotland"))
# Add council names to greenspace file
greenspace_council_names <- area_names %>%
select(area_code, ca_name) %>%
distinct() %>%
right_join(greenspace_clean, by = "area_code")
write_csv(greenspace_council_names,
here("data/clean_data/greenspace_council_names.csv"))
# Healthy life expectancy -------------------------------------------------
healthy_life_expectancy_clean <- read_csv(here("data/raw_data/healthy_life_expectancy.csv")) %>%
clean_names() %>%
filter(measurement == "Count",
date_code == "2016-2018") %>%
rename("years_of_quality_life" = "value",
"area_code" = "feature_code") %>%
select(-"measurement", -"units") %>%
filter(!str_detect(area_code, pattern = "S08")) %>%
replace_na(list(ca_name = "Scotland"))
write_csv(healthy_life_expectancy_clean,
here("data/clean_data/healthy_life_expectancy_clean.csv"))
# Life expectancy -------------------------------------------------------
life_expectancy_clean <- read_csv(here("data/raw_data/life_expectancy.csv")) %>%
clean_names() %>%
filter(measurement == "Count") %>%
rename("years_to_live" = "value",
"area_code" = "feature_code") %>%
select(-"measurement", -"units") %>%
filter(!str_detect(area_code, pattern = "S08")) %>%
replace_na(list(ca_name = "Scotland"))
write_csv(life_expectancy_clean,
here("data/clean_data/life_expectancy_clean.csv"))
# Health board codes ------------------------------------------------------
council_codes <- area_names %>%
select(area_code, hb_name)
health_board_codes <- area_names %>%
select(hb, hb_name) %>%
rename(area_code = hb)
health_board_names <- bind_rows(council_codes, health_board_codes) %>%
distinct()
write_csv(health_board_names, here("data/clean_data/health_board_names.csv"))
# Scottish Health Survey by Local Area ------------------------------------
scotland_health_survey_local <- read_csv(here("data/raw_data/scotland health survey local level.csv")) %>%
clean_names()
scotland_health_survey_local <- scotland_health_survey_local %>%
rename(area_code = feature_code)
scotland_health_survey_local <- area_names %>%
select(area_code, ca_name) %>%
distinct() %>%
right_join(scotland_health_survey_local, by = "area_code")
# Select the same health indicators as for the scottish health survey scotland
scotland_health_survey_local_clean <- scotland_health_survey_local %>%
filter(scottish_health_survey_indicator %in% c(
"Any cardiovascular condition: Has a cardiovascular condition",
"Any cardiovascular condition: No cardiovascular condition",
"Life satisfaction: Above the mode (9 to 10-Extremely satisfied)",
"Life satisfaction: Below the mode (0-Extremely dissatisfied to 7)",
"Life satisfaction: Mode (8)",
"Obesity: Not obese",
"Obesity: Obese",
"Overweight: Not overweight or obese",
"Overweight: Overweight (including obese)",
"Overweight: Overweight (including obese)",
"Summary activity levels: Low activity",
"Summary activity levels: Meets recommendations",
"Summary activity levels: Some activity",
"Summary activity levels: Very low activity"),
measurement == "Percent",
date_code == "2016-2019") %>%
filter(!str_detect(area_code, pattern = "S08")) %>%
replace_na(list(ca_name = "Scotland"))
scotland_health_survey_local_clean <- scotland_health_survey_local_clean %>%
rename(year = date_code,
percentage = value) %>%
select(area_code, ca_name, year, scottish_health_survey_indicator,
sex, percentage) %>%
arrange(area_code, year, scottish_health_survey_indicator, sex)
write_csv(scotland_health_survey_local_clean,
here("data/clean_data/scotland_health_survey_local_clean.csv"))
# Summary statistics ------------------------------------------------------
# Scottish Health Survey by Local Area
raw_scotland_health_survey_local <- read_csv(here(
"data/raw_data/scotland health survey local level.csv")) %>%
clean_names()
summary_stat_scotland_health_2016_2019 <- raw_scotland_health_survey_local %>%
filter(
date_code == "2016-2019",
str_detect(feature_code, "^S92"),
scottish_health_survey_indicator %in% c(
"Any cardiovascular condition: Has a cardiovascular condition",
"Any cardiovascular condition: No cardiovascular condition",
"Life satisfaction: Above the mode (9 to 10-Extremely satisfied)",
"Life satisfaction: Below the mode (0-Extremely dissatisfied to 7)",
"Life satisfaction: Mode (8)", "Obesity: Not obese", "Obesity: Obese",
"Overweight: Not overweight or obese",
"Overweight: Overweight (including obese)",
"Overweight: Overweight (including obese)",
"Summary activity levels: Low activity",
"Summary activity levels: Meets recommendations",
"Summary activity levels: Some activity",
"Summary activity levels: Very low activity"),
measurement == "Percent" |
measurement == "95% Lower Confidence Limit" |
measurement == "95% Upper Confidence Limit") %>%
pivot_wider(names_from = measurement, values_from = value)
summary_stat_scotland_health_2016_2019 <- summary_stat_scotland_health_2016_2019 %>%
rename(year = date_code) %>%
select(scottish_health_survey_indicator, sex,
"Percent", "95% Lower Confidence Limit", "95% Upper Confidence Limit")
write_csv(summary_stat_scotland_health_2016_2019,
here("data/clean_data/summary_stat_scotland_health_2016_2019.csv"))
# Statistics table for green space tab
filtered_scotland_health_survey_local_clean <- scotland_health_survey_local_clean %>%
filter(str_detect(area_code, "^S120"),
sex == "All",
scottish_health_survey_indicator %in% c(
"Any cardiovascular condition: Has a cardiovascular condition",
"Life satisfaction: Below the mode (0-Extremely dissatisfied to 7)",
"Obesity: Obese",
"Overweight: Overweight (including obese)",
"Summary activity levels: Low activity",
"Summary activity levels: Very low activity"))
filtered_greenspace <- greenspace_council_names %>%
filter(
str_detect(area_code, "^S120"),
date_code >= 2016,
distance_to_nearest_green_or_blue_space == "A 5 minute walk or less",
age == "All",
gender == "All",
urban_rural_classification == "All",
simd_quintiles == "All",
type_of_tenure == "All",
household_type == "All",
ethnicity == "All") %>%
group_by(
area_code, ca_name, age
) %>%
summarise(mean_percent = mean(value_percent)) %>%
ungroup()
# Combine data together for green space summary table
local_greenspace <- filtered_scotland_health_survey_local_clean %>%
rename(indicator_percentage = percentage) %>%
left_join(filtered_greenspace, by = "area_code") %>%
select(-ca_name.x) %>%
rename(ca_name = ca_name.y) %>%
select(ca_name, scottish_health_survey_indicator, indicator_percentage,
mean_percent)
write_csv(local_greenspace, here("data/clean_data/local_greenspace.csv"))
| /group_health_project/scripts/1_cleaning_scripts.R | permissive | axbraae/shiny_apps | R | false | false | 9,301 | r | # Data cleaning for health app
# Aug 2021
library(tidyverse)
library(janitor)
library(here)
# Read in area code and local authority name detail
area_names <- read_csv(here("data/clean_data/council codes.csv")) %>%
clean_names() %>%
rename(area_code = ca)
# Scottish Health Survey Overview -----------------------------------------
scotland_health_survey <- read_csv(here("data/raw_data/scotland_health_survey.csv")) %>%
clean_names()
# Filter health indicators for those related to activity
scotland_health_survey_clean <- scotland_health_survey %>%
filter(scottish_health_survey_indicator %in% c(
"Any cardiovascular condition: Has a cardiovascular condition",
"Any cardiovascular condition: No cardiovascular condition",
"Life satisfaction: Above the mode (9 to 10-Extremely satisfied)",
"Life satisfaction: Below the mode (0-Extremely dissatisfied to 7)",
"Life satisfaction: Mode (8)",
"Obesity: Not obese",
"Obesity: Obese",
"Overweight: Not overweight or obese",
"Overweight: Overweight (including obese)",
"Overweight: Overweight (including obese)",
"Summary activity levels: Low activity",
"Summary activity levels: Meets recommendations",
"Summary activity levels: Some activity",
"Summary activity levels: Very low activity"),
measurement == "Percent")
scotland_health_survey_clean <- scotland_health_survey_clean %>%
rename(year = date_code,
percentage = value,
area_code = feature_code) %>%
select(area_code, year, scottish_health_survey_indicator, sex, percentage) %>%
arrange(year, scottish_health_survey_indicator, sex)
write_csv(scotland_health_survey_clean,
here("data/clean_data/scotland_health_survey_clean.csv"))
# Greenspace -------------------------------------------------------------
greenspace_clean <- read_csv(here("data/raw_data/greenspace.csv")) %>%
clean_names() %>%
filter(measurement == "Percent") %>%
rename("value_percent" = "value",
"area_code" = "feature_code") %>%
select(-"measurement", -"units") %>%
filter(!str_detect(area_code, pattern = "S08")) %>%
replace_na(list(ca_name = "Scotland"))
# Add council names to greenspace file
greenspace_council_names <- area_names %>%
select(area_code, ca_name) %>%
distinct() %>%
right_join(greenspace_clean, by = "area_code")
write_csv(greenspace_council_names,
here("data/clean_data/greenspace_council_names.csv"))
# Healthy life expectancy -------------------------------------------------
healthy_life_expectancy_clean <- read_csv(here("data/raw_data/healthy_life_expectancy.csv")) %>%
clean_names() %>%
filter(measurement == "Count",
date_code == "2016-2018") %>%
rename("years_of_quality_life" = "value",
"area_code" = "feature_code") %>%
select(-"measurement", -"units") %>%
filter(!str_detect(area_code, pattern = "S08")) %>%
replace_na(list(ca_name = "Scotland"))
write_csv(healthy_life_expectancy_clean,
here("data/clean_data/healthy_life_expectancy_clean.csv"))
# Life expectancy -------------------------------------------------------
life_expectancy_clean <- read_csv(here("data/raw_data/life_expectancy.csv")) %>%
clean_names() %>%
filter(measurement == "Count") %>%
rename("years_to_live" = "value",
"area_code" = "feature_code") %>%
select(-"measurement", -"units") %>%
filter(!str_detect(area_code, pattern = "S08")) %>%
replace_na(list(ca_name = "Scotland"))
write_csv(life_expectancy_clean,
here("data/clean_data/life_expectancy_clean.csv"))
# Health board codes ------------------------------------------------------
council_codes <- area_names %>%
select(area_code, hb_name)
health_board_codes <- area_names %>%
select(hb, hb_name) %>%
rename(area_code = hb)
health_board_names <- bind_rows(council_codes, health_board_codes) %>%
distinct()
write_csv(health_board_names, here("data/clean_data/health_board_names.csv"))
# Scottish Health Survey by Local Area ------------------------------------
scotland_health_survey_local <- read_csv(here("data/raw_data/scotland health survey local level.csv")) %>%
clean_names()
scotland_health_survey_local <- scotland_health_survey_local %>%
rename(area_code = feature_code)
scotland_health_survey_local <- area_names %>%
select(area_code, ca_name) %>%
distinct() %>%
right_join(scotland_health_survey_local, by = "area_code")
# Select the same health indicators as for the scottish health survey scotland
scotland_health_survey_local_clean <- scotland_health_survey_local %>%
filter(scottish_health_survey_indicator %in% c(
"Any cardiovascular condition: Has a cardiovascular condition",
"Any cardiovascular condition: No cardiovascular condition",
"Life satisfaction: Above the mode (9 to 10-Extremely satisfied)",
"Life satisfaction: Below the mode (0-Extremely dissatisfied to 7)",
"Life satisfaction: Mode (8)",
"Obesity: Not obese",
"Obesity: Obese",
"Overweight: Not overweight or obese",
"Overweight: Overweight (including obese)",
"Overweight: Overweight (including obese)",
"Summary activity levels: Low activity",
"Summary activity levels: Meets recommendations",
"Summary activity levels: Some activity",
"Summary activity levels: Very low activity"),
measurement == "Percent",
date_code == "2016-2019") %>%
filter(!str_detect(area_code, pattern = "S08")) %>%
replace_na(list(ca_name = "Scotland"))
scotland_health_survey_local_clean <- scotland_health_survey_local_clean %>%
rename(year = date_code,
percentage = value) %>%
select(area_code, ca_name, year, scottish_health_survey_indicator,
sex, percentage) %>%
arrange(area_code, year, scottish_health_survey_indicator, sex)
write_csv(scotland_health_survey_local_clean,
here("data/clean_data/scotland_health_survey_local_clean.csv"))
# Summary statistics ------------------------------------------------------
# Scottish Health Survey by Local Area
raw_scotland_health_survey_local <- read_csv(here(
"data/raw_data/scotland health survey local level.csv")) %>%
clean_names()
summary_stat_scotland_health_2016_2019 <- raw_scotland_health_survey_local %>%
filter(
date_code == "2016-2019",
str_detect(feature_code, "^S92"),
scottish_health_survey_indicator %in% c(
"Any cardiovascular condition: Has a cardiovascular condition",
"Any cardiovascular condition: No cardiovascular condition",
"Life satisfaction: Above the mode (9 to 10-Extremely satisfied)",
"Life satisfaction: Below the mode (0-Extremely dissatisfied to 7)",
"Life satisfaction: Mode (8)", "Obesity: Not obese", "Obesity: Obese",
"Overweight: Not overweight or obese",
"Overweight: Overweight (including obese)",
"Overweight: Overweight (including obese)",
"Summary activity levels: Low activity",
"Summary activity levels: Meets recommendations",
"Summary activity levels: Some activity",
"Summary activity levels: Very low activity"),
measurement == "Percent" |
measurement == "95% Lower Confidence Limit" |
measurement == "95% Upper Confidence Limit") %>%
pivot_wider(names_from = measurement, values_from = value)
summary_stat_scotland_health_2016_2019 <- summary_stat_scotland_health_2016_2019 %>%
rename(year = date_code) %>%
select(scottish_health_survey_indicator, sex,
"Percent", "95% Lower Confidence Limit", "95% Upper Confidence Limit")
write_csv(summary_stat_scotland_health_2016_2019,
here("data/clean_data/summary_stat_scotland_health_2016_2019.csv"))
# Statistics table for green space tab
filtered_scotland_health_survey_local_clean <- scotland_health_survey_local_clean %>%
filter(str_detect(area_code, "^S120"),
sex == "All",
scottish_health_survey_indicator %in% c(
"Any cardiovascular condition: Has a cardiovascular condition",
"Life satisfaction: Below the mode (0-Extremely dissatisfied to 7)",
"Obesity: Obese",
"Overweight: Overweight (including obese)",
"Summary activity levels: Low activity",
"Summary activity levels: Very low activity"))
filtered_greenspace <- greenspace_council_names %>%
filter(
str_detect(area_code, "^S120"),
date_code >= 2016,
distance_to_nearest_green_or_blue_space == "A 5 minute walk or less",
age == "All",
gender == "All",
urban_rural_classification == "All",
simd_quintiles == "All",
type_of_tenure == "All",
household_type == "All",
ethnicity == "All") %>%
group_by(
area_code, ca_name, age
) %>%
summarise(mean_percent = mean(value_percent)) %>%
ungroup()
# Combine data together for green space summary table
local_greenspace <- filtered_scotland_health_survey_local_clean %>%
rename(indicator_percentage = percentage) %>%
left_join(filtered_greenspace, by = "area_code") %>%
select(-ca_name.x) %>%
rename(ca_name = ca_name.y) %>%
select(ca_name, scottish_health_survey_indicator, indicator_percentage,
mean_percent)
write_csv(local_greenspace, here("data/clean_data/local_greenspace.csv"))
|
#############################################################################################
# Analysis of Role of Dams on Recorded Dry Season Malaria Incidences in Kasungu ##
#############################################################################################
#################
# Set path name #
#################
pathname <- "C:/GIS Folder/2020/Vector/finalized_data/finalized.shp"
####################
# Read in packages #
####################
library(dplyr)
library(ggplot2)
library(sf)
library(sp)
########################
# Load the Data files #
########################
finalized_data <- st_read(paste0(pathname,"finalized.shp"))
finalized_data$prop_0_5km_2018 <- finalized_data$pop_0_5ksu/finalized_data$X__2018
finalized_data$prop_1km_2018 <- finalized_data$pop_1ksum/finalized_data$X__2018
finalized_data$prop_2km_2018 <- finalized_data$pop_2ksum/finalized_data$X__2018
finalized_data$prop_3km_2018 <- finalized_data$pop_3ksum/finalized_data$X__2018
summary(finalized_data$prop_0_5km_2018)
summary(finalized_data$prop_1km_2018)
summary(finalized_data$prop_2km_2018)
summary(finalized_data$prop_3km_2018)
##############################
# Model Fitting ###
##############################
######
mod.0_5k <- glm(dr_2018~1+prop_0_5km_2018+offset(log(ex_2018)), data=finalized_data, family="poisson")
summary(mod.0_5k) #AIC = 38503
mod.1k <- glm(dr_2018~1+prop_1km_2018+offset(log(ex_2018)), data=finalized_data, family="poisson")
summary(mod.1k) #AIC = 37047
mod.2k <- glm(dr_2018~1+prop_2km_2018+offset(log(ex_2018)), data=finalized_data, family="poisson")
summary(mod.2k) #AIC = 36736
mod.3k <- glm(dr_2018~1+prop_3km_2018+offset(log(ex_2018)), data=finalized_data, family="poisson")
summary(mod.3k) #AIC = 39157
# Lowest AIC found when distance = 2km
exp(coef(mod.2k))
# This tells us that living within 2km increases risk of dry season malaria as there's a significant positive relationship
# with prop of population living within 2km and risk. If all lived within 2km of water, risk of malaria would be 3.19 times
# higher compared to noone living close to water.
exp(confint(mod.2k))
# Confidence interval 3.09 - 3.29
| /kasungu_model_v2.R | no_license | ClintyNkolokosa/Analysis-of-dry-season-malaria-cases-in-Kasungu | R | false | false | 2,265 | r | #############################################################################################
# Analysis of Role of Dams on Recorded Dry Season Malaria Incidences in Kasungu ##
#############################################################################################
#################
# Set path name #
#################
pathname <- "C:/GIS Folder/2020/Vector/finalized_data/finalized.shp"
####################
# Read in packages #
####################
library(dplyr)
library(ggplot2)
library(sf)
library(sp)
########################
# Load the Data files #
########################
finalized_data <- st_read(paste0(pathname,"finalized.shp"))
finalized_data$prop_0_5km_2018 <- finalized_data$pop_0_5ksu/finalized_data$X__2018
finalized_data$prop_1km_2018 <- finalized_data$pop_1ksum/finalized_data$X__2018
finalized_data$prop_2km_2018 <- finalized_data$pop_2ksum/finalized_data$X__2018
finalized_data$prop_3km_2018 <- finalized_data$pop_3ksum/finalized_data$X__2018
summary(finalized_data$prop_0_5km_2018)
summary(finalized_data$prop_1km_2018)
summary(finalized_data$prop_2km_2018)
summary(finalized_data$prop_3km_2018)
##############################
# Model Fitting ###
##############################
######
mod.0_5k <- glm(dr_2018~1+prop_0_5km_2018+offset(log(ex_2018)), data=finalized_data, family="poisson")
summary(mod.0_5k) #AIC = 38503
mod.1k <- glm(dr_2018~1+prop_1km_2018+offset(log(ex_2018)), data=finalized_data, family="poisson")
summary(mod.1k) #AIC = 37047
mod.2k <- glm(dr_2018~1+prop_2km_2018+offset(log(ex_2018)), data=finalized_data, family="poisson")
summary(mod.2k) #AIC = 36736
mod.3k <- glm(dr_2018~1+prop_3km_2018+offset(log(ex_2018)), data=finalized_data, family="poisson")
summary(mod.3k) #AIC = 39157
# Lowest AIC found when distance = 2km
exp(coef(mod.2k))
# This tells us that living within 2km increases risk of dry season malaria as there's a significant positive relationship
# with prop of population living within 2km and risk. If all lived within 2km of water, risk of malaria would be 3.19 times
# higher compared to noone living close to water.
exp(confint(mod.2k))
# Confidence interval 3.09 - 3.29
|
library(Lahman)
### Name: AwardsManagers
### Title: AwardsManagers table
### Aliases: AwardsManagers
### Keywords: datasets
### ** Examples
# Post-season managerial awards
# Number of recipients of each award by year
with(AwardsManagers, table(yearID, awardID))
# 1996 award winners
subset(AwardsManagers, yearID == 1996)
# AL winners of the BBWAA managerial award
subset(AwardsManagers, awardID == "BBWAA Manager of the year" &
lgID == "AL")
# Tony LaRussa's manager of the year awards
subset(AwardsManagers, playerID == "larusto01")
| /data/genthat_extracted_code/Lahman/examples/AwardsManagers.Rd.R | no_license | surayaaramli/typeRrh | R | false | false | 573 | r | library(Lahman)
### Name: AwardsManagers
### Title: AwardsManagers table
### Aliases: AwardsManagers
### Keywords: datasets
### ** Examples
# Post-season managerial awards
# Number of recipients of each award by year
with(AwardsManagers, table(yearID, awardID))
# 1996 award winners
subset(AwardsManagers, yearID == 1996)
# AL winners of the BBWAA managerial award
subset(AwardsManagers, awardID == "BBWAA Manager of the year" &
lgID == "AL")
# Tony LaRussa's manager of the year awards
subset(AwardsManagers, playerID == "larusto01")
|
cdensText = as.matrix(read.table("chernoffDensity.dat",header=TRUE))
cdistText = as.matrix(read.table("chernoffDistribution.dat",header=TRUE))
cquanText = as.matrix(read.table("chernoffQuantiles.dat",header=TRUE))
cquanText = rbind(c(0,-Inf),cquanText,c(1,Inf))
csimsText = as.vector(as.matrix(read.table("chernoff.dat")))
dchernoff = function(x, log = FALSE){
lowerInd = max(which(cdensText[,1] <= x))
upperInd = min(which(cdensText[,1] >= x))
lowerLim = cdensText[lowerInd,2]
upperLim = cdensText[upperInd,2]
weights = c(1,1)/2
a = weights[1]*lowerLim + weights[2]*upperLim
ifelse(log,return(log(a)),return(a))
}
dchernoff = Vectorize(dchernoff)
pchernoff = function(x){
cdist = rbind(c(-Inf,0),cdistText,c(Inf,1))
lowerLim = cdist[max(which(cdist[,1] <= x)),2]
upperLim = cdist[min(which(cdist[,1] >= x)),2]
(lowerLim + upperLim)/2
}
pchernoff = Vectorize(pchernoff)
qchernoff = function(q){
lowerLim = cquanText[max(which(cquanText[,1] <= q)),2]
upperLim = cquanText[min(which(cquanText[,1] >= q)),2]
(lowerLim + upperLim)/2
}
qchernoff = Vectorize(qchernoff)
simulateBrown = function(){
delta = 0.001
ts = seq(-3,3,by=delta)
n = length(ts)
motionRight = cumsum(rnorm(n/2,0,sqrt(delta)))
motionLeft = rev(cumsum(rnorm(n/2,0,sqrt(delta))))
motion = c(motionLeft,0,motionRight)
maxers = -ts^2+motion
maxers[is.na(maxers)] = NaN
maxer = which.max(maxers)
ts[maxer]
}
| /OppgaveR/chernoffsDistribution.R | no_license | JonasMoss/cuberoot | R | false | false | 1,426 | r | cdensText = as.matrix(read.table("chernoffDensity.dat",header=TRUE))
cdistText = as.matrix(read.table("chernoffDistribution.dat",header=TRUE))
cquanText = as.matrix(read.table("chernoffQuantiles.dat",header=TRUE))
cquanText = rbind(c(0,-Inf),cquanText,c(1,Inf))
csimsText = as.vector(as.matrix(read.table("chernoff.dat")))
dchernoff = function(x, log = FALSE){
lowerInd = max(which(cdensText[,1] <= x))
upperInd = min(which(cdensText[,1] >= x))
lowerLim = cdensText[lowerInd,2]
upperLim = cdensText[upperInd,2]
weights = c(1,1)/2
a = weights[1]*lowerLim + weights[2]*upperLim
ifelse(log,return(log(a)),return(a))
}
dchernoff = Vectorize(dchernoff)
pchernoff = function(x){
cdist = rbind(c(-Inf,0),cdistText,c(Inf,1))
lowerLim = cdist[max(which(cdist[,1] <= x)),2]
upperLim = cdist[min(which(cdist[,1] >= x)),2]
(lowerLim + upperLim)/2
}
pchernoff = Vectorize(pchernoff)
qchernoff = function(q){
lowerLim = cquanText[max(which(cquanText[,1] <= q)),2]
upperLim = cquanText[min(which(cquanText[,1] >= q)),2]
(lowerLim + upperLim)/2
}
qchernoff = Vectorize(qchernoff)
simulateBrown = function(){
delta = 0.001
ts = seq(-3,3,by=delta)
n = length(ts)
motionRight = cumsum(rnorm(n/2,0,sqrt(delta)))
motionLeft = rev(cumsum(rnorm(n/2,0,sqrt(delta))))
motion = c(motionLeft,0,motionRight)
maxers = -ts^2+motion
maxers[is.na(maxers)] = NaN
maxer = which.max(maxers)
ts[maxer]
}
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/SelectTypeDistance.R
\name{SelectTypeDistance}
\alias{SelectTypeDistance}
\title{Selekcja obiektów}
\usage{
SelectTypeDistance(data = NULL, latitude = NULL, longtitude = NULL,
name.type = NULL, sel.type = NULL, sel.dist = 60)
}
\arguments{
\item{data}{Obiekt typu data.frame zawierający dane obiektów, w tym
położenie geografincze (tj. szerokość geograficzną - zmienna
\code{latitude} i długość geograficzna - zmienna \code{longtitude})}
\item{latitude}{Wektor wartości typu numeric reprezentujących szerokość
geograficzną wyrażoną w stopniach dziesiętnych, które wraz z
korespondującymi z nimi rekordami zmiennej \code{latitude} dają pełną
infomrację o współrzędnych geograficznych. Może przyjmować wartości
w zakresie od -90 do 90.}
\item{longtitude}{Wektor wartości typu numeric, reprezentujących długość
geograficzną wyrażoną w stopniach dziesiętnych, które wraz z
korespondującymi z nimi rekordami zmiennej \code{longtitude} dają pełną
infomrację o współrzędnych geograficznych. Może przyjmować wartości w
zakresie od -180 do 180.}
\item{name.type}{Nazwa zmiennej w ramce danych \code{data} zawierająca
kategorie typu obiektu. Zmienna typu character.}
\item{sel.type}{Wybrana kategoria typu obiektu (mieszcząca się w zmiennej
\code{name.type}), w oparciu o którą będzie filtrowana ramka danych
\code{data}.}
\item{sel.dist}{Wartość numeryczna (numeric). Kryterium wyboru obiektów
określające maksymalna odległość obiektu (w km) od centrum Krakowa. Domyślnie
wynosi 60km.}
}
\value{
Obiekty typu data.frame.
}
\description{
Pozwala na selekcjonowane obiektów ramki danych w oparciu o kryterium typu
obiektu oraz odległości, która dzieli je od centrum Krakowa (tj. Rynku
Głównego).
}
\examples{
#Wybór z bazy obiektów turystycznych Krakowa wyłącznie muzeów i kościołów
#położonych nie dalej niż 2km od Rynku Głównego
\dontrun{
new.df<-SelectTypeDistance(data = df, latitude = "lat",
longtitude = "lng", name.type = "type",
sel.type = c("Churches", "Museums"), sel.dist = 2)
}
}
| /man/SelectTypeDistance.Rd | no_license | MonikaTT/Zadanie | R | false | true | 2,152 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/SelectTypeDistance.R
\name{SelectTypeDistance}
\alias{SelectTypeDistance}
\title{Selekcja obiektów}
\usage{
SelectTypeDistance(data = NULL, latitude = NULL, longtitude = NULL,
name.type = NULL, sel.type = NULL, sel.dist = 60)
}
\arguments{
\item{data}{Obiekt typu data.frame zawierający dane obiektów, w tym
położenie geografincze (tj. szerokość geograficzną - zmienna
\code{latitude} i długość geograficzna - zmienna \code{longtitude})}
\item{latitude}{Wektor wartości typu numeric reprezentujących szerokość
geograficzną wyrażoną w stopniach dziesiętnych, które wraz z
korespondującymi z nimi rekordami zmiennej \code{latitude} dają pełną
infomrację o współrzędnych geograficznych. Może przyjmować wartości
w zakresie od -90 do 90.}
\item{longtitude}{Wektor wartości typu numeric, reprezentujących długość
geograficzną wyrażoną w stopniach dziesiętnych, które wraz z
korespondującymi z nimi rekordami zmiennej \code{longtitude} dają pełną
infomrację o współrzędnych geograficznych. Może przyjmować wartości w
zakresie od -180 do 180.}
\item{name.type}{Nazwa zmiennej w ramce danych \code{data} zawierająca
kategorie typu obiektu. Zmienna typu character.}
\item{sel.type}{Wybrana kategoria typu obiektu (mieszcząca się w zmiennej
\code{name.type}), w oparciu o którą będzie filtrowana ramka danych
\code{data}.}
\item{sel.dist}{Wartość numeryczna (numeric). Kryterium wyboru obiektów
określające maksymalna odległość obiektu (w km) od centrum Krakowa. Domyślnie
wynosi 60km.}
}
\value{
Obiekty typu data.frame.
}
\description{
Pozwala na selekcjonowane obiektów ramki danych w oparciu o kryterium typu
obiektu oraz odległości, która dzieli je od centrum Krakowa (tj. Rynku
Głównego).
}
\examples{
#Wybór z bazy obiektów turystycznych Krakowa wyłącznie muzeów i kościołów
#położonych nie dalej niż 2km od Rynku Głównego
\dontrun{
new.df<-SelectTypeDistance(data = df, latitude = "lat",
longtitude = "lng", name.type = "type",
sel.type = c("Churches", "Museums"), sel.dist = 2)
}
}
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/regional_table.R
\name{regional_table}
\alias{regional_table}
\title{Make ACS table for a region of towns}
\usage{
regional_table(town_list, name = "Aggregate", town_lookup, state = 9,
table.number, year = 2015)
}
\arguments{
\item{town_list}{A character vector of the names or FIPS codes of towns in the region}
\item{name}{Name of the region. Defaults to "Aggregate"}
\item{town_lookup}{A data.frame or tbl. Must have columns \code{town} and \code{county}, as generated by \code{\link{get_town_names}}}
\item{state}{Either a number corresponding to the state's FIPS code, or a string with the state's two-letter abbreviation or full name. Defaults to 9, FIPS code for Connecticut}
\item{table.number}{String corresponding to an ACS table number; this is case-sensitive}
\item{year}{Endyear of ACS estimates as a four-digit integer}
}
\value{
Returns an \code{\link[acs]{acs-class}} object, as is standard from the \code{acs} package.
}
\description{
Makes ACS table aggregated across a region of towns
}
\examples{
inner_ring <- c("Hamden", "East Haven", "West Haven")
ct_towns <- get_town_names(state = 9)
inner_ring_pops <- regional_table(inner_ring, name = "Inner Ring", ct_towns,
table.number = "B01003")
}
\seealso{
\code{\link{get_town_names}}, which returns a dataframe of towns and countied formatted for \code{town_lookup}
}
| /man/regional_table.Rd | no_license | CT-Data-Haven/acsprofiles | R | false | true | 1,424 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/regional_table.R
\name{regional_table}
\alias{regional_table}
\title{Make ACS table for a region of towns}
\usage{
regional_table(town_list, name = "Aggregate", town_lookup, state = 9,
table.number, year = 2015)
}
\arguments{
\item{town_list}{A character vector of the names or FIPS codes of towns in the region}
\item{name}{Name of the region. Defaults to "Aggregate"}
\item{town_lookup}{A data.frame or tbl. Must have columns \code{town} and \code{county}, as generated by \code{\link{get_town_names}}}
\item{state}{Either a number corresponding to the state's FIPS code, or a string with the state's two-letter abbreviation or full name. Defaults to 9, FIPS code for Connecticut}
\item{table.number}{String corresponding to an ACS table number; this is case-sensitive}
\item{year}{Endyear of ACS estimates as a four-digit integer}
}
\value{
Returns an \code{\link[acs]{acs-class}} object, as is standard from the \code{acs} package.
}
\description{
Makes ACS table aggregated across a region of towns
}
\examples{
inner_ring <- c("Hamden", "East Haven", "West Haven")
ct_towns <- get_town_names(state = 9)
inner_ring_pops <- regional_table(inner_ring, name = "Inner Ring", ct_towns,
table.number = "B01003")
}
\seealso{
\code{\link{get_town_names}}, which returns a dataframe of towns and countied formatted for \code{town_lookup}
}
|
##############################################################################################
#
# R Code to draw graphs in R
# copyright IoT Cloud Research Lab
# Author: iotcloud Benedict Date: 1.6.2020
# Graphs for certain values
#
##############################################################################################
library(dplyr)
library(caret)
library(tidyverse)
library(GGally)
library(corrplot)
### Prepare graphs for prediction accuracy R squared errors
### Step 1: Collect values in the dataset
### LR, LRM, QR, RR, LaR, ER, RF
RsquaredValues <- NULL
RsquaredValues$NO2 <- c(88.21, 88.21, 84.16, 92.66, 92.25, 88.25, 99.81)
RsquaredValues$SO2 <- c(51.66, 51.66, 36.31, 56.89, 55.8, 51.72, 99.48)
corrVal<-cor(mtcars)
corrplot(corrVal, method="circle")
cor(RsquaredValues, method = "pearson", use = "complete.obs")
ggcorr(RsquaredValues, method = c("everything", "pearson"))
maxNO2 <- max(Rsquared_NO2)
minNO2 <- min(Rsquared_NO2)
incrementNO2 <- (as.numeric(maxNO2) - as.numeric(minNO2)) / 4
plotR2 <- ggplot() +
geom_line(data = Rsquared_NO2, aes(x = Rsquared_NO2, y = SO2), color = "#993333") +
xlab('Latitude+Longitude ') +
ylab('Prediction Accuracy -- RSquared NO2 ') +
# add more ticks on the y-axis
scale_y_discrete(breaks=seq(maxNO2,minNO2,by=incrementSO2)) +
theme(
legend.text = element_text(face = "italic",colour="steelblue4",
family = "Helvetica", size = rel(1)),
axis.line = element_line(colour = "darkblue",
size = 1, linetype = "solid"),
legend.position="right",
panel.grid.major = element_line(colour="grey"),
panel.grid.minor = element_line(colour="red"),
legend.key = element_rect(fill = "whitesmoke"),
legend.title = element_text(colour = "steelblue",size = rel(1.5),
family = "Helvetica")
)
### Print pdf for SO2
pdf("/home/iotcloud/shaju/workspace/Eclipseworkspace/EnergyAnalyzer/tests/mobility/Results/PredAccuracy.pdf",width=8,height=5)
print(plotR2)
dev.off() | /mobility/RProgram/ResultGraphs.R | no_license | shajulin/shared-mobility | R | false | false | 1,981 | r | ##############################################################################################
#
# R Code to draw graphs in R
# copyright IoT Cloud Research Lab
# Author: iotcloud Benedict Date: 1.6.2020
# Graphs for certain values
#
##############################################################################################
library(dplyr)
library(caret)
library(tidyverse)
library(GGally)
library(corrplot)
### Prepare graphs for prediction accuracy R squared errors
### Step 1: Collect values in the dataset
### LR, LRM, QR, RR, LaR, ER, RF
RsquaredValues <- NULL
RsquaredValues$NO2 <- c(88.21, 88.21, 84.16, 92.66, 92.25, 88.25, 99.81)
RsquaredValues$SO2 <- c(51.66, 51.66, 36.31, 56.89, 55.8, 51.72, 99.48)
corrVal<-cor(mtcars)
corrplot(corrVal, method="circle")
cor(RsquaredValues, method = "pearson", use = "complete.obs")
ggcorr(RsquaredValues, method = c("everything", "pearson"))
maxNO2 <- max(Rsquared_NO2)
minNO2 <- min(Rsquared_NO2)
incrementNO2 <- (as.numeric(maxNO2) - as.numeric(minNO2)) / 4
plotR2 <- ggplot() +
geom_line(data = Rsquared_NO2, aes(x = Rsquared_NO2, y = SO2), color = "#993333") +
xlab('Latitude+Longitude ') +
ylab('Prediction Accuracy -- RSquared NO2 ') +
# add more ticks on the y-axis
scale_y_discrete(breaks=seq(maxNO2,minNO2,by=incrementSO2)) +
theme(
legend.text = element_text(face = "italic",colour="steelblue4",
family = "Helvetica", size = rel(1)),
axis.line = element_line(colour = "darkblue",
size = 1, linetype = "solid"),
legend.position="right",
panel.grid.major = element_line(colour="grey"),
panel.grid.minor = element_line(colour="red"),
legend.key = element_rect(fill = "whitesmoke"),
legend.title = element_text(colour = "steelblue",size = rel(1.5),
family = "Helvetica")
)
### Print pdf for SO2
pdf("/home/iotcloud/shaju/workspace/Eclipseworkspace/EnergyAnalyzer/tests/mobility/Results/PredAccuracy.pdf",width=8,height=5)
print(plotR2)
dev.off() |
## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(echo = TRUE,eval = FALSE,echo = T)
## -----------------------------------------------------------------------------
# # cat categories: https://www.purina.com/cats/cat-breeds
# f_n = 'cats'
#
# if(!dir.exists(f_n)) {
# dir.create(f_n)
# }
## -----------------------------------------------------------------------------
# library(rvest)
#
# download_pet = function(name, dest) {
# query = name
# query = gsub('\\s', '%20', query)
#
# search <- read_html(paste("https://www.google.com/search?site=&tbm=isch&q", query, sep = "="))
#
# urls <- search %>% html_nodes("img") %>% html_attr("src") %>% .[-1]
#
# fixed_name = gsub('\\s|[[:punct:]]', '_', name)
#
# for (i in 1:length(urls)) {
# download.file(urls[i], destfile =
# file.path(dest,
# paste(
# paste(fixed_name,
# round(runif(1)*10000),
# sep = '_'),
# '.jpg', sep = ''
# )
# ), mode = 'wb'
# )
# }
# }
## -----------------------------------------------------------------------------
# cat_names = c('Balinese-Javanese Cat Breed', 'Chartreux Cat Breed',
# 'Norwegian Forest Cat Breed', 'Turkish Angora Cat Breed')
## -----------------------------------------------------------------------------
# for (i in 1:length(cat_names)) {
# download_pet(cat_names[i], f_n)
# print(paste('Done',cat_names[i]))
# }
## -----------------------------------------------------------------------------
# library(fastai)
# library(magrittr)
#
# path = 'cats'
# fnames = get_image_files(path)
#
# fnames[1]
# # cats/Turkish_Angora_Cat_Breed_8583.jpg
## -----------------------------------------------------------------------------
# dls = ImageDataLoaders_from_name_re(
# path, fnames, pat='(.+)_\\d+.jpg$',
# item_tfms = Resize(size = 200), bs = 15,
# batch_tfms = list(aug_transforms(size = 224, min_scale = 0.75),
# Normalize_from_stats( imagenet_stats() )
# )
# )
#
#
# dls %>% show_batch(dpi = 200)
## -----------------------------------------------------------------------------
# learn = cnn_learner(dls, resnet50(), metrics = list(accuracy, error_rate))
#
# learn$recorder$train_metrics = TRUE
#
## -----------------------------------------------------------------------------
# learn %>% fit_one_cycle(5, 1e-3)
## -----------------------------------------------------------------------------
# fnames[1]
#
# # cats/Turkish_Angora_Cat_Breed_8583.jpg
#
# learn %>% predict(as.character(fnames[1]))
| /vignettes/custom_img.R | permissive | Cdk29/fastai | R | false | false | 2,665 | r | ## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(echo = TRUE,eval = FALSE,echo = T)
## -----------------------------------------------------------------------------
# # cat categories: https://www.purina.com/cats/cat-breeds
# f_n = 'cats'
#
# if(!dir.exists(f_n)) {
# dir.create(f_n)
# }
## -----------------------------------------------------------------------------
# library(rvest)
#
# download_pet = function(name, dest) {
# query = name
# query = gsub('\\s', '%20', query)
#
# search <- read_html(paste("https://www.google.com/search?site=&tbm=isch&q", query, sep = "="))
#
# urls <- search %>% html_nodes("img") %>% html_attr("src") %>% .[-1]
#
# fixed_name = gsub('\\s|[[:punct:]]', '_', name)
#
# for (i in 1:length(urls)) {
# download.file(urls[i], destfile =
# file.path(dest,
# paste(
# paste(fixed_name,
# round(runif(1)*10000),
# sep = '_'),
# '.jpg', sep = ''
# )
# ), mode = 'wb'
# )
# }
# }
## -----------------------------------------------------------------------------
# cat_names = c('Balinese-Javanese Cat Breed', 'Chartreux Cat Breed',
# 'Norwegian Forest Cat Breed', 'Turkish Angora Cat Breed')
## -----------------------------------------------------------------------------
# for (i in 1:length(cat_names)) {
# download_pet(cat_names[i], f_n)
# print(paste('Done',cat_names[i]))
# }
## -----------------------------------------------------------------------------
# library(fastai)
# library(magrittr)
#
# path = 'cats'
# fnames = get_image_files(path)
#
# fnames[1]
# # cats/Turkish_Angora_Cat_Breed_8583.jpg
## -----------------------------------------------------------------------------
# dls = ImageDataLoaders_from_name_re(
# path, fnames, pat='(.+)_\\d+.jpg$',
# item_tfms = Resize(size = 200), bs = 15,
# batch_tfms = list(aug_transforms(size = 224, min_scale = 0.75),
# Normalize_from_stats( imagenet_stats() )
# )
# )
#
#
# dls %>% show_batch(dpi = 200)
## -----------------------------------------------------------------------------
# learn = cnn_learner(dls, resnet50(), metrics = list(accuracy, error_rate))
#
# learn$recorder$train_metrics = TRUE
#
## -----------------------------------------------------------------------------
# learn %>% fit_one_cycle(5, 1e-3)
## -----------------------------------------------------------------------------
# fnames[1]
#
# # cats/Turkish_Angora_Cat_Breed_8583.jpg
#
# learn %>% predict(as.character(fnames[1]))
|
######################################################################
# generate the report, slides, and if needed start the web application
unlink( "TMPdirReport", recursive = TRUE )
dir.create( "TMPdirReport" )
setwd( "TMPdirReport" )
file.copy( paste(local_directory,"doc/Report.Rmd", sep="/"),"Report.Rmd", overwrite = T )
knit2html( 'Report.Rmd', quiet = TRUE )
file.copy( 'Report.html', paste(local_directory,"doc/Report.html", sep="/"), overwrite = T )
setwd( "../" )
unlink( "TMPdirReport", recursive = TRUE )
unlink( "TMPdirSlides", recursive = TRUE )
dir.create( "TMPdirSlides" )
setwd( "TMPdirSlides" )
file.copy( paste(local_directory,"doc/Slides.Rmd", sep="/"),"Slides.Rmd", overwrite = T )
slidify( "Slides.Rmd" )
file.copy( 'Slides.html', paste(local_directory,"doc/Slides.html", sep="/"), overwrite = T )
setwd( "../" )
unlink( "TMPdirSlides", recursive = TRUE )
| /R/runcode.R | permissive | anuradhavasudeva/BigDataRetailProject | R | false | false | 910 | r |
######################################################################
# generate the report, slides, and if needed start the web application
unlink( "TMPdirReport", recursive = TRUE )
dir.create( "TMPdirReport" )
setwd( "TMPdirReport" )
file.copy( paste(local_directory,"doc/Report.Rmd", sep="/"),"Report.Rmd", overwrite = T )
knit2html( 'Report.Rmd', quiet = TRUE )
file.copy( 'Report.html', paste(local_directory,"doc/Report.html", sep="/"), overwrite = T )
setwd( "../" )
unlink( "TMPdirReport", recursive = TRUE )
unlink( "TMPdirSlides", recursive = TRUE )
dir.create( "TMPdirSlides" )
setwd( "TMPdirSlides" )
file.copy( paste(local_directory,"doc/Slides.Rmd", sep="/"),"Slides.Rmd", overwrite = T )
slidify( "Slides.Rmd" )
file.copy( 'Slides.html', paste(local_directory,"doc/Slides.html", sep="/"), overwrite = T )
setwd( "../" )
unlink( "TMPdirSlides", recursive = TRUE )
|
source("../my_functions/linear_regression/gradient_descent.r")
df<-read.csv(file = "../my_functions/linear_regression/data//mlr04.csv")
names(df)
head(df)
plot(df[[1]],df[[2]])
theta<-gradient_descent(df,"X1",alpha=0.000001,it=400,scaling=T)
class(theta)
conv<-read.csv("./J.dat",header=F)
#head(conv)
#dim(conv)
plot(conv$V1,type = "l")
df1<-df[,c(6,10)]
head(df1)
df1[is.na(df$Age),"Age"]<-mean(df$Age,na.rm=T)
summary(df1)
gradient_descent(df1,"Age")
df<-df1
target<-"Age"
mylm <- lm(X1 ~ X2+X3+X4, data=df)
summary(mylm)
| /my_functions/linear_regression/gradient_descent_test.r | no_license | raghulmz/R-Works | R | false | false | 534 | r |
source("../my_functions/linear_regression/gradient_descent.r")
df<-read.csv(file = "../my_functions/linear_regression/data//mlr04.csv")
names(df)
head(df)
plot(df[[1]],df[[2]])
theta<-gradient_descent(df,"X1",alpha=0.000001,it=400,scaling=T)
class(theta)
conv<-read.csv("./J.dat",header=F)
#head(conv)
#dim(conv)
plot(conv$V1,type = "l")
df1<-df[,c(6,10)]
head(df1)
df1[is.na(df$Age),"Age"]<-mean(df$Age,na.rm=T)
summary(df1)
gradient_descent(df1,"Age")
df<-df1
target<-"Age"
mylm <- lm(X1 ~ X2+X3+X4, data=df)
summary(mylm)
|
###
# 4. 구별로 뽑기
###
source("./arules_data.R", encoding = "UTF-8")
adj_rule_place <- subset(ttRule.pruned, (lhs %in% paste0("시군구=",unique(food$시군구))))
place.df <- as(adj_rule_place,"data.frame")
place.df$rules <- as.character(place.df$rules)
place.df$lhs <- do.call(rbind,strsplit(place.df$rules,"=>"))[,1]
place.df$rhs <- do.call(rbind,strsplit(place.df$rules,"=>"))[,2]
place.rule <- list()
for(i in 1:length(unique(food$시군구))){
place.rule[[as.character(unique(food$시군구)[i])]] <- grep(unique(food$시군구)[i],place.df$lhs)
}
place.idx <- lapply(1:length(unique(food$시군구)),function(x){place.df[place.rule[[x]],]})
sa <- lapply(1:length(unique(food$시군구)),function(x){as.data.frame(table(place.idx[[x]]$rhs))})
place.table <- matrix(,nrow =length(unique(food$시군구)),ncol=4,
dimnames=list(unique(food$시군구),c("중국집","패밀리레스토랑","치킨","피자")))
for(i in 1:25){
place.table[i,"중국집"] <- ifelse(length(sa[[i]]$Freq)==0,0,sa[[i]][grep("중국집",sa[[i]]$Var1),"Freq"])
place.table[i,"패밀리레스토랑"] <- ifelse(length(sa[[i]]$Freq)==0,0,sa[[i]][grep("패밀리레스토랑",sa[[i]]$Var1),"Freq"])
place.table[i,"치킨"] <- ifelse(length(sa[[i]]$Freq)==0,0,sa[[i]][grep("치킨",sa[[i]]$Var1),"Freq"])
place.table[i,"피자"] <- ifelse(length(sa[[i]]$Freq)==0,0,sa[[i]][grep("피자",sa[[i]]$Var1),"Freq"])
}
place.table[which(is.na(place.table),arr.ind=T)] <- 0
#구별 업종 table
# place.table
#구별 업종 그래프 그리기 위한 작업
# place.graph <- list()
# for(i in 1:25){
# for(j in 1:4){
# place.graph[[paste(row.names(place.table)[i],colnames(place.table)[j])]] <-
# apply(data.frame(시군구=row.names(place.table)[i],업종=colnames(place.table)[j]),2,
# function(x){rep(x,place.table[i,j])})
# }
# }
# place.graph <- data.frame(Reduce(rbind, place.graph))
#구별 업종 그래프
# ggplot(place.graph,aes(x=시군구,group=업종,fill=업종))+geom_bar(position = "dodge")+
# geom_text(aes(label=..count..),stat='count',position=position_dodge(0.9))+theme_classic()+
# ggtitle("서울시 구별로 주문한 음식")+
# theme(plot.title = element_text(size=20, face="bold",hjust = 0.5),
# axis.text.x = element_text(angle = 45, hjust = 1))
| /model/place_table.R | no_license | ddinggu/r_plumber_app | R | false | false | 2,334 | r | ###
# 4. 구별로 뽑기
###
source("./arules_data.R", encoding = "UTF-8")
adj_rule_place <- subset(ttRule.pruned, (lhs %in% paste0("시군구=",unique(food$시군구))))
place.df <- as(adj_rule_place,"data.frame")
place.df$rules <- as.character(place.df$rules)
place.df$lhs <- do.call(rbind,strsplit(place.df$rules,"=>"))[,1]
place.df$rhs <- do.call(rbind,strsplit(place.df$rules,"=>"))[,2]
place.rule <- list()
for(i in 1:length(unique(food$시군구))){
place.rule[[as.character(unique(food$시군구)[i])]] <- grep(unique(food$시군구)[i],place.df$lhs)
}
place.idx <- lapply(1:length(unique(food$시군구)),function(x){place.df[place.rule[[x]],]})
sa <- lapply(1:length(unique(food$시군구)),function(x){as.data.frame(table(place.idx[[x]]$rhs))})
place.table <- matrix(,nrow =length(unique(food$시군구)),ncol=4,
dimnames=list(unique(food$시군구),c("중국집","패밀리레스토랑","치킨","피자")))
for(i in 1:25){
place.table[i,"중국집"] <- ifelse(length(sa[[i]]$Freq)==0,0,sa[[i]][grep("중국집",sa[[i]]$Var1),"Freq"])
place.table[i,"패밀리레스토랑"] <- ifelse(length(sa[[i]]$Freq)==0,0,sa[[i]][grep("패밀리레스토랑",sa[[i]]$Var1),"Freq"])
place.table[i,"치킨"] <- ifelse(length(sa[[i]]$Freq)==0,0,sa[[i]][grep("치킨",sa[[i]]$Var1),"Freq"])
place.table[i,"피자"] <- ifelse(length(sa[[i]]$Freq)==0,0,sa[[i]][grep("피자",sa[[i]]$Var1),"Freq"])
}
place.table[which(is.na(place.table),arr.ind=T)] <- 0
#구별 업종 table
# place.table
#구별 업종 그래프 그리기 위한 작업
# place.graph <- list()
# for(i in 1:25){
# for(j in 1:4){
# place.graph[[paste(row.names(place.table)[i],colnames(place.table)[j])]] <-
# apply(data.frame(시군구=row.names(place.table)[i],업종=colnames(place.table)[j]),2,
# function(x){rep(x,place.table[i,j])})
# }
# }
# place.graph <- data.frame(Reduce(rbind, place.graph))
#구별 업종 그래프
# ggplot(place.graph,aes(x=시군구,group=업종,fill=업종))+geom_bar(position = "dodge")+
# geom_text(aes(label=..count..),stat='count',position=position_dodge(0.9))+theme_classic()+
# ggtitle("서울시 구별로 주문한 음식")+
# theme(plot.title = element_text(size=20, face="bold",hjust = 0.5),
# axis.text.x = element_text(angle = 45, hjust = 1))
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/datename.R
\name{datename}
\alias{datename}
\title{Filename with date}
\usage{
datename(filename = "filename")
}
\arguments{
\item{filename}{A filename string.}
}
\value{
String with today's date in YYYY-MM-DD- format concatenated to filename.
}
\description{
Returns string with today's date in YYYY-MM-DD- format concatenated to filename.
}
\examples{
datename("myfile.png")
}
\author{
Stephen Turner
}
\keyword{keywords}
| /man/datename.Rd | no_license | gmaubach/Tmisc | R | false | true | 504 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/datename.R
\name{datename}
\alias{datename}
\title{Filename with date}
\usage{
datename(filename = "filename")
}
\arguments{
\item{filename}{A filename string.}
}
\value{
String with today's date in YYYY-MM-DD- format concatenated to filename.
}
\description{
Returns string with today's date in YYYY-MM-DD- format concatenated to filename.
}
\examples{
datename("myfile.png")
}
\author{
Stephen Turner
}
\keyword{keywords}
|
library(testthat)
test_check('mzID') | /tests/test-all.R | no_license | thomasp85/mzID | R | false | false | 37 | r | library(testthat)
test_check('mzID') |
setwd("C:/Users/faisal/OneDrive - eSevens/HD Backup/My University/Study/Kanazawa University/Riset/Code/R/AminoAcidComposition")
rm(list = ls())
library(protr)
library(stringr)
main_data.files = cbind(c("chlo1.txt","chlo2.txt","chlo3.txt","chlo4.txt","chlo5.txt"))
main_data.files = rbind(main_data.files, cbind(c("cytop1.txt","cytop2.txt","cytop3.txt","cytop4.txt","cytop5.txt")))
main_data.files = rbind(main_data.files, cbind(c("cytos1.txt","cytos2.txt","cytos3.txt","cytos4.txt","cytos5.txt")))
main_data.files = rbind(main_data.files, cbind(c("er1.txt","er2.txt","er3.txt","er4.txt","er5.txt")))
main_data.files = rbind(main_data.files, cbind(c("extr1.txt","extr2.txt","extr3.txt","extr4.txt","extr5.txt")))
main_data.files = rbind(main_data.files, cbind(c("golgi1.txt","golgi2.txt","golgi3.txt","golgi4.txt","golgi5.txt")))
main_data.files = rbind(main_data.files, cbind(c("lyso1.txt","lyso2.txt","lyso3.txt","lyso4.txt","lyso5.txt")))
main_data.files = rbind(main_data.files, cbind(c("mito1.txt","mito2.txt","mito3.txt","mito4.txt","mito5.txt")))
main_data.files = rbind(main_data.files, cbind(c("nuc1.txt","nuc2.txt","nuc3.txt","nuc4.txt","nuc5.txt")))
main_data.files = rbind(main_data.files, cbind(c("pero1.txt","pero2.txt","pero3.txt","pero4.txt","pero5.txt")))
main_data.files = rbind(main_data.files, cbind(c("plas1.txt","plas2.txt","plas3.txt","plas4.txt","plas5.txt")))
main_data.files = rbind(main_data.files, cbind(c("vacu1.txt","vacu2.txt","vacu3.txt","vacu4.txt","vacu5.txt")))
dividers = c(2,3,4,5)
for(file_i in main_data.files){
main_data = read.csv(paste0("dataset/",file_i), stringsAsFactors = FALSE)
#segmentation process - start
#=================================================================
for(divider_i in dividers){
if(exists("main_data.num")){
rm("main_data.num")
}
for(i in 1:nrow(main_data)){
datum = main_data[i,]
tryCatch({
class = datum$class
seq = datum$seq
# validasi sequence
# jika proses ini gagal maka baris yang di bawah di dalam blok ini tidak akan dieksekusi
# dilanjutkan dengan sample berikutnya
num_feature.test = extractCTDD(seq)
seq.length = nchar(seq)
part_length = round(seq.length/divider_i)
if(exists("num_feature")){
rm("num_feature")
}
if(exists("start_point")){
rm("start_point")
}
#perhitungan feature dari awal sampai akhir
#------------------------------------------ start
for(j in 1:(divider_i)){
if(j > 1){
start = ((j - 1) * part_length) + 1
end = j * part_length
if(j == divider_i){
end = seq.length
}
} else {
start = 1
end = part_length
}
seq.part = substr(seq, start, end)
#print(seq.part)
#print(extractCTDD(seq.part))
if(!exists("num_feature")){
assign("num_feature", cbind(extractCTDD(seq.part)))
} else {
num_feature = rbind(num_feature, cbind(extractCTDD(seq.part)))
}
if(!exists("start_point")){
assign("start_point", start)
} else {
start_point = rbind(start_point, start)
}
}
#------------------------------------------ end
#perhitungan feature antara 2 segment
#------------------------------------------ start
start_point = start_point[2:nrow(start_point),]
part_length.half = floor(part_length/2)
if(part_length.half == 0){
part_length.half = 1
}
for(start_point_i in start_point){
start = start_point_i - part_length.half
end = start_point_i + part_length.half
seq.part = substr(seq, start, end)
if(!exists("num_feature")){
assign("num_feature", cbind(extractCTDD(seq.part)))
} else {
num_feature = rbind(num_feature, cbind(extractCTDD(seq.part)))
}
}
#------------------------------------------ end
datum.num = cbind(t(num_feature), class)
if(!exists("main_data.num")){
assign("main_data.num", datum.num)
} else {
main_data.num = rbind.data.frame(main_data.num, datum.num)
}
}, error = function(err){
print(paste("error:",i,seq))
})
}
write.csv(main_data.num, paste0("overlapped/ctdd-overlapped-divider-",divider_i,"-",file_i), row.names = FALSE, quote = FALSE)
#=================================================================
#segmentation process - end
}
} | /Step2.DivideSeqOverlapped.ConvertToNumericFeature.CTDD.Ver1.R | no_license | rezafaisal/ProteinClassification | R | false | false | 4,838 | r | setwd("C:/Users/faisal/OneDrive - eSevens/HD Backup/My University/Study/Kanazawa University/Riset/Code/R/AminoAcidComposition")
rm(list = ls())
library(protr)
library(stringr)
main_data.files = cbind(c("chlo1.txt","chlo2.txt","chlo3.txt","chlo4.txt","chlo5.txt"))
main_data.files = rbind(main_data.files, cbind(c("cytop1.txt","cytop2.txt","cytop3.txt","cytop4.txt","cytop5.txt")))
main_data.files = rbind(main_data.files, cbind(c("cytos1.txt","cytos2.txt","cytos3.txt","cytos4.txt","cytos5.txt")))
main_data.files = rbind(main_data.files, cbind(c("er1.txt","er2.txt","er3.txt","er4.txt","er5.txt")))
main_data.files = rbind(main_data.files, cbind(c("extr1.txt","extr2.txt","extr3.txt","extr4.txt","extr5.txt")))
main_data.files = rbind(main_data.files, cbind(c("golgi1.txt","golgi2.txt","golgi3.txt","golgi4.txt","golgi5.txt")))
main_data.files = rbind(main_data.files, cbind(c("lyso1.txt","lyso2.txt","lyso3.txt","lyso4.txt","lyso5.txt")))
main_data.files = rbind(main_data.files, cbind(c("mito1.txt","mito2.txt","mito3.txt","mito4.txt","mito5.txt")))
main_data.files = rbind(main_data.files, cbind(c("nuc1.txt","nuc2.txt","nuc3.txt","nuc4.txt","nuc5.txt")))
main_data.files = rbind(main_data.files, cbind(c("pero1.txt","pero2.txt","pero3.txt","pero4.txt","pero5.txt")))
main_data.files = rbind(main_data.files, cbind(c("plas1.txt","plas2.txt","plas3.txt","plas4.txt","plas5.txt")))
main_data.files = rbind(main_data.files, cbind(c("vacu1.txt","vacu2.txt","vacu3.txt","vacu4.txt","vacu5.txt")))
dividers = c(2,3,4,5)
for(file_i in main_data.files){
main_data = read.csv(paste0("dataset/",file_i), stringsAsFactors = FALSE)
#segmentation process - start
#=================================================================
for(divider_i in dividers){
if(exists("main_data.num")){
rm("main_data.num")
}
for(i in 1:nrow(main_data)){
datum = main_data[i,]
tryCatch({
class = datum$class
seq = datum$seq
# validasi sequence
# jika proses ini gagal maka baris yang di bawah di dalam blok ini tidak akan dieksekusi
# dilanjutkan dengan sample berikutnya
num_feature.test = extractCTDD(seq)
seq.length = nchar(seq)
part_length = round(seq.length/divider_i)
if(exists("num_feature")){
rm("num_feature")
}
if(exists("start_point")){
rm("start_point")
}
#perhitungan feature dari awal sampai akhir
#------------------------------------------ start
for(j in 1:(divider_i)){
if(j > 1){
start = ((j - 1) * part_length) + 1
end = j * part_length
if(j == divider_i){
end = seq.length
}
} else {
start = 1
end = part_length
}
seq.part = substr(seq, start, end)
#print(seq.part)
#print(extractCTDD(seq.part))
if(!exists("num_feature")){
assign("num_feature", cbind(extractCTDD(seq.part)))
} else {
num_feature = rbind(num_feature, cbind(extractCTDD(seq.part)))
}
if(!exists("start_point")){
assign("start_point", start)
} else {
start_point = rbind(start_point, start)
}
}
#------------------------------------------ end
#perhitungan feature antara 2 segment
#------------------------------------------ start
start_point = start_point[2:nrow(start_point),]
part_length.half = floor(part_length/2)
if(part_length.half == 0){
part_length.half = 1
}
for(start_point_i in start_point){
start = start_point_i - part_length.half
end = start_point_i + part_length.half
seq.part = substr(seq, start, end)
if(!exists("num_feature")){
assign("num_feature", cbind(extractCTDD(seq.part)))
} else {
num_feature = rbind(num_feature, cbind(extractCTDD(seq.part)))
}
}
#------------------------------------------ end
datum.num = cbind(t(num_feature), class)
if(!exists("main_data.num")){
assign("main_data.num", datum.num)
} else {
main_data.num = rbind.data.frame(main_data.num, datum.num)
}
}, error = function(err){
print(paste("error:",i,seq))
})
}
write.csv(main_data.num, paste0("overlapped/ctdd-overlapped-divider-",divider_i,"-",file_i), row.names = FALSE, quote = FALSE)
#=================================================================
#segmentation process - end
}
} |
\name{i2d}
\alias{i2d}
\title{
convert 2D image into digital coordinates
}
\description{
convert 2D image into digital coordinates
}
\usage{
i2d(image=image, p.n=500, scale=T);
}
\arguments{
\item{image}{image file, type of file can be PNG, JPEG, TIF, or RAW}
\item{p.n}{number of points}
\item{scale}{a logical value, if scale the output coordinates}
}
\author{
Ying Hu \email{yhu@mail.nih.gov}
Chunhua Yan \email{yanch@mail.nih.gov}
Xiaoyu Liang \email{xiaoyu.liang@yale.edu}
}
\references{
Pau, G., Fuchs, F., Sklyar, O., Boutros, M., & Huber, W. (2010). EBImage--an R package for image processing with applications to cellular phenotypes. Bioinformatics, 26(7), 979-981. doi: 10.1093/bioinformatics/btq046
Csardi, G., & Nepusz, T. (2006). The igraph software package for complex network research. InterJournal, complex systems, 1695(5), 1-9.
}
\examples{
data(i2d_Example,package="i2d")
col=rgb(0, 0, 1, max = 1, alpha = 0.2)
mickey <- i2d(image=i2d_Example, p.n=5000)
mickey1 <- i2d(image=i2d_Example, p.n=10000)
par(mfrow=c(1,2))
plot(mickey, pch=19,col=col,main="i2d: 5000 points")
plot(mickey1, pch=19,col=col,main="i2d: 10000 points")
## Example for 3D data simulation
data(simulate_3D_data_1,package="i2d")
data(simulate_3D_data_2,package="i2d")
f <- function(x){ (x - min(x))/(max(x)-min(x)) * (1.6 - 0) + 0};
dat <- i2d(image=simulate_3D_data_1, p.n=1000);
dat2 <- i2d(image=simulate_3D_data_2, p.n=1000);
dat2 <- dat2[order(dat2[,1]),];
r <- f(dat2[,2]);
x <- dat[,1];
z <- dat[,2] + r;
y <- seq(1.5, 2.5, length.out = 1000);
## 3d data
out.s <- data.frame(x=x, y=y, z=z);
## for colors
row.names(dat) <- paste0("n", 1:nrow(dat));
out <- tjGCluster(dat);
out2 <- tree_list(out$mst, out$node);
cols <- rainbow(10, alpha=0.6);
l.n <- length(out2);
col.n <- colorRampPalette(cols)(l.n);
n2col <- NULL;
for (i in 1:l.n){
tmp <- unlist(out2[[i]]);
tmp.s <- data.frame(n=tmp, cols=rep(col.n[i], length(tmp)))
n2col <- rbind(n2col, tmp.s);
}
row.names(out.s) <- row.names(dat);
n.i <- match(row.names(out.s), n2col[,1]);
n2col <- n2col[n.i,]
# library(scatterplot3d)
# scatterplot3d(out.s$x, y=out.s$y, z=out.s$z,
# color = n2col[,2], pch=19,
# xlab = "", ylab = "", zlab = "")
}
| /man/i2d.Rd | no_license | XiaoyuLiang/i2d | R | false | false | 2,481 | rd | \name{i2d}
\alias{i2d}
\title{
convert 2D image into digital coordinates
}
\description{
convert 2D image into digital coordinates
}
\usage{
i2d(image=image, p.n=500, scale=T);
}
\arguments{
\item{image}{image file, type of file can be PNG, JPEG, TIF, or RAW}
\item{p.n}{number of points}
\item{scale}{a logical value, if scale the output coordinates}
}
\author{
Ying Hu \email{yhu@mail.nih.gov}
Chunhua Yan \email{yanch@mail.nih.gov}
Xiaoyu Liang \email{xiaoyu.liang@yale.edu}
}
\references{
Pau, G., Fuchs, F., Sklyar, O., Boutros, M., & Huber, W. (2010). EBImage--an R package for image processing with applications to cellular phenotypes. Bioinformatics, 26(7), 979-981. doi: 10.1093/bioinformatics/btq046
Csardi, G., & Nepusz, T. (2006). The igraph software package for complex network research. InterJournal, complex systems, 1695(5), 1-9.
}
\examples{
data(i2d_Example,package="i2d")
col=rgb(0, 0, 1, max = 1, alpha = 0.2)
mickey <- i2d(image=i2d_Example, p.n=5000)
mickey1 <- i2d(image=i2d_Example, p.n=10000)
par(mfrow=c(1,2))
plot(mickey, pch=19,col=col,main="i2d: 5000 points")
plot(mickey1, pch=19,col=col,main="i2d: 10000 points")
## Example for 3D data simulation
data(simulate_3D_data_1,package="i2d")
data(simulate_3D_data_2,package="i2d")
f <- function(x){ (x - min(x))/(max(x)-min(x)) * (1.6 - 0) + 0};
dat <- i2d(image=simulate_3D_data_1, p.n=1000);
dat2 <- i2d(image=simulate_3D_data_2, p.n=1000);
dat2 <- dat2[order(dat2[,1]),];
r <- f(dat2[,2]);
x <- dat[,1];
z <- dat[,2] + r;
y <- seq(1.5, 2.5, length.out = 1000);
## 3d data
out.s <- data.frame(x=x, y=y, z=z);
## for colors
row.names(dat) <- paste0("n", 1:nrow(dat));
out <- tjGCluster(dat);
out2 <- tree_list(out$mst, out$node);
cols <- rainbow(10, alpha=0.6);
l.n <- length(out2);
col.n <- colorRampPalette(cols)(l.n);
n2col <- NULL;
for (i in 1:l.n){
tmp <- unlist(out2[[i]]);
tmp.s <- data.frame(n=tmp, cols=rep(col.n[i], length(tmp)))
n2col <- rbind(n2col, tmp.s);
}
row.names(out.s) <- row.names(dat);
n.i <- match(row.names(out.s), n2col[,1]);
n2col <- n2col[n.i,]
# library(scatterplot3d)
# scatterplot3d(out.s$x, y=out.s$y, z=out.s$z,
# color = n2col[,2], pch=19,
# xlab = "", ylab = "", zlab = "")
}
|
setwd("/out/path/processed_data/")
### Read Data
### This table relates the different IDs that are used
# Study accession: phs000276.v2.p1
# Table accession: pht002004.v2.p1
# Consent group: All
# Citation instructions: The study accession (phs000276.v2.p1) is used to cite the study and its data tables and documents. The data in this file should be cited using the accession pht002004.v2.p1.
# To cite columns of data within this file, please use the variable (phv#) accessions below:
#
# 1) the table name and the variable (phv#) accessions below; or
# 2) you may cite a variable as phv#.v2.p1
## phv00129602.v2.p1 phv00129603.v2.p1 phv00196503.v1.p1
NFBC66_Sample_table <- read.table(gzfile("/path/to/files/phs000276.v2.pht002004.v2.p1.NFBC66_Sample.MULTI.txt.gz"),sep="\t",header = T)
head(NFBC66_Sample_table)
table(NFBC66_Sample_table$SAMPLE_USE)
length(unique(NFBC66_Sample_table$BioSample.Accession))
length(unique(NFBC66_Sample_table$SUBJID))
length(unique(NFBC66_Sample_table$SUBJID[NFBC66_Sample_table$SAMPLE_USE=="CTS_SRA"]))
length(unique(NFBC66_Sample_table$SUBJID[duplicated(NFBC66_Sample_table$SUBJID)]))
### Neet to count the number of subjects with both CTS and SNP_Array in this dataset:
NFBC66_Sample_table_CHIP_CTS <- subset(NFBC66_Sample_table,SAMPLE_USE%in%c('SNP_Array','CTS_SRA'))
aggregate(SUBJID~SAMPLE_USE,NFBC66_Sample_table_CHIP_CTS, FUN=function(x){length(unique(x))})
NFBC66_Sample_table_CHIP_CTS_uniqSUBJID <- aggregate(SAMPLE_USE~SUBJID,NFBC66_Sample_table_CHIP_CTS, FUN=length)
dim(NFBC66_Sample_table_CHIP_CTS_uniqSUBJID[NFBC66_Sample_table_CHIP_CTS_uniqSUBJID$SAMPLE_USE==2,])
## Load IDs in the chip data:
IDs_chipdata <- read.table("NFBC_dbGaP_20091127_hg19.fam",header = F)
head(IDs_chipdata)
### All the subjects in the chip are present in the Sample table
# IDs_chipdata$V1[!IDs_chipdata$V1%in%NFBC66_Sample_table$SUBJID]
## Load IDs in the sequence data (after post-processing)
IDs_seqdata <- read.table("PLP.fam",header = F)
IDs_seqdata$Sample_Name <- paste(IDs_seqdata$V1,IDs_seqdata$V2,sep = "_")
IDs_seqdata <- merge(IDs_seqdata,NFBC66_Sample_table,by.x="Sample_Name",by.y="SAMPID")
head(IDs_seqdata)
### 12 subjects appear with sequence data but were not present on the genotype. These will need to be removed from the analysis
# IDs_seqdata[!IDs_seqdata$SUBJID%in%IDs_chipdata$V1,]
# length(IDs_seqdata$SUBJID[!IDs_seqdata$SUBJID%in%IDs_chipdata$V1])
### write to a file to remove these
write.table(IDs_seqdata[!IDs_seqdata$SUBJID%in%IDs_chipdata$V1,c("V1","V2")],file="IDs_to_remove_seqdatan=12.txt", quote = F, row.names = F, col.names = F)
### Write the convertion file for the IDS that are common to both genotype and sequence data
write.table(IDs_seqdata[IDs_seqdata$SUBJID%in%IDs_chipdata$V1, c("V1","V2","SUBJID","SUBJID")],file="Convert_IDs_seq_to_geno_n=4511.txt", quote = F, row.names = F, col.names = F)
| /App_NFBC66/4a_homogenize_IDs_chip-seq.R | no_license | egosv/TwoPhase_postGWAS | R | false | false | 2,877 | r |
setwd("/out/path/processed_data/")
### Read Data
### This table relates the different IDs that are used
# Study accession: phs000276.v2.p1
# Table accession: pht002004.v2.p1
# Consent group: All
# Citation instructions: The study accession (phs000276.v2.p1) is used to cite the study and its data tables and documents. The data in this file should be cited using the accession pht002004.v2.p1.
# To cite columns of data within this file, please use the variable (phv#) accessions below:
#
# 1) the table name and the variable (phv#) accessions below; or
# 2) you may cite a variable as phv#.v2.p1
## phv00129602.v2.p1 phv00129603.v2.p1 phv00196503.v1.p1
NFBC66_Sample_table <- read.table(gzfile("/path/to/files/phs000276.v2.pht002004.v2.p1.NFBC66_Sample.MULTI.txt.gz"),sep="\t",header = T)
head(NFBC66_Sample_table)
table(NFBC66_Sample_table$SAMPLE_USE)
length(unique(NFBC66_Sample_table$BioSample.Accession))
length(unique(NFBC66_Sample_table$SUBJID))
length(unique(NFBC66_Sample_table$SUBJID[NFBC66_Sample_table$SAMPLE_USE=="CTS_SRA"]))
length(unique(NFBC66_Sample_table$SUBJID[duplicated(NFBC66_Sample_table$SUBJID)]))
### Neet to count the number of subjects with both CTS and SNP_Array in this dataset:
NFBC66_Sample_table_CHIP_CTS <- subset(NFBC66_Sample_table,SAMPLE_USE%in%c('SNP_Array','CTS_SRA'))
aggregate(SUBJID~SAMPLE_USE,NFBC66_Sample_table_CHIP_CTS, FUN=function(x){length(unique(x))})
NFBC66_Sample_table_CHIP_CTS_uniqSUBJID <- aggregate(SAMPLE_USE~SUBJID,NFBC66_Sample_table_CHIP_CTS, FUN=length)
dim(NFBC66_Sample_table_CHIP_CTS_uniqSUBJID[NFBC66_Sample_table_CHIP_CTS_uniqSUBJID$SAMPLE_USE==2,])
## Load IDs in the chip data:
IDs_chipdata <- read.table("NFBC_dbGaP_20091127_hg19.fam",header = F)
head(IDs_chipdata)
### All the subjects in the chip are present in the Sample table
# IDs_chipdata$V1[!IDs_chipdata$V1%in%NFBC66_Sample_table$SUBJID]
## Load IDs in the sequence data (after post-processing)
IDs_seqdata <- read.table("PLP.fam",header = F)
IDs_seqdata$Sample_Name <- paste(IDs_seqdata$V1,IDs_seqdata$V2,sep = "_")
IDs_seqdata <- merge(IDs_seqdata,NFBC66_Sample_table,by.x="Sample_Name",by.y="SAMPID")
head(IDs_seqdata)
### 12 subjects appear with sequence data but were not present on the genotype. These will need to be removed from the analysis
# IDs_seqdata[!IDs_seqdata$SUBJID%in%IDs_chipdata$V1,]
# length(IDs_seqdata$SUBJID[!IDs_seqdata$SUBJID%in%IDs_chipdata$V1])
### write to a file to remove these
write.table(IDs_seqdata[!IDs_seqdata$SUBJID%in%IDs_chipdata$V1,c("V1","V2")],file="IDs_to_remove_seqdatan=12.txt", quote = F, row.names = F, col.names = F)
### Write the convertion file for the IDS that are common to both genotype and sequence data
write.table(IDs_seqdata[IDs_seqdata$SUBJID%in%IDs_chipdata$V1, c("V1","V2","SUBJID","SUBJID")],file="Convert_IDs_seq_to_geno_n=4511.txt", quote = F, row.names = F, col.names = F)
|
devtools::install_github("garretrc/ggvoronoi")
library(ggvoronoi)
library(tidyverse)
####Example 1: Voronoi Diagram Simulation####
#start with some simulated data, keep n at 100 to start
n=5000
x=sample(1:n,n/2)
y=sample(1:n,n)
fill = sqrt((x-n/2)^2 + (y-n/2)^2) #distance form the center
points = data.frame(x=x,y=y,fill=fill)
#ggvoronoi allows us to draw voronoi diagram heatmaps.
#What does this mean?
#a Voronoi Diagram draws the nearest neighbor regions around a set of points
#and by specifying a fill argument we can turn that into a heatmap!
ggplot(points,aes(x,y))+
geom_voronoi(aes(fill=fill))
#or we can draw the points with the region boundaries!
ggplot(points,aes(x,y))+
geom_path(stat="voronoi")+
geom_point()
#these plots rely on our newly created ggplot stat, stat_voronoi
#stat_voronoi allows us to use the functions in the deldir package
#to visualize as well are more easily manipulate voronoi diagrams
#You can use stat_voronoi as its own layer, use it with geom_path or geom_polygon,
#or use our geom_voronoi function for convenience
#But what if we want the diagram drawn in a pre-defined region? deldir doesn't help with this
#the outline argument can take any dataframe with the following structure:
#first column is x/longitude
#second column is y/latitude
#optional column "group"
#Or you can feed it any SpatialPolygonsDataFrame!
circle = data.frame(x = (n/2)*(1+cos(seq(0, 2*pi, length.out = 2500))),
y = (n/2)*(1+sin(seq(0, 2*pi, length.out = 2500))),
group=rep(1,2500))
ggplot(data=points, aes(x=x, y=y, fill=fill)) +
geom_voronoi(outline = circle,color="black",size=.05)
#And with more knowledge of ggplot2 we can add more:
ggplot(points,aes(x,y))+
geom_voronoi(aes(fill=fill),outline=circle)+
scale_fill_gradient(low="#4dffb8",high="black",guide=F)+
theme_void()+
coord_fixed()
#If you found this example interesting, go back up and set n=5000 and run these again!
#Make sure to re-run the circle data if you do this
#Now these circles look pretty, but what are some actual applications?
####Example 2: Oxford Bikes Dataset####
#For this example, we'll be using the locations of each bike rack in Oxford, Ohio
#Note that ggvoronoi at the moment is limited to euclidean distance calculations.
#As such, using longitude and latitude will result in approximate Voronoi regions,
#But with high sample size or a small area on the globe (such as one small town),
#ggvoronoi still produces a useful (and near-exact) result!
bikes = read.csv("http://garretrc.github.io/host/oxford_bikes.csv",stringsAsFactors = F)
#first build the base map
library(ggmap)
library(ggthemes)
ox_map = get_map(location = c(-84.7398373,39.507306),zoom = 15)
bounds = as.numeric(attr(ox_map,"bb"))
map=
ggmap(ox_map,base_layer = ggplot(data=bikes,aes(x,y)))+ #map of oxford
xlim(-85,-84)+ylim(39,40)+ #adjust plot limits
coord_map(ylim=bounds[c(1,3)],xlim=bounds[c(2,4)]) #adjust plot zoom
#Now lets take a look!
map + geom_path(stat="voronoi",alpha=.085,size=1)+
geom_point(color="blue",size=.9)
#Here we can visually see each bike rack along with the Voronoi Region.
#So, given a bike rack, the region surrounding it is the area in Oxford for
#which that is the closest bike rack.
#But what if we want to utilize this, not just look at it?
#First, we can build a voronoi diagram as a SpatialPolygonsDataFrame
#The voronoi_polygon function takes in:
#data: a data frame (will need at least 2 numeric columns)
#x: dataframe column name or index for the x variable
#y: dataframe column name or index for the y variable
#outline: a data.frame or SpatialPolygonsDataFrame witha map outline
ox_diagram = voronoi_polygon(bikes,x="x",y="y")
#now, lets take a point of interest in Oxford, say Mac & Joes, a popular restuarant/bar.
#Google Maps can give me directions there, but there is no place to chain up a bike.
#So, lets use the diagram!
library(sp)
#create a point with Mac & Joes' location
mac_joes = SpatialPointsDataFrame(cbind(long=-84.7418,lat=39.5101),
data=data.frame(name="Mac & Joes"))
#overlay the point on our voronoi diagram
mac_joes %over% ox_diagram
#nd there we have the coordinates of the closest bike rack to Mac & Joes!
#Let's plot the map again.
#First, plot he voronoi regions using the SpatialPolygonsDataFrame
#Next, zoom into the area of interest (Uptown Oxford)
#Then, plot Mac & Joes with a red point
#Find the closest bike rack and drop a blue point
#Lastly, plot the rest of the racks for visual comparison
map + geom_path(data=fortify_voronoi(ox_diagram),aes(x,y,group=group),alpha=.1,size=1)+
coord_map(xlim=c(-84.747,-84.737),ylim=c(39.5075,39.515))+
geom_point(data=data.frame(mac_joes),aes(long,lat),color="red",size=4)+
geom_point(data=mac_joes %over% ox_diagram,aes(x,y),color="blue",size=4)+
geom_point(size=2)
#So, we can see if you're headed to Mac & Joes for lunch you're better off
#using the bike rack across High Street than the one on South Poplar
| /host/examples.R | no_license | garretrc/garretrc.github.io | R | false | false | 5,208 | r | devtools::install_github("garretrc/ggvoronoi")
library(ggvoronoi)
library(tidyverse)
####Example 1: Voronoi Diagram Simulation####
#start with some simulated data, keep n at 100 to start
n=5000
x=sample(1:n,n/2)
y=sample(1:n,n)
fill = sqrt((x-n/2)^2 + (y-n/2)^2) #distance form the center
points = data.frame(x=x,y=y,fill=fill)
#ggvoronoi allows us to draw voronoi diagram heatmaps.
#What does this mean?
#a Voronoi Diagram draws the nearest neighbor regions around a set of points
#and by specifying a fill argument we can turn that into a heatmap!
ggplot(points,aes(x,y))+
geom_voronoi(aes(fill=fill))
#or we can draw the points with the region boundaries!
ggplot(points,aes(x,y))+
geom_path(stat="voronoi")+
geom_point()
#these plots rely on our newly created ggplot stat, stat_voronoi
#stat_voronoi allows us to use the functions in the deldir package
#to visualize as well are more easily manipulate voronoi diagrams
#You can use stat_voronoi as its own layer, use it with geom_path or geom_polygon,
#or use our geom_voronoi function for convenience
#But what if we want the diagram drawn in a pre-defined region? deldir doesn't help with this
#the outline argument can take any dataframe with the following structure:
#first column is x/longitude
#second column is y/latitude
#optional column "group"
#Or you can feed it any SpatialPolygonsDataFrame!
circle = data.frame(x = (n/2)*(1+cos(seq(0, 2*pi, length.out = 2500))),
y = (n/2)*(1+sin(seq(0, 2*pi, length.out = 2500))),
group=rep(1,2500))
ggplot(data=points, aes(x=x, y=y, fill=fill)) +
geom_voronoi(outline = circle,color="black",size=.05)
#And with more knowledge of ggplot2 we can add more:
ggplot(points,aes(x,y))+
geom_voronoi(aes(fill=fill),outline=circle)+
scale_fill_gradient(low="#4dffb8",high="black",guide=F)+
theme_void()+
coord_fixed()
#If you found this example interesting, go back up and set n=5000 and run these again!
#Make sure to re-run the circle data if you do this
#Now these circles look pretty, but what are some actual applications?
####Example 2: Oxford Bikes Dataset####
#For this example, we'll be using the locations of each bike rack in Oxford, Ohio
#Note that ggvoronoi at the moment is limited to euclidean distance calculations.
#As such, using longitude and latitude will result in approximate Voronoi regions,
#But with high sample size or a small area on the globe (such as one small town),
#ggvoronoi still produces a useful (and near-exact) result!
bikes = read.csv("http://garretrc.github.io/host/oxford_bikes.csv",stringsAsFactors = F)
#first build the base map
library(ggmap)
library(ggthemes)
ox_map = get_map(location = c(-84.7398373,39.507306),zoom = 15)
bounds = as.numeric(attr(ox_map,"bb"))
map=
ggmap(ox_map,base_layer = ggplot(data=bikes,aes(x,y)))+ #map of oxford
xlim(-85,-84)+ylim(39,40)+ #adjust plot limits
coord_map(ylim=bounds[c(1,3)],xlim=bounds[c(2,4)]) #adjust plot zoom
#Now lets take a look!
map + geom_path(stat="voronoi",alpha=.085,size=1)+
geom_point(color="blue",size=.9)
#Here we can visually see each bike rack along with the Voronoi Region.
#So, given a bike rack, the region surrounding it is the area in Oxford for
#which that is the closest bike rack.
#But what if we want to utilize this, not just look at it?
#First, we can build a voronoi diagram as a SpatialPolygonsDataFrame
#The voronoi_polygon function takes in:
#data: a data frame (will need at least 2 numeric columns)
#x: dataframe column name or index for the x variable
#y: dataframe column name or index for the y variable
#outline: a data.frame or SpatialPolygonsDataFrame witha map outline
ox_diagram = voronoi_polygon(bikes,x="x",y="y")
#now, lets take a point of interest in Oxford, say Mac & Joes, a popular restuarant/bar.
#Google Maps can give me directions there, but there is no place to chain up a bike.
#So, lets use the diagram!
library(sp)
#create a point with Mac & Joes' location
mac_joes = SpatialPointsDataFrame(cbind(long=-84.7418,lat=39.5101),
data=data.frame(name="Mac & Joes"))
#overlay the point on our voronoi diagram
mac_joes %over% ox_diagram
#nd there we have the coordinates of the closest bike rack to Mac & Joes!
#Let's plot the map again.
#First, plot he voronoi regions using the SpatialPolygonsDataFrame
#Next, zoom into the area of interest (Uptown Oxford)
#Then, plot Mac & Joes with a red point
#Find the closest bike rack and drop a blue point
#Lastly, plot the rest of the racks for visual comparison
map + geom_path(data=fortify_voronoi(ox_diagram),aes(x,y,group=group),alpha=.1,size=1)+
coord_map(xlim=c(-84.747,-84.737),ylim=c(39.5075,39.515))+
geom_point(data=data.frame(mac_joes),aes(long,lat),color="red",size=4)+
geom_point(data=mac_joes %over% ox_diagram,aes(x,y),color="blue",size=4)+
geom_point(size=2)
#So, we can see if you're headed to Mac & Joes for lunch you're better off
#using the bike rack across High Street than the one on South Poplar
|
#' Finding the neighborhood of best lambda_H and lambda_K
#'
#' This function computes the neighborhood of the best lambda_K and lambda_H.
#'
#' @param AFFSEN_CV. output of the AFSSEN_CV function
#' @param diff_between_K. the threshold for finding the optimum K
#' @param diff_within_H. the threshold for finding the optimum H
#'
#' @return list containing:
#' \itemize{
#' \item \code{lambda_K_opt}. the optimum lambda_K
#' \item \code{lambda_H_opt}. the optimum lambda_H
#'
#' @export
#'
#' @useDynLib flm, .registration = TRUE
#'
opt_lambdas<- function(AFSSEN_CV, diff_between_K , diff_within_H)
{
dim_H=dim(AFSSEN_CV$CV_error)[1]
dim_K=dim(AFSSEN_CV$CV_error)[2]
##########
##########
opt=which(AFSSEN_CV$CV_error==min(AFSSEN_CV$CV_error),arr.ind = TRUE)
if((opt[1]!=dim_H)||(opt[2]!=dim_K)){
print("optimum is not in the boundry.")
result=c(AFSSEN_CV$lambda_H[opt[1]] , AFSSEN_CV$lambda_K[opt[2]])
names(result)=c("lambda_H_opt","lambda_K_opt")
return(result)
} else{
##########
##########
diff_K=rep(NA,dim(AFSSEN_CV$CV_error)[2]-1)
for(i in 1:(dim(AFSSEN_CV$CV_error)[2]-1)){
diff_K[i]=mean((AFSSEN_CV$CV_error[,i+1]-AFSSEN_CV$CV_error[,i])^2)
}
if(min(diff_K) < diff_between_K){
ind_K=min(which(diff_K < diff_between_K))
lambda_K_opt=AFSSEN_CV$lambda_K[ind_K]
}else{
print("You should choose more value for lambda_K")
ind_K=dim(AFSSEN_CV$CV_error)[2]
lambda_K_opt=AFSSEN_CV$lambda_K[ind_K] # return the last lambda_K
}
##########
##########
opt_H=which(AFSSEN_CV$CV_error[,ind_K]==min(AFSSEN_CV$CV_error[,ind_K]),arr.ind = TRUE)
if(opt_H!=dim_H){
print("optimum lambda_H is not in the boundry.")
result=c(AFSSEN_CV$lambda_H[opt_H] , lambda_K_opt)
names(result)=c("lambda_H_opt","lambda_K_opt")
return(result)
}else{
diff_H=rep(NA,dim(AFSSEN_CV$CV_error)[1]-1)
for(i in 1:(dim(AFSSEN_CV$CV_error)[1]-1)){
diff_H[i]=abs((AFSSEN_CV$CV_error[i+1,ind_K]-AFSSEN_CV$CV_error[i,ind_K])/(AFSSEN_CV$CV_error[i+1,ind_K]-AFSSEN_CV$CV_error[dim_H,ind_K]))
}
if(min(diff_H[diff_H>0]) < diff_within_H){ # min nonzero diff_H
ind_H=min(which( diff_H[diff_H>0] < diff_within_H ))
lambda_H_opt=AFSSEN_CV$lambda_H[ind_H]
}else{
print("You should choose more value for lambda_H")
lambda_H_opt=tail(AFSSEN_CV$lambda_H,1) # return the last lambda_K
}
##########
##########
result=c(lambda_K_opt, lambda_H_opt)
names(result)=c("lambda_K_opt","lambda_H_opt")
return(result)
}
}
}
| /R/opt_lambdas.R | no_license | ardeeshany/AFSSEN | R | false | false | 2,625 | r | #' Finding the neighborhood of best lambda_H and lambda_K
#'
#' This function computes the neighborhood of the best lambda_K and lambda_H.
#'
#' @param AFFSEN_CV. output of the AFSSEN_CV function
#' @param diff_between_K. the threshold for finding the optimum K
#' @param diff_within_H. the threshold for finding the optimum H
#'
#' @return list containing:
#' \itemize{
#' \item \code{lambda_K_opt}. the optimum lambda_K
#' \item \code{lambda_H_opt}. the optimum lambda_H
#'
#' @export
#'
#' @useDynLib flm, .registration = TRUE
#'
opt_lambdas<- function(AFSSEN_CV, diff_between_K , diff_within_H)
{
dim_H=dim(AFSSEN_CV$CV_error)[1]
dim_K=dim(AFSSEN_CV$CV_error)[2]
##########
##########
opt=which(AFSSEN_CV$CV_error==min(AFSSEN_CV$CV_error),arr.ind = TRUE)
if((opt[1]!=dim_H)||(opt[2]!=dim_K)){
print("optimum is not in the boundry.")
result=c(AFSSEN_CV$lambda_H[opt[1]] , AFSSEN_CV$lambda_K[opt[2]])
names(result)=c("lambda_H_opt","lambda_K_opt")
return(result)
} else{
##########
##########
diff_K=rep(NA,dim(AFSSEN_CV$CV_error)[2]-1)
for(i in 1:(dim(AFSSEN_CV$CV_error)[2]-1)){
diff_K[i]=mean((AFSSEN_CV$CV_error[,i+1]-AFSSEN_CV$CV_error[,i])^2)
}
if(min(diff_K) < diff_between_K){
ind_K=min(which(diff_K < diff_between_K))
lambda_K_opt=AFSSEN_CV$lambda_K[ind_K]
}else{
print("You should choose more value for lambda_K")
ind_K=dim(AFSSEN_CV$CV_error)[2]
lambda_K_opt=AFSSEN_CV$lambda_K[ind_K] # return the last lambda_K
}
##########
##########
opt_H=which(AFSSEN_CV$CV_error[,ind_K]==min(AFSSEN_CV$CV_error[,ind_K]),arr.ind = TRUE)
if(opt_H!=dim_H){
print("optimum lambda_H is not in the boundry.")
result=c(AFSSEN_CV$lambda_H[opt_H] , lambda_K_opt)
names(result)=c("lambda_H_opt","lambda_K_opt")
return(result)
}else{
diff_H=rep(NA,dim(AFSSEN_CV$CV_error)[1]-1)
for(i in 1:(dim(AFSSEN_CV$CV_error)[1]-1)){
diff_H[i]=abs((AFSSEN_CV$CV_error[i+1,ind_K]-AFSSEN_CV$CV_error[i,ind_K])/(AFSSEN_CV$CV_error[i+1,ind_K]-AFSSEN_CV$CV_error[dim_H,ind_K]))
}
if(min(diff_H[diff_H>0]) < diff_within_H){ # min nonzero diff_H
ind_H=min(which( diff_H[diff_H>0] < diff_within_H ))
lambda_H_opt=AFSSEN_CV$lambda_H[ind_H]
}else{
print("You should choose more value for lambda_H")
lambda_H_opt=tail(AFSSEN_CV$lambda_H,1) # return the last lambda_K
}
##########
##########
result=c(lambda_K_opt, lambda_H_opt)
names(result)=c("lambda_K_opt","lambda_H_opt")
return(result)
}
}
}
|
library(plyr)
library(ggplot2)
diffs <- read.csv("RepositoryLog.csv")
churnSummary <- ddply(diffs,.(File),summarise,Add=sum(Added), Rem=sum(Removed), TotalChurn = Add+Rem, Edits=length(File))
ggplot(churnSummary,aes(x=Add,y=Rem)) + geom_point(aes(size=Edits)) + geom_text(data=churnSummary[churnSummary$TotalChurn>500,],aes(label=File),nudge_x = 40)
| /dataFiles/3A_MetricsAndRelations/RepositoryLog/AllChanges/churn-analysis.R | permissive | AlHasan89/System_Re-engineering | R | false | false | 357 | r | library(plyr)
library(ggplot2)
diffs <- read.csv("RepositoryLog.csv")
churnSummary <- ddply(diffs,.(File),summarise,Add=sum(Added), Rem=sum(Removed), TotalChurn = Add+Rem, Edits=length(File))
ggplot(churnSummary,aes(x=Add,y=Rem)) + geom_point(aes(size=Edits)) + geom_text(data=churnSummary[churnSummary$TotalChurn>500,],aes(label=File),nudge_x = 40)
|
# test function
require(data.table)
require(Rcpp) | /test.R | no_license | JeongSeopSong/Song | R | false | false | 50 | r | # test function
require(data.table)
require(Rcpp) |
####Analyses and graphs####
##set up and load libraries
library(ez)
library(reshape)
library(ggplot2)
library(Hmisc)
#source(descriptives.R)
options(scipen = 999)
cleanup = theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line.x = element_line(color = "black"),
axis.line.y = element_line(color = "black"),
legend.key = element_rect(fill = "white"),
text = element_text(size = 25))
##overall switch vs non switch here
##global switch vs pure
##set up overall switch data here
output_errors$switch_average = (output_errors$alt_switch_errors + output_errors$alt_non_switch_errors +
output_errors$rand_switch_errors + output_errors$rand_non_switch_errors) / 4
pure.switch = output_errors[ , c(3, 12)]
pure.switch$subID = 1:nrow(pure.switch)
pure.switch = pure.switch[-15, ]
long.dat1 = melt(pure.switch, id = ("subID"))
colnames(long.dat1)[2] = "Task_Type"
colnames(long.dat1)[3] = "Mean_Error"
bar1 = ggplot(long.dat1, aes(Task_Type, Mean_Error))
bar1 +
stat_summary(fun.y = mean,
geom = "bar",
fill = "Red",
color = "Red") +
stat_summary(fun.data = mean_cl_normal,
geom = "errorbar",
width = .2,
position = "dodge") +
cleanup +
xlab("Task Type") +
ylab("Mean Error Rate") +
scale_x_discrete(labels = c("Pure", "Switch"))
##just looking at switch data
switch.nonswitch = output_errors[ , c(4:7)]
switch.nonswitch$subID = 1:nrow(switch.nonswitch)
switch.nonswitch = switch.nonswitch[-15, ]
long.dat2 = melt(switch.nonswitch, id = ("subID"))
colnames(long.dat2)[2] = "Task_Type"
colnames(long.dat2)[3] = "Mean_Error"
long.dat2$switch_type = c(rep("Switch", 20), rep("Non-Switch", 20), rep("Switch", 20), rep("Non-Switch", 20))
long.dat2$Task_Type = c(rep("Alternating Runs", 40), rep("Random", 40))
long.dat2$Mean_Error = long.dat2$Mean_Error * 100
bar2 = ggplot(long.dat2, aes(Task_Type, Mean_Error, fill = switch_type))
bar2 +
stat_summary(fun.y = mean,
geom = "bar",
position = "dodge") +
stat_summary(fun.data = mean_cl_normal,
geom = "errorbar",
position = position_dodge(width = 0.90),
width = .2) +
xlab("Task Type") +
ylab("Mean Error Rate") +
cleanup +
scale_fill_manual(name = "Switch Type",
labels = c("Switch", "Non-Switch"),
values = c("Red", "Gray"))
bar2
####Pure, switch, and non-switch trials
dat3 = output_errors[ , c(3:7)]
dat3$subID = 1:nrow(dat3)
dat3 = dat3[-15, ]
dat3$Switch = (dat3$alt_switch_errors + dat3$rand_switch_errors) / 2
dat3$Non_Switch = (dat3$alt_non_switch_errors + dat3$rand_non_switch_errors) / 2
dat3 = dat3[ , -c(2:5)]
colnames(dat3)[1] = "Pure"
long.dat3 = melt(dat3, id = ("subID"))
colnames(long.dat3)[2] = "Task_Type"
colnames(long.dat3)[3] = "Mean_Error"
##make the graph
bar3 = ggplot(long.dat3, aes(Task_Type, Mean_Error))
bar3 +
stat_summary(fun.y = mean,
geom = "bar",
fill = "Red",
color = "Red") +
stat_summary(fun.data = mean_cl_normal,
geom = "errorbar",
width = .2,
position = "dodge") +
cleanup +
xlab("Task Type") +
ylab("Mean Error Rate") +
scale_x_discrete(labels = c("Pure", "Switch", "Non-Switch"))
bar3
####run some ANOVA####
##difference between pure, switch, and non-switch
ezANOVA(data = long.dat3,
wid = subID,
within = Task_Type,
dv = Mean_Error,
type = 3) ##non-significant, p = .254
####t-test for alt runs switch vs non-switch and rand switch vs non-switch####
dat4 = subset(long.dat2,
long.dat2$Task_Type == "Alternating Runs")
dat5 = subset(long.dat2,
long.dat2$Task_Type == "Random")
t.test(dat4$Mean_Error ~ dat4$switch_type) ##signficant! ##ALT RUNS
t.test(dat5$Mean_Error ~ dat5$switch_type) ##signficant! ##RANDOM
####global vs local switch costs####
dat6 = output_errors[ , c(8:11)]
| /CVOE/1 Analysis/Scripts/CVOE graphs.R | no_license | npm27/Spring-2019-Projects | R | false | false | 4,198 | r | ####Analyses and graphs####
##set up and load libraries
library(ez)
library(reshape)
library(ggplot2)
library(Hmisc)
#source(descriptives.R)
options(scipen = 999)
cleanup = theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line.x = element_line(color = "black"),
axis.line.y = element_line(color = "black"),
legend.key = element_rect(fill = "white"),
text = element_text(size = 25))
##overall switch vs non switch here
##global switch vs pure
##set up overall switch data here
output_errors$switch_average = (output_errors$alt_switch_errors + output_errors$alt_non_switch_errors +
output_errors$rand_switch_errors + output_errors$rand_non_switch_errors) / 4
pure.switch = output_errors[ , c(3, 12)]
pure.switch$subID = 1:nrow(pure.switch)
pure.switch = pure.switch[-15, ]
long.dat1 = melt(pure.switch, id = ("subID"))
colnames(long.dat1)[2] = "Task_Type"
colnames(long.dat1)[3] = "Mean_Error"
bar1 = ggplot(long.dat1, aes(Task_Type, Mean_Error))
bar1 +
stat_summary(fun.y = mean,
geom = "bar",
fill = "Red",
color = "Red") +
stat_summary(fun.data = mean_cl_normal,
geom = "errorbar",
width = .2,
position = "dodge") +
cleanup +
xlab("Task Type") +
ylab("Mean Error Rate") +
scale_x_discrete(labels = c("Pure", "Switch"))
##just looking at switch data
switch.nonswitch = output_errors[ , c(4:7)]
switch.nonswitch$subID = 1:nrow(switch.nonswitch)
switch.nonswitch = switch.nonswitch[-15, ]
long.dat2 = melt(switch.nonswitch, id = ("subID"))
colnames(long.dat2)[2] = "Task_Type"
colnames(long.dat2)[3] = "Mean_Error"
long.dat2$switch_type = c(rep("Switch", 20), rep("Non-Switch", 20), rep("Switch", 20), rep("Non-Switch", 20))
long.dat2$Task_Type = c(rep("Alternating Runs", 40), rep("Random", 40))
long.dat2$Mean_Error = long.dat2$Mean_Error * 100
bar2 = ggplot(long.dat2, aes(Task_Type, Mean_Error, fill = switch_type))
bar2 +
stat_summary(fun.y = mean,
geom = "bar",
position = "dodge") +
stat_summary(fun.data = mean_cl_normal,
geom = "errorbar",
position = position_dodge(width = 0.90),
width = .2) +
xlab("Task Type") +
ylab("Mean Error Rate") +
cleanup +
scale_fill_manual(name = "Switch Type",
labels = c("Switch", "Non-Switch"),
values = c("Red", "Gray"))
bar2
####Pure, switch, and non-switch trials
dat3 = output_errors[ , c(3:7)]
dat3$subID = 1:nrow(dat3)
dat3 = dat3[-15, ]
dat3$Switch = (dat3$alt_switch_errors + dat3$rand_switch_errors) / 2
dat3$Non_Switch = (dat3$alt_non_switch_errors + dat3$rand_non_switch_errors) / 2
dat3 = dat3[ , -c(2:5)]
colnames(dat3)[1] = "Pure"
long.dat3 = melt(dat3, id = ("subID"))
colnames(long.dat3)[2] = "Task_Type"
colnames(long.dat3)[3] = "Mean_Error"
##make the graph
bar3 = ggplot(long.dat3, aes(Task_Type, Mean_Error))
bar3 +
stat_summary(fun.y = mean,
geom = "bar",
fill = "Red",
color = "Red") +
stat_summary(fun.data = mean_cl_normal,
geom = "errorbar",
width = .2,
position = "dodge") +
cleanup +
xlab("Task Type") +
ylab("Mean Error Rate") +
scale_x_discrete(labels = c("Pure", "Switch", "Non-Switch"))
bar3
####run some ANOVA####
##difference between pure, switch, and non-switch
ezANOVA(data = long.dat3,
wid = subID,
within = Task_Type,
dv = Mean_Error,
type = 3) ##non-significant, p = .254
####t-test for alt runs switch vs non-switch and rand switch vs non-switch####
dat4 = subset(long.dat2,
long.dat2$Task_Type == "Alternating Runs")
dat5 = subset(long.dat2,
long.dat2$Task_Type == "Random")
t.test(dat4$Mean_Error ~ dat4$switch_type) ##signficant! ##ALT RUNS
t.test(dat5$Mean_Error ~ dat5$switch_type) ##signficant! ##RANDOM
####global vs local switch costs####
dat6 = output_errors[ , c(8:11)]
|
93e1a1828579c5d4faae0be1377a2c1f aim-50-6_0-yes1-1-50.qdimacs 446 1269 | /code/dcnf-ankit-optimized/Results/QBFLIB-2018/E1/Database/Letombe/Abduction/aim-50-6_0-yes1-1-50/aim-50-6_0-yes1-1-50.R | no_license | arey0pushpa/dcnf-autarky | R | false | false | 70 | r | 93e1a1828579c5d4faae0be1377a2c1f aim-50-6_0-yes1-1-50.qdimacs 446 1269 |
MCMC.BD<-function(phy,diversity,root.rate=0.01,a=0,e=3,ngen=1000000,sfreq=100,lam=1,expl=1){
require(ape)
if (is.null(attr(phy, "order")) || attr(phy, "order") == "cladewise")
phy<- reorder.phylo(phy,"c")
edge<-phy$edge
stem.ages<-branching.times(phy)
edge<-cbind(edge,stem.ages[phy$edge[,1]-Ntip(phy)]) # birth time xi =3
edge<-cbind(edge,phy$edge.length) # branch length or waiting time, ti = 4
edge<-cbind(edge,diversity[phy$edge[,2]])# assign diversity to termainals, NAs are for internals. =5
edge<-cbind(edge,NA) # div rate column = 6
edge<-cbind(edge,NA) # div node split column =7
edge<-cbind(edge,0) # div rate group column = 8
dimnames(edge)<-NULL
rate.vect<-numeric(1)
avge<-e
#_______________________________________________________________________________
# Main MCMC function
MCMC<-function(logLik,edge,root.rate,a,e,rate.vect,lam,expl){
N <-length(which(edge[,7]==1))
if (N==0) z<-sample(c(1,6),1,prob=c(30,60)) # 1=have to split, 6=change root rate
else if (N==length(edge[,1])) z<-sample(c(2,5,6),1,prob=c(33,33,33)) #2=must merge, 5=change rate modifier
else if (N>0 && N<length(edge[,1])) z<-sample(c(3:6),1,prob=c(10,10,30,50))
#cat(a,"\n")
if (z==1){# must split diversity
x<-sample(1:length(edge[,1]),1)
rate.vect.new<-rexp(1)
newedge<-split(edge,x)
newedge<-rate.calc(newedge,root.rate,rate.vect.new)
newlogLik<-likelihood(newedge,a)
HP<-e/2
accept=1
lr <- newlogLik-logLik
ratio <- exp(lr)*HP
#cat(accept," ",logLik," ", newlogLik," ",N," ", ratio, "\n")
if (runif(1,0,1) < ratio) return(list(newedge,newlogLik,rate.vect.new,root.rate,accept,1))
else return(list(edge,logLik,rate.vect,root.rate,accept,0))
}
else if (z==2){# must merge diversity
x<-sample(1:length(edge[,1]),1)
rate.vect.new<-rate.vect[-x]
newedge<-merge(edge,x)
newedge<-rate.calc(newedge,root.rate,rate.vect.new)
newlogLik<-likelihood(newedge,a)
HP<-N/e
accept=2
lr <- newlogLik-logLik
ratio <- exp(lr)*HP
#cat(accept," ",logLik," ", newlogLik," ",N," ", ratio, "\n")
if (runif(1,0,1) < ratio) return(list(newedge,newlogLik,rate.vect.new,root.rate,accept,1))
else return(list(edge,logLik,rate.vect,root.rate,accept,0))
}
else if (z==3){# regular merge
if (N==1){
x<-which(edge[,7]==1)
HP<-2/e
}
else { x<-sample(which(edge[,7]==1),1)
HP<-N/e
}
s<-edge[x,8]
rate.vect.new<-rate.vect[-s]
newedge<-merge(edge,x)
newedge<-rate.calc(newedge,root.rate,rate.vect.new)
newlogLik<-likelihood(newedge,a)
accept=3
lr <- newlogLik-logLik
ratio <- exp(lr)*HP
#cat(accept," ",logLik," ", newlogLik," ",N," ", ratio, "\n")
if (runif(1,0,1) < ratio) return(list(newedge,newlogLik,rate.vect.new,root.rate,accept,1))
else return(list(edge,logLik,rate.vect,root.rate,accept,0))
}
else if (z==4){# regular split
x<-which(is.na(edge[,7]))
if (length(x)>1) x<-sample(x,1)
rate.vect.new<-c(rate.vect,rexp(1))
newedge<-split(edge,x)
newedge<-rate.calc(newedge,root.rate,rate.vect.new)
newlogLik<-likelihood(newedge,a)
HP<-e/(N+1)
accept=4
lr <- newlogLik-logLik
ratio <- exp(lr)*HP
#cat(accept," ",logLik," ", newlogLik," ",N," ", ratio, "\n")
if(runif(1,0,1) < ratio) return(list(newedge,newlogLik,rate.vect.new,root.rate,accept,1))
else return(list(edge,logLik,rate.vect,root.rate,accept,0))
}
else if (z==5){ #change exisiting rate multiplier
#rm<-rexp(1)
if (N==1) x<-which(edge[,7]==1)
else x<-sample(which(edge[,7]==1),1)
s<-edge[x,8]
rate.vect.new<-rate.vect
r<-exp(runif(1,0,1)-0.5)*expl
rate.vect.new[s]<-rate.vect.new[s]*r
newedge<-rate.calc(edge,root.rate,rate.vect.new)
newlogLik<-likelihood(newedge,a)
accept=5
lr <- newlogLik-logLik
ratio <- exp(lr)*r
#cat(accept," ",logLik," ", newlogLik," ",N," ", ratio, "\n")
if(runif(1,0,1) < ratio) return(list(newedge,newlogLik,rate.vect.new,root.rate,accept,1))
else return(list(edge,logLik,rate.vect,root.rate,accept,0))
}
else if (z==6){ #change root rate
#rr<-root.rate + runif(1,-0.05,0.05) # simply add a small value to rate
#rr<-runif(1,root.rate-(lam/2),root.rate+(lam/2)) #
#if (rr<=0) new.root.rate<-0+(0-rr)
#else if (rr>=10) new.root.rate <-10-(rr-10)
#else new.root.rate<-rr
r<-exp(runif(1,0,1)-0.5)*lam #proportionally grow/shrink
new.root.rate<-root.rate*r
newedge<-rate.calc(edge,new.root.rate,rate.vect)
newlogLik<-likelihood(newedge,a)
accept=6
lr <- newlogLik-logLik
#ratio <- exp(lr)
ratio <- exp(lr) * r
#cat(accept," ",logLik," ", newlogLik," ",N," ", ratio, "\n")
if(runif(1,0,1) < ratio) return(list(newedge,newlogLik,rate.vect,new.root.rate,accept,1))
else return(list(edge,logLik,rate.vect,root.rate,accept,0))
}
}
#______________________________________________________
# Main LOG likelihood code
likelihood<-function(edge,a){
lik<-numeric(length(edge[,1]))
for (i in 1:length(edge[,1])){
if (!is.na(edge[i,5])){
beta <-(expm1(edge[i,6]*edge[i,4]))/(exp(edge[i,6]*edge[i,4])-a) #taxonomic likelihood
lik[i]<-log(1-beta) + ((edge[i,5]-1)* log (beta))
}
else {
lik[i]<-log(edge[i,6])-(edge[i,6]*edge[i,4])-log(1-a*exp(-edge[i,6]*edge[i,3]))
#lik[i]<-log(edge[i,6]*((1-a*exp(-edge[i,6]*edge[i,3]))^(-1))*(exp(-edge[i,6]*edge[i,4])))
}
#cat(lik[i],"\n")
}
#cat(lik,"\n", edge[,6],"\n")
lik<-sum(lik)
}
#_________________________________________________________________
# RJ and tree functions
find.clade<-function(edge,x){
if (!is.na(edge[x,5])) clade<-x
else{
nod<-edge[x,2]
start<-which(edge[,1]==nod)
tmp<-which(edge[,1]<edge[start[2],1])
end<-tmp[tmp>start[2]]
clade<-c(x[1],end[1]-1)
if (is.na(clade[2])) clade[2]<-length(edge[,1])
}
clade
}
split<-function(edge,x){
if (!is.na(edge[x,7])) {
stop("that lineage is already split, choose another")
}
edge[x,7]<-1
tmp<-find.clade(edge,x)
group<-max(unique(edge[,8]))+1
oldgroup<-edge[x,8]
if (length(tmp)==1) edge[x,8]<-group
else for (i in tmp[1]:tmp[2]){
if (edge[i,8]!=oldgroup) next
edge[i,8]<-group
}
edge
}
merge<- function(edge,x){
if (is.na(edge[x,7])) {
stop("that lineage is not split, choose another")
}
edge[x,7]<-NA
tmp<-find.clade(edge,x)
oldgroup<-edge[x,8]
d<-which(edge[,2]==edge[x,1])
if (length(d)==0) anc.group<-0
else anc.group<-edge[d,8]
if (length(tmp)==1) edge[x,8]<-anc.group
else for (i in tmp[1]:tmp[2]){
if (edge[i,8]!=oldgroup) next
edge[i,8]<-anc.group
}
edge[edge[,8]>oldgroup,8]<-edge[edge[,8]>oldgroup,8]-1
edge
}
rate.calc<-function(edge,root.rate,rate.vect){
for (i in 1:length(edge[,1])){
d<-which(edge[,2]==edge[i,1])
if (is.na(edge[i,7]) && length(d)==0) edge[i,6]<-root.rate
else if (!is.na(edge[i,7]) && length(d)==0) edge[i,6]<-root.rate*rate.vect[edge[i,8]]
else if (is.na(edge[i,7]) && length(d)==1) edge[i,6]<-edge[d,6]
else if (!is.na(edge[i,7]) && length(d)==1) edge[i,6]<-edge[d,6]*rate.vect[edge[i,8]]
}
edge
}
#_______________________________________________________
# initiallize chain
edge<-rate.calc(edge,root.rate,rate.vect)
logLik<-likelihood(edge,a)
# BEGIN CALCULATION
count.it<-ngen/sfreq
#out.edge <- vector("list",count.it)
#out.logLik <- 1:count.it
#out.rates <- vector("list",count.it)
#out.ratecat <- vector("list",count.it)
#out.rateshift <- vector("list",count.it)
#out.proposal<-1:count.it
#out.accept<-1:count.it
#out.root.rate<-1:count.it
count.i<-1
for(i in (1:ngen)) {
step<-MCMC(logLik,edge,root.rate,a,e,rate.vect,lam,expl)
edge<-step[[1]]
logLik<-step[[2]]
rate.vect<-step[[3]]
root.rate<-step[[4]]
#e<-step[[7]]
if (i==1 || i%%sfreq==0){
#out.edge[[count.i]]<-edge[,6]
#out.logLik[[count.i]]<-logLik
#out.rates[[count.i]]<-rate.vect
#out.ratecat[[count.i]]<-edge[,8]
#out.rateshift[[count.i]] <-edge[,7]
#out.proposal[[count.i]]<-step[[5]]
#out.accept[[count.i]]<-step[[6]]
#out.root.rate[[count.i]]<-root.rate
#cat(e," ",logLik,"\n",edge[,6],"\n",edge[,8],"\n","\n")
plot(phy,cex=0.5)
edgelabels(round(edge[,6],3),frame="n",cex=0.6)
cat(count.i,logLik,edge[,6],"\n", sep=" ", file="divrates", append=TRUE)
cat(edge[,7],"\n", file="divshift", append=TRUE)
cat(step[[5]], step[[6]],"\n", sep=" ", file="accept", append=TRUE)
count.i<-count.i+1
}
}
#list(rate.vect=out.rates,logLik=out.logLik,edge.rates=out.edge,rate.cat=out.ratecat,rate.shift=out.rateshift,proposal=out.proposal, accept=out.accept, root.rate=out.root.rate)
}
| /RJBayesBD_fixed_e.R | no_license | markclements/birth_death_RJ | R | false | false | 8,665 | r | MCMC.BD<-function(phy,diversity,root.rate=0.01,a=0,e=3,ngen=1000000,sfreq=100,lam=1,expl=1){
require(ape)
if (is.null(attr(phy, "order")) || attr(phy, "order") == "cladewise")
phy<- reorder.phylo(phy,"c")
edge<-phy$edge
stem.ages<-branching.times(phy)
edge<-cbind(edge,stem.ages[phy$edge[,1]-Ntip(phy)]) # birth time xi =3
edge<-cbind(edge,phy$edge.length) # branch length or waiting time, ti = 4
edge<-cbind(edge,diversity[phy$edge[,2]])# assign diversity to termainals, NAs are for internals. =5
edge<-cbind(edge,NA) # div rate column = 6
edge<-cbind(edge,NA) # div node split column =7
edge<-cbind(edge,0) # div rate group column = 8
dimnames(edge)<-NULL
rate.vect<-numeric(1)
avge<-e
#_______________________________________________________________________________
# Main MCMC function
MCMC<-function(logLik,edge,root.rate,a,e,rate.vect,lam,expl){
N <-length(which(edge[,7]==1))
if (N==0) z<-sample(c(1,6),1,prob=c(30,60)) # 1=have to split, 6=change root rate
else if (N==length(edge[,1])) z<-sample(c(2,5,6),1,prob=c(33,33,33)) #2=must merge, 5=change rate modifier
else if (N>0 && N<length(edge[,1])) z<-sample(c(3:6),1,prob=c(10,10,30,50))
#cat(a,"\n")
if (z==1){# must split diversity
x<-sample(1:length(edge[,1]),1)
rate.vect.new<-rexp(1)
newedge<-split(edge,x)
newedge<-rate.calc(newedge,root.rate,rate.vect.new)
newlogLik<-likelihood(newedge,a)
HP<-e/2
accept=1
lr <- newlogLik-logLik
ratio <- exp(lr)*HP
#cat(accept," ",logLik," ", newlogLik," ",N," ", ratio, "\n")
if (runif(1,0,1) < ratio) return(list(newedge,newlogLik,rate.vect.new,root.rate,accept,1))
else return(list(edge,logLik,rate.vect,root.rate,accept,0))
}
else if (z==2){# must merge diversity
x<-sample(1:length(edge[,1]),1)
rate.vect.new<-rate.vect[-x]
newedge<-merge(edge,x)
newedge<-rate.calc(newedge,root.rate,rate.vect.new)
newlogLik<-likelihood(newedge,a)
HP<-N/e
accept=2
lr <- newlogLik-logLik
ratio <- exp(lr)*HP
#cat(accept," ",logLik," ", newlogLik," ",N," ", ratio, "\n")
if (runif(1,0,1) < ratio) return(list(newedge,newlogLik,rate.vect.new,root.rate,accept,1))
else return(list(edge,logLik,rate.vect,root.rate,accept,0))
}
else if (z==3){# regular merge
if (N==1){
x<-which(edge[,7]==1)
HP<-2/e
}
else { x<-sample(which(edge[,7]==1),1)
HP<-N/e
}
s<-edge[x,8]
rate.vect.new<-rate.vect[-s]
newedge<-merge(edge,x)
newedge<-rate.calc(newedge,root.rate,rate.vect.new)
newlogLik<-likelihood(newedge,a)
accept=3
lr <- newlogLik-logLik
ratio <- exp(lr)*HP
#cat(accept," ",logLik," ", newlogLik," ",N," ", ratio, "\n")
if (runif(1,0,1) < ratio) return(list(newedge,newlogLik,rate.vect.new,root.rate,accept,1))
else return(list(edge,logLik,rate.vect,root.rate,accept,0))
}
else if (z==4){# regular split
x<-which(is.na(edge[,7]))
if (length(x)>1) x<-sample(x,1)
rate.vect.new<-c(rate.vect,rexp(1))
newedge<-split(edge,x)
newedge<-rate.calc(newedge,root.rate,rate.vect.new)
newlogLik<-likelihood(newedge,a)
HP<-e/(N+1)
accept=4
lr <- newlogLik-logLik
ratio <- exp(lr)*HP
#cat(accept," ",logLik," ", newlogLik," ",N," ", ratio, "\n")
if(runif(1,0,1) < ratio) return(list(newedge,newlogLik,rate.vect.new,root.rate,accept,1))
else return(list(edge,logLik,rate.vect,root.rate,accept,0))
}
else if (z==5){ #change exisiting rate multiplier
#rm<-rexp(1)
if (N==1) x<-which(edge[,7]==1)
else x<-sample(which(edge[,7]==1),1)
s<-edge[x,8]
rate.vect.new<-rate.vect
r<-exp(runif(1,0,1)-0.5)*expl
rate.vect.new[s]<-rate.vect.new[s]*r
newedge<-rate.calc(edge,root.rate,rate.vect.new)
newlogLik<-likelihood(newedge,a)
accept=5
lr <- newlogLik-logLik
ratio <- exp(lr)*r
#cat(accept," ",logLik," ", newlogLik," ",N," ", ratio, "\n")
if(runif(1,0,1) < ratio) return(list(newedge,newlogLik,rate.vect.new,root.rate,accept,1))
else return(list(edge,logLik,rate.vect,root.rate,accept,0))
}
else if (z==6){ #change root rate
#rr<-root.rate + runif(1,-0.05,0.05) # simply add a small value to rate
#rr<-runif(1,root.rate-(lam/2),root.rate+(lam/2)) #
#if (rr<=0) new.root.rate<-0+(0-rr)
#else if (rr>=10) new.root.rate <-10-(rr-10)
#else new.root.rate<-rr
r<-exp(runif(1,0,1)-0.5)*lam #proportionally grow/shrink
new.root.rate<-root.rate*r
newedge<-rate.calc(edge,new.root.rate,rate.vect)
newlogLik<-likelihood(newedge,a)
accept=6
lr <- newlogLik-logLik
#ratio <- exp(lr)
ratio <- exp(lr) * r
#cat(accept," ",logLik," ", newlogLik," ",N," ", ratio, "\n")
if(runif(1,0,1) < ratio) return(list(newedge,newlogLik,rate.vect,new.root.rate,accept,1))
else return(list(edge,logLik,rate.vect,root.rate,accept,0))
}
}
#______________________________________________________
# Main LOG likelihood code
likelihood<-function(edge,a){
lik<-numeric(length(edge[,1]))
for (i in 1:length(edge[,1])){
if (!is.na(edge[i,5])){
beta <-(expm1(edge[i,6]*edge[i,4]))/(exp(edge[i,6]*edge[i,4])-a) #taxonomic likelihood
lik[i]<-log(1-beta) + ((edge[i,5]-1)* log (beta))
}
else {
lik[i]<-log(edge[i,6])-(edge[i,6]*edge[i,4])-log(1-a*exp(-edge[i,6]*edge[i,3]))
#lik[i]<-log(edge[i,6]*((1-a*exp(-edge[i,6]*edge[i,3]))^(-1))*(exp(-edge[i,6]*edge[i,4])))
}
#cat(lik[i],"\n")
}
#cat(lik,"\n", edge[,6],"\n")
lik<-sum(lik)
}
#_________________________________________________________________
# RJ and tree functions
find.clade<-function(edge,x){
if (!is.na(edge[x,5])) clade<-x
else{
nod<-edge[x,2]
start<-which(edge[,1]==nod)
tmp<-which(edge[,1]<edge[start[2],1])
end<-tmp[tmp>start[2]]
clade<-c(x[1],end[1]-1)
if (is.na(clade[2])) clade[2]<-length(edge[,1])
}
clade
}
split<-function(edge,x){
if (!is.na(edge[x,7])) {
stop("that lineage is already split, choose another")
}
edge[x,7]<-1
tmp<-find.clade(edge,x)
group<-max(unique(edge[,8]))+1
oldgroup<-edge[x,8]
if (length(tmp)==1) edge[x,8]<-group
else for (i in tmp[1]:tmp[2]){
if (edge[i,8]!=oldgroup) next
edge[i,8]<-group
}
edge
}
merge<- function(edge,x){
if (is.na(edge[x,7])) {
stop("that lineage is not split, choose another")
}
edge[x,7]<-NA
tmp<-find.clade(edge,x)
oldgroup<-edge[x,8]
d<-which(edge[,2]==edge[x,1])
if (length(d)==0) anc.group<-0
else anc.group<-edge[d,8]
if (length(tmp)==1) edge[x,8]<-anc.group
else for (i in tmp[1]:tmp[2]){
if (edge[i,8]!=oldgroup) next
edge[i,8]<-anc.group
}
edge[edge[,8]>oldgroup,8]<-edge[edge[,8]>oldgroup,8]-1
edge
}
rate.calc<-function(edge,root.rate,rate.vect){
for (i in 1:length(edge[,1])){
d<-which(edge[,2]==edge[i,1])
if (is.na(edge[i,7]) && length(d)==0) edge[i,6]<-root.rate
else if (!is.na(edge[i,7]) && length(d)==0) edge[i,6]<-root.rate*rate.vect[edge[i,8]]
else if (is.na(edge[i,7]) && length(d)==1) edge[i,6]<-edge[d,6]
else if (!is.na(edge[i,7]) && length(d)==1) edge[i,6]<-edge[d,6]*rate.vect[edge[i,8]]
}
edge
}
#_______________________________________________________
# initiallize chain
edge<-rate.calc(edge,root.rate,rate.vect)
logLik<-likelihood(edge,a)
# BEGIN CALCULATION
count.it<-ngen/sfreq
#out.edge <- vector("list",count.it)
#out.logLik <- 1:count.it
#out.rates <- vector("list",count.it)
#out.ratecat <- vector("list",count.it)
#out.rateshift <- vector("list",count.it)
#out.proposal<-1:count.it
#out.accept<-1:count.it
#out.root.rate<-1:count.it
count.i<-1
for(i in (1:ngen)) {
step<-MCMC(logLik,edge,root.rate,a,e,rate.vect,lam,expl)
edge<-step[[1]]
logLik<-step[[2]]
rate.vect<-step[[3]]
root.rate<-step[[4]]
#e<-step[[7]]
if (i==1 || i%%sfreq==0){
#out.edge[[count.i]]<-edge[,6]
#out.logLik[[count.i]]<-logLik
#out.rates[[count.i]]<-rate.vect
#out.ratecat[[count.i]]<-edge[,8]
#out.rateshift[[count.i]] <-edge[,7]
#out.proposal[[count.i]]<-step[[5]]
#out.accept[[count.i]]<-step[[6]]
#out.root.rate[[count.i]]<-root.rate
#cat(e," ",logLik,"\n",edge[,6],"\n",edge[,8],"\n","\n")
plot(phy,cex=0.5)
edgelabels(round(edge[,6],3),frame="n",cex=0.6)
cat(count.i,logLik,edge[,6],"\n", sep=" ", file="divrates", append=TRUE)
cat(edge[,7],"\n", file="divshift", append=TRUE)
cat(step[[5]], step[[6]],"\n", sep=" ", file="accept", append=TRUE)
count.i<-count.i+1
}
}
#list(rate.vect=out.rates,logLik=out.logLik,edge.rates=out.edge,rate.cat=out.ratecat,rate.shift=out.rateshift,proposal=out.proposal, accept=out.accept, root.rate=out.root.rate)
}
|
################################################################################
# In this file, we scrape and enrich the data for the African-American "firsts"
# we crawl several wikipedia pages using rvest
# we get geolocations using opencage
# we infer sex using the gender package
################################################################################
# load libraries
library(tidyverse)
library(vroom)
library(janitor)
library(sf)
library(here)
library(extrafont)
library(ggtext)
library(lubridate)
library(rvest)
library(parsedate)
library(opencage)
library(gender)
################################################################################
# SCRAPING FIRSTS
# Here we scrape African-American "firsts" from
# https://en.wikipedia.org/wiki/List_of_African-American_firsts
# The code is inspired by
# https://github.com/rfordatascience/tidytuesday/tree/master/data/2020/2020-06-09
################################################################################
first_url <- "https://en.wikipedia.org/wiki/List_of_African-American_firsts"
# read complete wikipedia page
raw_first <- read_html(first_url)
# function to extract the year of the firsts from the raw HTML code
get_year <- function(id_num){
raw_first %>%
html_nodes(glue::glue("#mw-content-text > div > h4:nth-child({id_num}) > span.mw-headline")) %>%
html_attr("id")
}
# function to extract the complete lines of the "firsts" from the raw HTML code
get_first <- function(id_num){
raw_first %>%
html_nodes(glue::glue("#mw-content-text > div > ul:nth-child({id_num}) > li")) %>%
lapply(function(x) x)
}
# function to extract the link to the wikipedia page of the person, that has achieved the "first"
extract_website <- function(x) {
x %>%
str_replace(":.*?<a", ": <a") %>%
str_extract(": <a href=\\\".*?\\\"") %>%
str_extract("/wiki.*?\\\"") %>%
str_replace("\\\"", "")
}
# function to extract the concrete description of the "first"
extract_first <- function(x) {
x %>%
str_extract("^First.*?:") %>%
str_replace(":", "")
}
# function to extract the name of the person, that has achieved the "first"
extract_name <- function(x) {
x %>%
str_replace(":.*?<a", ": <a") %>%
str_extract(": <a href=\\\".*?\\\">") %>%
str_extract("title=.*\\\">") %>%
str_replace("title=\\\"", "") %>%
str_replace("\\\">", "")
}
# find years and complete lines of the "firsts"
raw_first_df <- tibble(id_num = 1:409) %>%
mutate(year = map(id_num, get_year),
data = map(id_num, get_first))
# clean the parsed data
clean_first <- raw_first_df %>%
# save year as integer
mutate(year = as.integer(year)) %>%
# fill empty year cells with the last existing value for year
fill(year) %>%
unnest(data) %>%
mutate(
# get raw html string (with tags) for the complete lines of the "firsts"
data_string_raw = map_chr(data, toString),
# get only html text (without tags) for the complete lines of the "firsts
data_string_cle = map_chr(data, html_text)) %>%
mutate(
# get the link to the wikipedia page of the person, that has achieved the "first"
wiki = map_chr(data_string_raw, extract_website),
# get the concrete description of the "first"
first = map_chr(data_string_cle, extract_first),
# get the name of the person, that has achieved the "first"
name = map_chr(data_string_raw, extract_name))
################################################################################
# We also want to know, which kind of "first" was achieved,
# i.e. we want to map each "first" into a category.
# Hence, we define words that are indicators for specific categories.
# If we find such a word in the description of a "first", we categorize
# this "first" accordingly.
################################################################################
edu <- c(
"practice", "graduate", "learning", "college", "university", "medicine",
"earn", "ph.d.", "professor", "teacher", "school", "nobel", "invent", "patent",
"medicine", "degree", "doctor", "medical", "nurse", "physician", "m.d.", "b.a.", "b.s.", "m.b.a",
"principal", "space", "astronaut", "scientific") %>%
paste0(collapse = "|")
religion <- c("bishop", "rabbi", "minister", "church", "priest", "pastor", "missionary",
"denomination", "jesus", "jesuits", "diocese", "buddhis", "cardinal") %>%
paste0(collapse = "|")
politics <- c(
"diplomat", "elected", "nominee", "supreme court", "legislature", "mayor", "governor",
"vice President", "president", "representatives", "political", "department", "peace prize",
"ambassador", "government", "white house", "postal", "federal", "union", "trade",
"delegate", "alder", "solicitor", "senator", "intelligience", "combat", "commissioner",
"state", "first lady", "cabinet", "advisor", "guard", "coast", "secretary", "senate",
"house", "agency", "staff", "national committee", "lie in honor") %>%
paste0(collapse = "|")
sports <- c(
"baseball", "football", "basketball", "hockey", "golf", "tennis",
"championship", "boxing", "games", "medal", "game", "sport", "olympic", "nascar",
"coach", "trophy", "nba", "nhl", "nfl", "mlb", "stanley cup", "jockey", "pga",
"race", "driver", "ufc", "champion", "highest finishing position") %>%
paste0(collapse = "|")
military <- c(
"serve", "military", "enlist", "officer", "army", "marine", "naval",
"officer", "captain", "command", "admiral", "prison", "navy", "general",
"force") %>%
paste0(collapse = "|")
law <- c("american bar", "lawyer", "police", "judge", "attorney", "law",
"agent", "fbi") %>%
paste0(collapse = "|")
arts <- c(
"opera", "sing", "perform", "music", "billboard", "oscar", "television",
"movie", "network", "tony award", "paint", "author", "book", "academy award", "curator",
"director", "publish", "novel", "grammy", "emmy", "smithsonian",
"conduct", "picture", "pulitzer", "channel", "villain", "cartoon", "tv", "golden globe",
"comic", "magazine", "superhero", "pulitzer", "dancer", "opry", "rock and roll", "radio",
"record") %>%
paste0(collapse = "|")
social <- c("community", "freemasons", "vote", "voting", "rights", "signature",
"royal", "ceo", "community", "movement", "invited", "greek", "million",
"billion", "attendant", "chess", "pilot", "playboy", "own", "daughter",
"coin", "dollar", "stamp", "niagara", "pharmacist",
"stock", "north pole", "reporter", "sail around the world", "sail solo around the world", "press", "miss ",
"everest") %>%
paste0(collapse = "|")
# categorize "firsts" by looking for indicator words
first_df <- clean_first %>%
mutate(category = case_when(
str_detect(tolower(first), military) ~ "Military",
str_detect(tolower(first), law) ~ "Law",
str_detect(tolower(first), arts) ~ "Arts & Entertainment",
str_detect(tolower(first), social) ~ "Social & Jobs",
str_detect(tolower(first), religion) ~ "Religion",
str_detect(tolower(first), edu) ~ "Education & Science",
str_detect(tolower(first), politics) ~ "Politics",
str_detect(tolower(first), sports) ~ "Sports",
TRUE ~ NA_character_
)) %>%
drop_na() %>%
rename(accomplishment = first)
# clean up variables
rm(arts, edu, law, first_url, military, politics, religion, social, sports,
extract_first, extract_name, extract_website, get_first, get_year, raw_first, raw_first_df, clean_first)
################################################################################
# AUGMENTING WITH BDAY AND LOCATION
# We now parse the wikipedia page of the persons, that have achieved the "firsts"
# to get information about their location and birthday
################################################################################
# function to get the location and birthday given a wikipedia link
extract_bday_location <- function(wiki){
# read complete wikipedia page
html <- read_html(paste0("https://en.wikipedia.org", wiki))
# extract birthdays
bd <- html %>%
html_node(glue::glue('span[class="bday"]')) %>%
html_text()
if(is.na(bd)){
bd <- html %>%
html_node("table.vcard") %>%
toString() %>%
str_replace_all("\\n", "") %>%
str_extract("Born.*?</td>") %>%
str_extract("<td>.*?<") %>%
str_replace("<td>", "") %>%
str_replace("<", "")
bd <- bd %>%
str_replace("\\(.*", "") %>%
str_trim() %>%
str_replace_all("[^[:alnum:] ]", "") %>%
# convert parsed birthday string to a date
parse_date(approx = TRUE)
}
if(!is.na(bd)){
bd <- toString(bd)
}
# extract locations
lo <- html %>%
html_node("table.vcard") %>%
toString() %>%
str_replace_all("\\n", "") %>%
str_extract("Born.*?</td>") %>%
str_replace("Born</th>", "")
if(length(str_locate_all(lo, "<br>")[[1]]) == 4){
lo <- str_replace(lo, "<br>", "")
}
lo <- lo %>% str_extract("<br><.*?</td>$")
if(!is.na(lo)){
lo <- lo %>%
read_html() %>%
html_text()
}
return(list(bd, lo))
}
# extract birthday and location and store them in new columns
first_df_augmented <- suppressMessages(first_df %>%
# extract birthday and location form wikipedia
mutate(combi = map(wiki, extract_bday_location)) %>%
# unnest birthday and location into separate columns
unnest_wider(combi) %>%
# rename new columns
rename(bday = `...1`, location = `...2`) %>%
mutate(bday = map_chr(bday, function(x) x))) %>%
# it is possible that there was a mistake with the birthday --> filter those out
mutate(bday = ifelse(year(bday) == 2020, NA_character_, bday))
################################################################################
# AUGMENTING WITH GENDER
# In this step we try to infer the sex of a person, that has achieved a "first"
################################################################################
# add gender
# see if we find words in the description of the "first", that identify gender
first_df_augmented <- first_df_augmented %>%
mutate(gender = if_else(str_detect(data_string_cle,
"\\swoman\\s|\\sWoman\\s|\\sher\\s|\\sshe\\s|\\sfemale\\s"),
"female",
if_else(str_detect(data_string_cle,
"\\sman\\s|\\sMan\\s|\\shim\\s|\\she\\s|\\smale\\s"),
"male",
"idk")))
# use gender package as second source of info (parse first name)
# input: full name and the year of the "first"
get_gender <- function(name, year){
# get first name
name <- strsplit(name, split = " ")[[1]][1]
# define right method (see ?gender)
method = ifelse(year < 1930, "ipums", "ssa")
# get the gender
ret <- gender(name, method = method, countries = "United States") %>%
select(gender) %>%
pull()
if(typeof(ret) == "logical"){
return(NA_character_)
}
else{
return(ret)
}
}
# build final "gender" column
first_df_augmented <- first_df_augmented %>%
# use first name and year to infer gender
mutate(gender_2 = map2(name, year, get_gender)) %>%
mutate(gender_2 = map_chr(gender_2, function(x) x)) %>%
# combine both gender columns into one final column
mutate(gender = if_else(gender != "idk", gender, gender_2)) %>%
select(-gender_2)
################################################################################
# AUGMENTING WITH GEOLOCATION
# To be able to visualise our findings using maps, we need the geolocations
# We use the opencage package to get lng/lat
################################################################################
# add lng / lat, i.e. geocode locations
opencage_custom <- function(x) {
if(is.na(x)){
return(NA_character_)
}
else{
return(opencage_forward(x, limit = 1))
}
}
first_df_augmented <- suppressMessages(first_df_augmented %>%
# get information from opencage
mutate(location_geo = map(location, opencage_custom)) %>%
# parse and clean the information from opencage
unnest_wider(location_geo) %>%
unnest(results, keep_empty = TRUE) %>%
rename(lat = geometry.lat,
lng = geometry.lng,
country = components.country,
state = components.state,
county = components.county,
city = components.city,
FIPS_state = annotations.FIPS.state) %>%
select(id_num, year, data_string_raw, data_string_cle, wiki,
accomplishment, name, category, bday, gender,
location, lat, lng, country, state, county, city, FIPS_state))
# write the file as a csv
# write_csv(first_df_augmented, path = "firsts_augmented.csv")
| /code/v1/scraping_data.R | no_license | m-laube/am10.sg10 | R | false | false | 13,687 | r | ################################################################################
# In this file, we scrape and enrich the data for the African-American "firsts"
# we crawl several wikipedia pages using rvest
# we get geolocations using opencage
# we infer sex using the gender package
################################################################################
# load libraries
library(tidyverse)
library(vroom)
library(janitor)
library(sf)
library(here)
library(extrafont)
library(ggtext)
library(lubridate)
library(rvest)
library(parsedate)
library(opencage)
library(gender)
################################################################################
# SCRAPING FIRSTS
# Here we scrape African-American "firsts" from
# https://en.wikipedia.org/wiki/List_of_African-American_firsts
# The code is inspired by
# https://github.com/rfordatascience/tidytuesday/tree/master/data/2020/2020-06-09
################################################################################
first_url <- "https://en.wikipedia.org/wiki/List_of_African-American_firsts"
# read complete wikipedia page
raw_first <- read_html(first_url)
# function to extract the year of the firsts from the raw HTML code
get_year <- function(id_num){
raw_first %>%
html_nodes(glue::glue("#mw-content-text > div > h4:nth-child({id_num}) > span.mw-headline")) %>%
html_attr("id")
}
# function to extract the complete lines of the "firsts" from the raw HTML code
get_first <- function(id_num){
raw_first %>%
html_nodes(glue::glue("#mw-content-text > div > ul:nth-child({id_num}) > li")) %>%
lapply(function(x) x)
}
# function to extract the link to the wikipedia page of the person, that has achieved the "first"
extract_website <- function(x) {
x %>%
str_replace(":.*?<a", ": <a") %>%
str_extract(": <a href=\\\".*?\\\"") %>%
str_extract("/wiki.*?\\\"") %>%
str_replace("\\\"", "")
}
# function to extract the concrete description of the "first"
extract_first <- function(x) {
x %>%
str_extract("^First.*?:") %>%
str_replace(":", "")
}
# function to extract the name of the person, that has achieved the "first"
extract_name <- function(x) {
x %>%
str_replace(":.*?<a", ": <a") %>%
str_extract(": <a href=\\\".*?\\\">") %>%
str_extract("title=.*\\\">") %>%
str_replace("title=\\\"", "") %>%
str_replace("\\\">", "")
}
# find years and complete lines of the "firsts"
raw_first_df <- tibble(id_num = 1:409) %>%
mutate(year = map(id_num, get_year),
data = map(id_num, get_first))
# clean the parsed data
clean_first <- raw_first_df %>%
# save year as integer
mutate(year = as.integer(year)) %>%
# fill empty year cells with the last existing value for year
fill(year) %>%
unnest(data) %>%
mutate(
# get raw html string (with tags) for the complete lines of the "firsts"
data_string_raw = map_chr(data, toString),
# get only html text (without tags) for the complete lines of the "firsts
data_string_cle = map_chr(data, html_text)) %>%
mutate(
# get the link to the wikipedia page of the person, that has achieved the "first"
wiki = map_chr(data_string_raw, extract_website),
# get the concrete description of the "first"
first = map_chr(data_string_cle, extract_first),
# get the name of the person, that has achieved the "first"
name = map_chr(data_string_raw, extract_name))
################################################################################
# We also want to know, which kind of "first" was achieved,
# i.e. we want to map each "first" into a category.
# Hence, we define words that are indicators for specific categories.
# If we find such a word in the description of a "first", we categorize
# this "first" accordingly.
################################################################################
edu <- c(
"practice", "graduate", "learning", "college", "university", "medicine",
"earn", "ph.d.", "professor", "teacher", "school", "nobel", "invent", "patent",
"medicine", "degree", "doctor", "medical", "nurse", "physician", "m.d.", "b.a.", "b.s.", "m.b.a",
"principal", "space", "astronaut", "scientific") %>%
paste0(collapse = "|")
religion <- c("bishop", "rabbi", "minister", "church", "priest", "pastor", "missionary",
"denomination", "jesus", "jesuits", "diocese", "buddhis", "cardinal") %>%
paste0(collapse = "|")
politics <- c(
"diplomat", "elected", "nominee", "supreme court", "legislature", "mayor", "governor",
"vice President", "president", "representatives", "political", "department", "peace prize",
"ambassador", "government", "white house", "postal", "federal", "union", "trade",
"delegate", "alder", "solicitor", "senator", "intelligience", "combat", "commissioner",
"state", "first lady", "cabinet", "advisor", "guard", "coast", "secretary", "senate",
"house", "agency", "staff", "national committee", "lie in honor") %>%
paste0(collapse = "|")
sports <- c(
"baseball", "football", "basketball", "hockey", "golf", "tennis",
"championship", "boxing", "games", "medal", "game", "sport", "olympic", "nascar",
"coach", "trophy", "nba", "nhl", "nfl", "mlb", "stanley cup", "jockey", "pga",
"race", "driver", "ufc", "champion", "highest finishing position") %>%
paste0(collapse = "|")
military <- c(
"serve", "military", "enlist", "officer", "army", "marine", "naval",
"officer", "captain", "command", "admiral", "prison", "navy", "general",
"force") %>%
paste0(collapse = "|")
law <- c("american bar", "lawyer", "police", "judge", "attorney", "law",
"agent", "fbi") %>%
paste0(collapse = "|")
arts <- c(
"opera", "sing", "perform", "music", "billboard", "oscar", "television",
"movie", "network", "tony award", "paint", "author", "book", "academy award", "curator",
"director", "publish", "novel", "grammy", "emmy", "smithsonian",
"conduct", "picture", "pulitzer", "channel", "villain", "cartoon", "tv", "golden globe",
"comic", "magazine", "superhero", "pulitzer", "dancer", "opry", "rock and roll", "radio",
"record") %>%
paste0(collapse = "|")
social <- c("community", "freemasons", "vote", "voting", "rights", "signature",
"royal", "ceo", "community", "movement", "invited", "greek", "million",
"billion", "attendant", "chess", "pilot", "playboy", "own", "daughter",
"coin", "dollar", "stamp", "niagara", "pharmacist",
"stock", "north pole", "reporter", "sail around the world", "sail solo around the world", "press", "miss ",
"everest") %>%
paste0(collapse = "|")
# categorize "firsts" by looking for indicator words
first_df <- clean_first %>%
mutate(category = case_when(
str_detect(tolower(first), military) ~ "Military",
str_detect(tolower(first), law) ~ "Law",
str_detect(tolower(first), arts) ~ "Arts & Entertainment",
str_detect(tolower(first), social) ~ "Social & Jobs",
str_detect(tolower(first), religion) ~ "Religion",
str_detect(tolower(first), edu) ~ "Education & Science",
str_detect(tolower(first), politics) ~ "Politics",
str_detect(tolower(first), sports) ~ "Sports",
TRUE ~ NA_character_
)) %>%
drop_na() %>%
rename(accomplishment = first)
# clean up variables
rm(arts, edu, law, first_url, military, politics, religion, social, sports,
extract_first, extract_name, extract_website, get_first, get_year, raw_first, raw_first_df, clean_first)
################################################################################
# AUGMENTING WITH BDAY AND LOCATION
# We now parse the wikipedia page of the persons, that have achieved the "firsts"
# to get information about their location and birthday
################################################################################
# function to get the location and birthday given a wikipedia link
extract_bday_location <- function(wiki){
# read complete wikipedia page
html <- read_html(paste0("https://en.wikipedia.org", wiki))
# extract birthdays
bd <- html %>%
html_node(glue::glue('span[class="bday"]')) %>%
html_text()
if(is.na(bd)){
bd <- html %>%
html_node("table.vcard") %>%
toString() %>%
str_replace_all("\\n", "") %>%
str_extract("Born.*?</td>") %>%
str_extract("<td>.*?<") %>%
str_replace("<td>", "") %>%
str_replace("<", "")
bd <- bd %>%
str_replace("\\(.*", "") %>%
str_trim() %>%
str_replace_all("[^[:alnum:] ]", "") %>%
# convert parsed birthday string to a date
parse_date(approx = TRUE)
}
if(!is.na(bd)){
bd <- toString(bd)
}
# extract locations
lo <- html %>%
html_node("table.vcard") %>%
toString() %>%
str_replace_all("\\n", "") %>%
str_extract("Born.*?</td>") %>%
str_replace("Born</th>", "")
if(length(str_locate_all(lo, "<br>")[[1]]) == 4){
lo <- str_replace(lo, "<br>", "")
}
lo <- lo %>% str_extract("<br><.*?</td>$")
if(!is.na(lo)){
lo <- lo %>%
read_html() %>%
html_text()
}
return(list(bd, lo))
}
# extract birthday and location and store them in new columns
first_df_augmented <- suppressMessages(first_df %>%
# extract birthday and location form wikipedia
mutate(combi = map(wiki, extract_bday_location)) %>%
# unnest birthday and location into separate columns
unnest_wider(combi) %>%
# rename new columns
rename(bday = `...1`, location = `...2`) %>%
mutate(bday = map_chr(bday, function(x) x))) %>%
# it is possible that there was a mistake with the birthday --> filter those out
mutate(bday = ifelse(year(bday) == 2020, NA_character_, bday))
################################################################################
# AUGMENTING WITH GENDER
# In this step we try to infer the sex of a person, that has achieved a "first"
################################################################################
# add gender
# see if we find words in the description of the "first", that identify gender
first_df_augmented <- first_df_augmented %>%
mutate(gender = if_else(str_detect(data_string_cle,
"\\swoman\\s|\\sWoman\\s|\\sher\\s|\\sshe\\s|\\sfemale\\s"),
"female",
if_else(str_detect(data_string_cle,
"\\sman\\s|\\sMan\\s|\\shim\\s|\\she\\s|\\smale\\s"),
"male",
"idk")))
# use gender package as second source of info (parse first name)
# input: full name and the year of the "first"
get_gender <- function(name, year){
# get first name
name <- strsplit(name, split = " ")[[1]][1]
# define right method (see ?gender)
method = ifelse(year < 1930, "ipums", "ssa")
# get the gender
ret <- gender(name, method = method, countries = "United States") %>%
select(gender) %>%
pull()
if(typeof(ret) == "logical"){
return(NA_character_)
}
else{
return(ret)
}
}
# build final "gender" column
first_df_augmented <- first_df_augmented %>%
# use first name and year to infer gender
mutate(gender_2 = map2(name, year, get_gender)) %>%
mutate(gender_2 = map_chr(gender_2, function(x) x)) %>%
# combine both gender columns into one final column
mutate(gender = if_else(gender != "idk", gender, gender_2)) %>%
select(-gender_2)
################################################################################
# AUGMENTING WITH GEOLOCATION
# To be able to visualise our findings using maps, we need the geolocations
# We use the opencage package to get lng/lat
################################################################################
# add lng / lat, i.e. geocode locations
opencage_custom <- function(x) {
if(is.na(x)){
return(NA_character_)
}
else{
return(opencage_forward(x, limit = 1))
}
}
first_df_augmented <- suppressMessages(first_df_augmented %>%
# get information from opencage
mutate(location_geo = map(location, opencage_custom)) %>%
# parse and clean the information from opencage
unnest_wider(location_geo) %>%
unnest(results, keep_empty = TRUE) %>%
rename(lat = geometry.lat,
lng = geometry.lng,
country = components.country,
state = components.state,
county = components.county,
city = components.city,
FIPS_state = annotations.FIPS.state) %>%
select(id_num, year, data_string_raw, data_string_cle, wiki,
accomplishment, name, category, bday, gender,
location, lat, lng, country, state, county, city, FIPS_state))
# write the file as a csv
# write_csv(first_df_augmented, path = "firsts_augmented.csv")
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wikiPathways.R
\name{get_wp_organisms}
\alias{get_wp_organisms}
\title{get_wp_organism}
\usage{
get_wp_organisms()
}
\value{
supported organism list
}
\description{
list supported organism of WikiPathways
}
\details{
This function extracts information from 'https://wikipathways-data.wmcloud.org/current/gmt/'
and lists all supported organisms
}
\author{
Guangchuang Yu
}
| /man/get_wp_organisms.Rd | no_license | YuLab-SMU/clusterProfiler | R | false | true | 450 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wikiPathways.R
\name{get_wp_organisms}
\alias{get_wp_organisms}
\title{get_wp_organism}
\usage{
get_wp_organisms()
}
\value{
supported organism list
}
\description{
list supported organism of WikiPathways
}
\details{
This function extracts information from 'https://wikipathways-data.wmcloud.org/current/gmt/'
and lists all supported organisms
}
\author{
Guangchuang Yu
}
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{hole_shape}
\alias{hole_shape}
\title{A shapefile with a hole}
\format{
An object of class \code{SpatialPolygonsDataFrame} with 1 rows and 1 columns.
}
\usage{
hole_shape
}
\description{
A shapefile with a hole
}
\keyword{datasets}
| /windfarmGA/man/hole_shape.Rd | no_license | akhikolla/InformationHouse | R | false | true | 354 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{hole_shape}
\alias{hole_shape}
\title{A shapefile with a hole}
\format{
An object of class \code{SpatialPolygonsDataFrame} with 1 rows and 1 columns.
}
\usage{
hole_shape
}
\description{
A shapefile with a hole
}
\keyword{datasets}
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/removeNonASCII.R
\name{removeNonASCII}
\alias{removeNonASCII}
\title{Remove all non-ascii characters from a data.frame}
\usage{
removeNonASCII(df)
}
\arguments{
\item{df}{[`data.frame`] to purge of non-ASCII character}
}
\value{
[`data.frame`] with all character columns stripped of non-ASCII characters
}
\description{
Remove all non-ascii characters from a data.frame
}
| /rPharmacoDI/man/removeNonASCII.Rd | no_license | bhklab/DataIngestion | R | false | true | 450 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/removeNonASCII.R
\name{removeNonASCII}
\alias{removeNonASCII}
\title{Remove all non-ascii characters from a data.frame}
\usage{
removeNonASCII(df)
}
\arguments{
\item{df}{[`data.frame`] to purge of non-ASCII character}
}
\value{
[`data.frame`] with all character columns stripped of non-ASCII characters
}
\description{
Remove all non-ascii characters from a data.frame
}
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transaction.R
\name{charge_authorization}
\alias{charge_authorization}
\title{Charge Authorization}
\usage{
charge_authorization(authorization, ...)
}
\arguments{
\item{authorization}{set_keys("", "SECRET_KEY")$secret,
equivalent of "-H Authorization: Bearer SECRET_kEY"}
\item{...}{Body Params}
\item{amount}{int32. REQUIRED
Amount in kobo}
\item{authorization_code}{string. REQUIRED
Authorization code representing card you want charged}
\item{email}{string. REQUIRED
Customer's email address}
\item{plan}{string.
If transaction is to create a subscription to a predefined plan, provide plan code here.}
\item{quantity}{float.
Used to apply a multiple to the amount returned by the plan code above.}
\item{invoice_limit}{int32.
Number of invoices to raise during the subscription. Overrides invoice_limit set on plan.}
\item{currency}{string.
Currency in which amount should be charged}
\item{metadata}{object.
JSON object. Add a custom_fields attribute which has an array of objects if you would like the fields to be added to your transaction when displayed on the dashboard. Sample: {"custom_fields":[{"display_name":"Cart ID","variable_name":"cart_id","value":"8393"}]}}
\item{subaccount}{string.
The code for the subaccount that owns the payment. e.g. ACCT_8f4s1eq7ml6rlzj}
\item{transaction_charge}{int32.
A flat fee to charge the subaccount for this transaction, in kobo. This overrides the split percentage set when the subaccount was created. Ideally, you will need to use this if you are splitting in flat rates (since subaccount creation only allows for percentage split). e.g. 7000 for a 70 naira flat fee.}
\item{bearer}{string.
Who bears Paystack charges? account or subaccount.}
\item{queue}{boolean.
If you are making a scheduled charge call, it is a good idea to queue them so the processing system does not get overloaded causing transaction processing errors. Send queue:true to take advantage of our queued charging.}
}
\value{
}
\description{
Charge Authorization
}
\details{
This will only work for authorizations with for which reusable is true
}
| /man/charge_authorization.Rd | no_license | Wenmeilin/paystack | R | false | true | 2,223 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transaction.R
\name{charge_authorization}
\alias{charge_authorization}
\title{Charge Authorization}
\usage{
charge_authorization(authorization, ...)
}
\arguments{
\item{authorization}{set_keys("", "SECRET_KEY")$secret,
equivalent of "-H Authorization: Bearer SECRET_kEY"}
\item{...}{Body Params}
\item{amount}{int32. REQUIRED
Amount in kobo}
\item{authorization_code}{string. REQUIRED
Authorization code representing card you want charged}
\item{email}{string. REQUIRED
Customer's email address}
\item{plan}{string.
If transaction is to create a subscription to a predefined plan, provide plan code here.}
\item{quantity}{float.
Used to apply a multiple to the amount returned by the plan code above.}
\item{invoice_limit}{int32.
Number of invoices to raise during the subscription. Overrides invoice_limit set on plan.}
\item{currency}{string.
Currency in which amount should be charged}
\item{metadata}{object.
JSON object. Add a custom_fields attribute which has an array of objects if you would like the fields to be added to your transaction when displayed on the dashboard. Sample: {"custom_fields":[{"display_name":"Cart ID","variable_name":"cart_id","value":"8393"}]}}
\item{subaccount}{string.
The code for the subaccount that owns the payment. e.g. ACCT_8f4s1eq7ml6rlzj}
\item{transaction_charge}{int32.
A flat fee to charge the subaccount for this transaction, in kobo. This overrides the split percentage set when the subaccount was created. Ideally, you will need to use this if you are splitting in flat rates (since subaccount creation only allows for percentage split). e.g. 7000 for a 70 naira flat fee.}
\item{bearer}{string.
Who bears Paystack charges? account or subaccount.}
\item{queue}{boolean.
If you are making a scheduled charge call, it is a good idea to queue them so the processing system does not get overloaded causing transaction processing errors. Send queue:true to take advantage of our queued charging.}
}
\value{
}
\description{
Charge Authorization
}
\details{
This will only work for authorizations with for which reusable is true
}
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/brmsfit-methods.R
\name{residuals.brmsfit}
\alias{residuals.brmsfit}
\alias{predictive_error.brmsfit}
\alias{predictive_error}
\title{Extract Model Residuals from brmsfit Objects}
\usage{
\method{residuals}{brmsfit}(object, newdata = NULL, re_formula = NULL,
type = c("ordinary", "pearson"), method = c("fitted", "predict"),
allow_new_levels = FALSE, sample_new_levels = "uncertainty",
new_objects = list(), incl_autocor = TRUE, resp = NULL, subset = NULL,
nsamples = NULL, sort = FALSE, nug = NULL, summary = TRUE,
robust = FALSE, probs = c(0.025, 0.975), ...)
\method{predictive_error}{brmsfit}(object, newdata = NULL,
re_formula = NULL, re.form = NULL, allow_new_levels = FALSE,
sample_new_levels = "uncertainty", new_objects = list(),
incl_autocor = TRUE, resp = NULL, subset = NULL, nsamples = NULL,
sort = FALSE, nug = NULL, robust = FALSE, probs = c(0.025, 0.975),
...)
}
\arguments{
\item{object}{An object of class \code{brmsfit}}
\item{newdata}{An optional data.frame for which to evaluate predictions.
If \code{NULL} (default), the orginal data of the model is used.}
\item{re_formula}{formula containing group-level effects
to be considered in the prediction.
If \code{NULL} (default), include all group-level effects;
if \code{NA}, include no group-level effects.}
\item{type}{The type of the residuals,
either \code{"ordinary"} or \code{"pearson"}.
More information is provided under 'Details'.}
\item{method}{Indicates the method to compute
model implied values. Either \code{"fitted"}
(predicted values of the regression curve) or
\code{"predict"} (predicted response values).
Using \code{"predict"} is recommended
but \code{"fitted"} is the current default for
reasons of backwards compatibility.}
\item{allow_new_levels}{A flag indicating if new
levels of group-level effects are allowed
(defaults to \code{FALSE}).
Only relevant if \code{newdata} is provided.}
\item{sample_new_levels}{Indicates how to sample new levels
for grouping factors specified in \code{re_formula}.
This argument is only relevant if \code{newdata} is provided and
\code{allow_new_levels} is set to \code{TRUE}.
If \code{"uncertainty"} (default), include group-level uncertainty
in the predictions based on the variation of the existing levels.
If \code{"gaussian"}, sample new levels from the (multivariate)
normal distribution implied by the group-level standard deviations
and correlations. This options may be useful for conducting
Bayesian power analysis.
If \code{"old_levels"}, directly sample new levels from the
existing levels.}
\item{new_objects}{A named \code{list} of objects containing
new data, which cannot be passed via argument \code{newdata}.
Currently, only required for objects passed to
\code{\link[brms:cor_sar]{cor_sar}} and
\code{\link[brms:cor_fixed]{cor_fixed}}.}
\item{incl_autocor}{A flag indicating if ARMA autocorrelation
parameters should be included in the predictions. Defaults to
\code{TRUE}. Setting it to \code{FALSE} will not affect other
correlation structures such as \code{\link[brms:cor_bsts]{cor_bsts}},
or \code{\link[brms:cor_fixed]{cor_fixed}}.}
\item{resp}{Optional names of response variables.
If specified, fitted values of these response variables are returned.}
\item{subset}{A numeric vector specifying
the posterior samples to be used.
If \code{NULL} (the default), all samples are used.}
\item{nsamples}{Positive integer indicating how many
posterior samples should be used.
If \code{NULL} (the default) all samples are used.
Ignored if \code{subset} is not \code{NULL}.}
\item{sort}{Logical. Only relevant for time series models.
Indicating whether to return predicted values in the original
order (\code{FALSE}; default) or in the order of the
time series (\code{TRUE}).}
\item{nug}{Small positive number for Gaussian process terms only.
For numerical reasons, the covariance matrix of a Gaussian
process might not be positive definite. Adding a very small
number to the matrix's diagonal often solves this problem.
If \code{NULL} (the default), \code{nug} is chosen internally.}
\item{summary}{Should summary statistics
(i.e. means, sds, and 95\% intervals) be returned
instead of the raw values? Default is \code{TRUE}.}
\item{robust}{If \code{FALSE} (the default) the mean is used as
the measure of central tendency and the standard deviation as
the measure of variability. If \code{TRUE}, the median and the
median absolute deivation (MAD) are applied instead.
Only used if \code{summary} is \code{TRUE}.}
\item{probs}{The percentiles to be computed by the \code{quantile}
function. Only used if \code{summary} is \code{TRUE}.}
\item{...}{Currently ignored.}
\item{re.form}{Alias of \code{re_formula}.}
}
\value{
Model residuals. If \code{summary = TRUE}
this is a N x C matrix and if \code{summary = FALSE}
a S x N matrix, where S is the number of samples,
N is the number of observations, and C is equal to
\code{length(probs) + 2}.
}
\description{
Extract Model Residuals from brmsfit Objects
}
\details{
Residuals of type \code{ordinary}
are of the form \eqn{R = Y - Yp}, where \eqn{Y} is the observed
and \eqn{Yp} is the predicted response.
Residuals of type \code{pearson} are
of the form \eqn{R = (Y - Yp) / SD(Y)},
where \eqn{SD(Y)} is an estimation of the standard deviation
of \eqn{Y}.
Currently, \code{residuals.brmsfit} does not support
\code{categorical} or ordinal models.
Method \code{predictive_error.brmsfit} is an alias of
\code{residuals.brmsfit} with \code{method = "predict"} and
\code{summary = FALSE}.
}
\examples{
\dontrun{
## fit a model
fit <- brm(rating ~ treat + period + carry + (1|subject),
data = inhaler, cores = 2)
## extract residuals
res <- residuals(fit, summary = TRUE)
head(res)
}
}
| /man/residuals.brmsfit.Rd | no_license | famuvie/brms | R | false | true | 5,875 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/brmsfit-methods.R
\name{residuals.brmsfit}
\alias{residuals.brmsfit}
\alias{predictive_error.brmsfit}
\alias{predictive_error}
\title{Extract Model Residuals from brmsfit Objects}
\usage{
\method{residuals}{brmsfit}(object, newdata = NULL, re_formula = NULL,
type = c("ordinary", "pearson"), method = c("fitted", "predict"),
allow_new_levels = FALSE, sample_new_levels = "uncertainty",
new_objects = list(), incl_autocor = TRUE, resp = NULL, subset = NULL,
nsamples = NULL, sort = FALSE, nug = NULL, summary = TRUE,
robust = FALSE, probs = c(0.025, 0.975), ...)
\method{predictive_error}{brmsfit}(object, newdata = NULL,
re_formula = NULL, re.form = NULL, allow_new_levels = FALSE,
sample_new_levels = "uncertainty", new_objects = list(),
incl_autocor = TRUE, resp = NULL, subset = NULL, nsamples = NULL,
sort = FALSE, nug = NULL, robust = FALSE, probs = c(0.025, 0.975),
...)
}
\arguments{
\item{object}{An object of class \code{brmsfit}}
\item{newdata}{An optional data.frame for which to evaluate predictions.
If \code{NULL} (default), the orginal data of the model is used.}
\item{re_formula}{formula containing group-level effects
to be considered in the prediction.
If \code{NULL} (default), include all group-level effects;
if \code{NA}, include no group-level effects.}
\item{type}{The type of the residuals,
either \code{"ordinary"} or \code{"pearson"}.
More information is provided under 'Details'.}
\item{method}{Indicates the method to compute
model implied values. Either \code{"fitted"}
(predicted values of the regression curve) or
\code{"predict"} (predicted response values).
Using \code{"predict"} is recommended
but \code{"fitted"} is the current default for
reasons of backwards compatibility.}
\item{allow_new_levels}{A flag indicating if new
levels of group-level effects are allowed
(defaults to \code{FALSE}).
Only relevant if \code{newdata} is provided.}
\item{sample_new_levels}{Indicates how to sample new levels
for grouping factors specified in \code{re_formula}.
This argument is only relevant if \code{newdata} is provided and
\code{allow_new_levels} is set to \code{TRUE}.
If \code{"uncertainty"} (default), include group-level uncertainty
in the predictions based on the variation of the existing levels.
If \code{"gaussian"}, sample new levels from the (multivariate)
normal distribution implied by the group-level standard deviations
and correlations. This options may be useful for conducting
Bayesian power analysis.
If \code{"old_levels"}, directly sample new levels from the
existing levels.}
\item{new_objects}{A named \code{list} of objects containing
new data, which cannot be passed via argument \code{newdata}.
Currently, only required for objects passed to
\code{\link[brms:cor_sar]{cor_sar}} and
\code{\link[brms:cor_fixed]{cor_fixed}}.}
\item{incl_autocor}{A flag indicating if ARMA autocorrelation
parameters should be included in the predictions. Defaults to
\code{TRUE}. Setting it to \code{FALSE} will not affect other
correlation structures such as \code{\link[brms:cor_bsts]{cor_bsts}},
or \code{\link[brms:cor_fixed]{cor_fixed}}.}
\item{resp}{Optional names of response variables.
If specified, fitted values of these response variables are returned.}
\item{subset}{A numeric vector specifying
the posterior samples to be used.
If \code{NULL} (the default), all samples are used.}
\item{nsamples}{Positive integer indicating how many
posterior samples should be used.
If \code{NULL} (the default) all samples are used.
Ignored if \code{subset} is not \code{NULL}.}
\item{sort}{Logical. Only relevant for time series models.
Indicating whether to return predicted values in the original
order (\code{FALSE}; default) or in the order of the
time series (\code{TRUE}).}
\item{nug}{Small positive number for Gaussian process terms only.
For numerical reasons, the covariance matrix of a Gaussian
process might not be positive definite. Adding a very small
number to the matrix's diagonal often solves this problem.
If \code{NULL} (the default), \code{nug} is chosen internally.}
\item{summary}{Should summary statistics
(i.e. means, sds, and 95\% intervals) be returned
instead of the raw values? Default is \code{TRUE}.}
\item{robust}{If \code{FALSE} (the default) the mean is used as
the measure of central tendency and the standard deviation as
the measure of variability. If \code{TRUE}, the median and the
median absolute deivation (MAD) are applied instead.
Only used if \code{summary} is \code{TRUE}.}
\item{probs}{The percentiles to be computed by the \code{quantile}
function. Only used if \code{summary} is \code{TRUE}.}
\item{...}{Currently ignored.}
\item{re.form}{Alias of \code{re_formula}.}
}
\value{
Model residuals. If \code{summary = TRUE}
this is a N x C matrix and if \code{summary = FALSE}
a S x N matrix, where S is the number of samples,
N is the number of observations, and C is equal to
\code{length(probs) + 2}.
}
\description{
Extract Model Residuals from brmsfit Objects
}
\details{
Residuals of type \code{ordinary}
are of the form \eqn{R = Y - Yp}, where \eqn{Y} is the observed
and \eqn{Yp} is the predicted response.
Residuals of type \code{pearson} are
of the form \eqn{R = (Y - Yp) / SD(Y)},
where \eqn{SD(Y)} is an estimation of the standard deviation
of \eqn{Y}.
Currently, \code{residuals.brmsfit} does not support
\code{categorical} or ordinal models.
Method \code{predictive_error.brmsfit} is an alias of
\code{residuals.brmsfit} with \code{method = "predict"} and
\code{summary = FALSE}.
}
\examples{
\dontrun{
## fit a model
fit <- brm(rating ~ treat + period + carry + (1|subject),
data = inhaler, cores = 2)
## extract residuals
res <- residuals(fit, summary = TRUE)
head(res)
}
}
|
library(MASS)
# +-----------------------------------------------------------------+ #
# | convexpr2nlform create nl.form from an expression | #
# | arguments: | #
# | form: two sided or one sided or function. | #
# | namesdata: name of data include independent and possibly | #
# | dependent in two sided fomula. | #
# | start: is list of parameters. | #
# | result is nl.form object with gradient and hessian also. | #
# +-----------------------------------------------------------------+ #
convexpr2nlform<-function(form,namesdata=NULL,start,inv=NULL,name="User Defined",...){
n <- length(form)
if(n==2){
a0 <- call("~", form[[2]])
a1 <- formula(a0)
a2 <- names(start)
b <- deriv3(a1, a2)
depname <- NULL
formula <- call("~", b)
frmnames <- all.vars(form[[2]])
pnames <- names(start)
matchnames<-charmatch(pnames,frmnames)
indepnames <- frmnames[-matchnames]
}
if(n==3){
a0 <- call("~", form[[3]])
a1 <- formula(a0)
a2 <- names(start)
b <- deriv3(a1, a2)
depname <- all.vars(form[[2]]) # name of dependent variable
d2 <- call(depname)
formula <- call("~",d2[[1]], b)
frmnames <- all.vars(form[[3]])
pnames <- names(start)
matchnames<-charmatch(pnames,frmnames)
indepnames <- frmnames[-matchnames]
}
new("nl.form",formula=formula,formtype="formula",p=length(start),
name=name,par=start,dependent=depname,
independent=indepnames,origin=form,inv=inv,...)
## corect self start later ##
}
# +-----------------------------------------------------------------+ #
# | Hossein Riazoshams | #
# | 2014/04/19 | #
# | Department of statistics, stockholm university | #
# +-----------------------------------------------------------------+ #
| /R/convexpr2nlform.R | no_license | Allisterh/nlr | R | false | false | 2,107 | r | library(MASS)
# +-----------------------------------------------------------------+ #
# | convexpr2nlform create nl.form from an expression | #
# | arguments: | #
# | form: two sided or one sided or function. | #
# | namesdata: name of data include independent and possibly | #
# | dependent in two sided fomula. | #
# | start: is list of parameters. | #
# | result is nl.form object with gradient and hessian also. | #
# +-----------------------------------------------------------------+ #
convexpr2nlform<-function(form,namesdata=NULL,start,inv=NULL,name="User Defined",...){
n <- length(form)
if(n==2){
a0 <- call("~", form[[2]])
a1 <- formula(a0)
a2 <- names(start)
b <- deriv3(a1, a2)
depname <- NULL
formula <- call("~", b)
frmnames <- all.vars(form[[2]])
pnames <- names(start)
matchnames<-charmatch(pnames,frmnames)
indepnames <- frmnames[-matchnames]
}
if(n==3){
a0 <- call("~", form[[3]])
a1 <- formula(a0)
a2 <- names(start)
b <- deriv3(a1, a2)
depname <- all.vars(form[[2]]) # name of dependent variable
d2 <- call(depname)
formula <- call("~",d2[[1]], b)
frmnames <- all.vars(form[[3]])
pnames <- names(start)
matchnames<-charmatch(pnames,frmnames)
indepnames <- frmnames[-matchnames]
}
new("nl.form",formula=formula,formtype="formula",p=length(start),
name=name,par=start,dependent=depname,
independent=indepnames,origin=form,inv=inv,...)
## corect self start later ##
}
# +-----------------------------------------------------------------+ #
# | Hossein Riazoshams | #
# | 2014/04/19 | #
# | Department of statistics, stockholm university | #
# +-----------------------------------------------------------------+ #
|
library("plyr")
library("foreach")
library("gbm")
library("snow")
library("doSNOW")
library("verification")
library("reshape2")
library("caret")
library("ROCR")
setwd("../LoanDefault")
mae = function(x,y) { mean(abs(x-y)) }
load("final_data_full.RData")
load("final_golden_features.RData")
## load probability of default for the train and test set ##
classes.train = read.csv("train_classes_full.csv", stringsAsFactors = F, header = F, sep = ";")
classes.test = read.csv("test_classes_full.csv", stringsAsFactors = F, header = F, sep = ";")
colnames(classes.train) = c("id", "pd")
colnames(classes.test) = c("id", "pd")
## create full feature set for regression task ##
## it consists of all golden features and all features of the full data table ##
feature.set = cbind(data[,c("id", "loss","f776", "f777", "f778", "f2", "f4", "f5")], golden.features)
feature.set = cbind(feature.set, data[,!((colnames(data) %in% c("id","loss","f776", "f777", "f778", "f2", "f4", "f5")))])
#######################################################
## find optimal cutoff point for probability of default
#######################################################
t = merge(classes.train, feature.set[,c("id", "loss")], by = "id", all.x = T)
pred = prediction(t$pd, ifelse(t[,"loss"]>0, 1, 0))
f = performance(pred, 'f')
f1_score = f@y.values[[1]]
cutoff = f@x.values[[1]]
## compute f1 score - should be around 0.958 ##
max(f1_score,na.rm=T)
## get best cutoff point ##
best_cutoff = cutoff[which.max(f1_score)]
## get ids based on the cutoff value ##
## the loss will only be predicted for samples with a probability of default > best_cutoff ##
ids.train.default = classes.train[classes.train$pd > best_cutoff, "id"]
ids.test.default = classes.test[classes.test$pd > best_cutoff, "id"]
ids.test.nodefault = classes.test[classes.test$pd <= best_cutoff, "id"]
## keep only the defaulter ##
train = feature.set[is.na(feature.set$loss) == F & feature.set$id %in% ids.train.default,]
test = feature.set[is.na(feature.set$loss) == T & feature.set$id %in% ids.test.default,]
###############
## predict loss
###############
model.predict = function(fit, Input, run){
settings = read.table("../LoanDefault/rgf1.2/test/sample/predict.inp", stringsAsFactors = F)
settings[1,1] = paste("test_x_fn=sample/test.data.x.", run, sep = "")
settings[2,1] = paste("model_fn=output/model.run.", run, "-01", sep = "")
settings[3,1] = paste("prediction_fn=output/sample.pred.", run, sep = "")
write.table(settings, paste(getwd(), "/rgf1.2/test/sample/predict.", run, ".inp", sep = ""), col.names = F, row.names = F, quote = F)
write.table(Input, paste(getwd(), "/rgf1.2/test/sample/test.data.x.", run, sep=""), row.names = F, col.names = F, na = "-10")
setwd("../LoanDefault/rgf1.2/test")
cmd.rgf = paste("perl call_exe.pl ../bin/rgf predict sample/predict.", run, sep = "")
system(cmd.rgf)
setwd("../LoanDefault")
prediction = read.table(paste(getwd(),"/rgf1.2/test/output/sample.pred.", run, sep=""))$V1
return(prediction)
}
######################
## results for test ##
######################
## model with reg_L2=0.25 ##
model.fit = function(Input, Target, run){
settings = read.table("../LoanDefault/rgf1.2/test/sample/train_regression_025.inp", stringsAsFactors = F)
settings[1,1] = paste("train_x_fn=sample/train.data.x.", run, sep = "")
settings[2,1] = paste("train_y_fn=sample/train.data.y.", run, sep = "")
settings[3,1] = paste("model_fn_prefix=output/model.run.", run, sep = "")
write.table(settings, paste(getwd(), "/rgf1.2/test/sample/train.", run, ".inp", sep = ""), col.names = F, row.names = F, quote = F)
write.table(Input, paste(getwd(), "/rgf1.2/test/sample/train.data.x.", run, sep=""), row.names = F, col.names = F, na = "-10")
write.table(Target, paste(getwd(), "/rgf1.2/test/sample/train.data.y.", run, sep=""), row.names = F, col.names = F, na = "-10")
setwd("../LoanDefault/rgf1.2/test")
cmd.rgf = paste("perl call_exe.pl ../bin/rgf train sample/train.", run, sep = "")
system(cmd.rgf)
setwd("../LoanDefault")
return(1)
}
## fit model ##
temp.fit = model.fit(train[,3:length(train)], log1p(train[,"loss"]), 1)
## predict loss for test set ##
forecast_025 = expm1(model.predict(temp.fit, test[,3:length(test)], 1))
## model with reg_L2=0.5 ##
model.fit = function(Input, Target, run){
settings = read.table("../LoanDefault/rgf1.2/test/sample/train_regression_05.inp", stringsAsFactors = F)
settings[1,1] = paste("train_x_fn=sample/train.data.x.", run, sep = "")
settings[2,1] = paste("train_y_fn=sample/train.data.y.", run, sep = "")
settings[3,1] = paste("model_fn_prefix=output/model.run.", run, sep = "")
write.table(settings, paste(getwd(), "/rgf1.2/test/sample/train.", run, ".inp", sep = ""), col.names = F, row.names = F, quote = F)
write.table(Input, paste(getwd(), "/rgf1.2/test/sample/train.data.x.", run, sep=""), row.names = F, col.names = F, na = "-10")
write.table(Target, paste(getwd(), "/rgf1.2/test/sample/train.data.y.", run, sep=""), row.names = F, col.names = F, na = "-10")
setwd("../LoanDefault/rgf1.2/test")
cmd.rgf = paste("perl call_exe.pl ../bin/rgf train sample/train.", run, sep = "")
system(cmd.rgf)
setwd("../LoanDefault")
return(1)
}
## fit model ##
temp.fit = model.fit(train[,3:length(train)], log1p(train[,"loss"]), 1)
## predict loss for test set ##
forecast_05 = expm1(model.predict(temp.fit, test[,3:length(test)], 1))
## model with reg_L2=0.75 ##
model.fit = function(Input, Target, run){
settings = read.table("../LoanDefault/rgf1.2/test/sample/train_regression_075.inp", stringsAsFactors = F)
settings[1,1] = paste("train_x_fn=sample/train.data.x.", run, sep = "")
settings[2,1] = paste("train_y_fn=sample/train.data.y.", run, sep = "")
settings[3,1] = paste("model_fn_prefix=output/model.run.", run, sep = "")
write.table(settings, paste(getwd(), "/rgf1.2/test/sample/train.", run, ".inp", sep = ""), col.names = F, row.names = F, quote = F)
write.table(Input, paste(getwd(), "/rgf1.2/test/sample/train.data.x.", run, sep=""), row.names = F, col.names = F, na = "-10")
write.table(Target, paste(getwd(), "/rgf1.2/test/sample/train.data.y.", run, sep=""), row.names = F, col.names = F, na = "-10")
setwd("../LoanDefault/rgf1.2/test")
cmd.rgf = paste("perl call_exe.pl ../bin/rgf train sample/train.", run, sep = "")
system(cmd.rgf)
setwd("../LoanDefault")
return(1)
}
## fit model ##
temp.fit = model.fit(train[,3:length(train)], log1p(train[,"loss"]), 1)
## predict loss for test set ##
forecast_075 = expm1(model.predict(temp.fit, test[,3:length(test)], 1))
######################
## combine all results
######################
all.forecasts = rowMeans(cbind(forecast_025, forecast_05, forecast_075))
all.forecasts[all.forecasts<0] = 0
all.forecasts[all.forecasts>100] = 100
result = rbind(data.frame(id = test[,"id"], loss = round(all.forecasts)),
data.frame(id = ids.test.nodefault, loss = 0))
write.table(result, "final_submission.csv", sep = ",", col.names = T, row.names = F, quote = F)
| /GA_DS_materials/Final_project/Loan Prediction/scripts/final_regression.R | permissive | hhsu15/stockPrediction | R | false | false | 7,159 | r | library("plyr")
library("foreach")
library("gbm")
library("snow")
library("doSNOW")
library("verification")
library("reshape2")
library("caret")
library("ROCR")
setwd("../LoanDefault")
mae = function(x,y) { mean(abs(x-y)) }
load("final_data_full.RData")
load("final_golden_features.RData")
## load probability of default for the train and test set ##
classes.train = read.csv("train_classes_full.csv", stringsAsFactors = F, header = F, sep = ";")
classes.test = read.csv("test_classes_full.csv", stringsAsFactors = F, header = F, sep = ";")
colnames(classes.train) = c("id", "pd")
colnames(classes.test) = c("id", "pd")
## create full feature set for regression task ##
## it consists of all golden features and all features of the full data table ##
feature.set = cbind(data[,c("id", "loss","f776", "f777", "f778", "f2", "f4", "f5")], golden.features)
feature.set = cbind(feature.set, data[,!((colnames(data) %in% c("id","loss","f776", "f777", "f778", "f2", "f4", "f5")))])
#######################################################
## find optimal cutoff point for probability of default
#######################################################
t = merge(classes.train, feature.set[,c("id", "loss")], by = "id", all.x = T)
pred = prediction(t$pd, ifelse(t[,"loss"]>0, 1, 0))
f = performance(pred, 'f')
f1_score = f@y.values[[1]]
cutoff = f@x.values[[1]]
## compute f1 score - should be around 0.958 ##
max(f1_score,na.rm=T)
## get best cutoff point ##
best_cutoff = cutoff[which.max(f1_score)]
## get ids based on the cutoff value ##
## the loss will only be predicted for samples with a probability of default > best_cutoff ##
ids.train.default = classes.train[classes.train$pd > best_cutoff, "id"]
ids.test.default = classes.test[classes.test$pd > best_cutoff, "id"]
ids.test.nodefault = classes.test[classes.test$pd <= best_cutoff, "id"]
## keep only the defaulter ##
train = feature.set[is.na(feature.set$loss) == F & feature.set$id %in% ids.train.default,]
test = feature.set[is.na(feature.set$loss) == T & feature.set$id %in% ids.test.default,]
###############
## predict loss
###############
model.predict = function(fit, Input, run){
settings = read.table("../LoanDefault/rgf1.2/test/sample/predict.inp", stringsAsFactors = F)
settings[1,1] = paste("test_x_fn=sample/test.data.x.", run, sep = "")
settings[2,1] = paste("model_fn=output/model.run.", run, "-01", sep = "")
settings[3,1] = paste("prediction_fn=output/sample.pred.", run, sep = "")
write.table(settings, paste(getwd(), "/rgf1.2/test/sample/predict.", run, ".inp", sep = ""), col.names = F, row.names = F, quote = F)
write.table(Input, paste(getwd(), "/rgf1.2/test/sample/test.data.x.", run, sep=""), row.names = F, col.names = F, na = "-10")
setwd("../LoanDefault/rgf1.2/test")
cmd.rgf = paste("perl call_exe.pl ../bin/rgf predict sample/predict.", run, sep = "")
system(cmd.rgf)
setwd("../LoanDefault")
prediction = read.table(paste(getwd(),"/rgf1.2/test/output/sample.pred.", run, sep=""))$V1
return(prediction)
}
######################
## results for test ##
######################
## model with reg_L2=0.25 ##
model.fit = function(Input, Target, run){
settings = read.table("../LoanDefault/rgf1.2/test/sample/train_regression_025.inp", stringsAsFactors = F)
settings[1,1] = paste("train_x_fn=sample/train.data.x.", run, sep = "")
settings[2,1] = paste("train_y_fn=sample/train.data.y.", run, sep = "")
settings[3,1] = paste("model_fn_prefix=output/model.run.", run, sep = "")
write.table(settings, paste(getwd(), "/rgf1.2/test/sample/train.", run, ".inp", sep = ""), col.names = F, row.names = F, quote = F)
write.table(Input, paste(getwd(), "/rgf1.2/test/sample/train.data.x.", run, sep=""), row.names = F, col.names = F, na = "-10")
write.table(Target, paste(getwd(), "/rgf1.2/test/sample/train.data.y.", run, sep=""), row.names = F, col.names = F, na = "-10")
setwd("../LoanDefault/rgf1.2/test")
cmd.rgf = paste("perl call_exe.pl ../bin/rgf train sample/train.", run, sep = "")
system(cmd.rgf)
setwd("../LoanDefault")
return(1)
}
## fit model ##
temp.fit = model.fit(train[,3:length(train)], log1p(train[,"loss"]), 1)
## predict loss for test set ##
forecast_025 = expm1(model.predict(temp.fit, test[,3:length(test)], 1))
## model with reg_L2=0.5 ##
model.fit = function(Input, Target, run){
settings = read.table("../LoanDefault/rgf1.2/test/sample/train_regression_05.inp", stringsAsFactors = F)
settings[1,1] = paste("train_x_fn=sample/train.data.x.", run, sep = "")
settings[2,1] = paste("train_y_fn=sample/train.data.y.", run, sep = "")
settings[3,1] = paste("model_fn_prefix=output/model.run.", run, sep = "")
write.table(settings, paste(getwd(), "/rgf1.2/test/sample/train.", run, ".inp", sep = ""), col.names = F, row.names = F, quote = F)
write.table(Input, paste(getwd(), "/rgf1.2/test/sample/train.data.x.", run, sep=""), row.names = F, col.names = F, na = "-10")
write.table(Target, paste(getwd(), "/rgf1.2/test/sample/train.data.y.", run, sep=""), row.names = F, col.names = F, na = "-10")
setwd("../LoanDefault/rgf1.2/test")
cmd.rgf = paste("perl call_exe.pl ../bin/rgf train sample/train.", run, sep = "")
system(cmd.rgf)
setwd("../LoanDefault")
return(1)
}
## fit model ##
temp.fit = model.fit(train[,3:length(train)], log1p(train[,"loss"]), 1)
## predict loss for test set ##
forecast_05 = expm1(model.predict(temp.fit, test[,3:length(test)], 1))
## model with reg_L2=0.75 ##
model.fit = function(Input, Target, run){
settings = read.table("../LoanDefault/rgf1.2/test/sample/train_regression_075.inp", stringsAsFactors = F)
settings[1,1] = paste("train_x_fn=sample/train.data.x.", run, sep = "")
settings[2,1] = paste("train_y_fn=sample/train.data.y.", run, sep = "")
settings[3,1] = paste("model_fn_prefix=output/model.run.", run, sep = "")
write.table(settings, paste(getwd(), "/rgf1.2/test/sample/train.", run, ".inp", sep = ""), col.names = F, row.names = F, quote = F)
write.table(Input, paste(getwd(), "/rgf1.2/test/sample/train.data.x.", run, sep=""), row.names = F, col.names = F, na = "-10")
write.table(Target, paste(getwd(), "/rgf1.2/test/sample/train.data.y.", run, sep=""), row.names = F, col.names = F, na = "-10")
setwd("../LoanDefault/rgf1.2/test")
cmd.rgf = paste("perl call_exe.pl ../bin/rgf train sample/train.", run, sep = "")
system(cmd.rgf)
setwd("../LoanDefault")
return(1)
}
## fit model ##
temp.fit = model.fit(train[,3:length(train)], log1p(train[,"loss"]), 1)
## predict loss for test set ##
forecast_075 = expm1(model.predict(temp.fit, test[,3:length(test)], 1))
######################
## combine all results
######################
all.forecasts = rowMeans(cbind(forecast_025, forecast_05, forecast_075))
all.forecasts[all.forecasts<0] = 0
all.forecasts[all.forecasts>100] = 100
result = rbind(data.frame(id = test[,"id"], loss = round(all.forecasts)),
data.frame(id = ids.test.nodefault, loss = 0))
write.table(result, "final_submission.csv", sep = ",", col.names = T, row.names = F, quote = F)
|
#set working directory
setwd("D:/Data Science Course Materials/Course03")
#download zip data file
fileURL <- "https://d396qusza40orc.cloudfront.net/getdata%2Fprojectfiles%2FUCI%20HAR%20Dataset.zip"
fileDest <- "wcdata.zip"
download.file(fileURL, fileDest)
###______________________________________________________________________
###STEP 1: Merges the training and the test sets to create one data set
#read train related data
trainData <- read.table("./wcdata/UCI HAR Dataset/train/X_train.txt")
trainLabel <- read.table("./wcdata/UCI HAR Dataset/train/y_train.txt")
trainSubject <- read.table("./wcdata/UCI HAR Dataset/train/subject_train.txt")
#read test related data
testData <- read.table("./wcdata/UCI HAR Dataset/test/X_test.txt")
testLabel <- read.table("./wcdata/UCI HAR Dataset/test/y_test.txt")
testSubject <- read.table("./wcdata/UCI HAR Dataset/test/subject_test.txt")
#merge train and test data (appending)
mergeData <- rbind(trainData, testData)
mergeLabel <- rbind(trainLabel, testLabel)
mergeSubject <- rbind(trainSubject, testSubject)
###______________________________________________________________________
###STEP 2: Extracts only the measurements on the mean and standard deviation for each measurement.
features <- read.table("./wcdata/UCI HAR Dataset/features.txt")
mean_std_only <- grep("mean\\(\\)|std\\(\\)", features[, 2])
#length(mean_std_only) # 66 columns are with mean and std column names
mergeData <- mergeData[, mean_std_only] #get wanted columns with mean and std only
names(mergeData) <- features[mean_std_only, 2] #replace column name
###______________________________________________________________________
###STEP 3: Uses descriptive activity names to name the activities in the data set
activity <- read.table("./wcdata/UCI HAR Dataset/activity_labels.txt")
activityLabel <- activity[mergeLabel[, 1], 2]
mergeLabel[, 1] <- activityLabel
names(mergeLabel) <- "activity" #replace column name
###______________________________________________________________________
###STEP 4: Appropriately labels the data set with descriptive variable names.
names(mergeSubject) <- "subject" #replace column name
allData <- cbind(mergeSubject, mergeLabel, mergeData)
#dim(allData) # 10299*68
write.table(allData, "merged_data.txt") # write out the 1st tidy dataset
###______________________________________________________________________
###STEP 5: From the data set in 4, creates a second, independent tidy data set with the average of each variable for each activity and each subject.
subjectLen <- length(table(mergeSubject)) # 30
activityLen <- dim(activity)[1] # 6
columnLen <- dim(allData)[2]
result <- matrix(NA, nrow=subjectLen*activityLen, ncol=columnLen) #create the matrix to hold aggregate data
result <- as.data.frame(result)
colnames(result) <- colnames(allData) #change column name
row <- 1
for(i in 1:subjectLen) {
for(j in 1:activityLen) {
result[row, 1] <- sort(unique(mergeSubject)[, 1])[i]
result[row, 2] <- activity[j, 2]
bool1 <- i == allData$subject
bool2 <- activity[j, 2] == allData$activity
result[row, 3:columnLen] <- colMeans(allData[bool1&bool2, 3:columnLen])
row <- row + 1
}
}
write.table(result, "merged_data_mean.txt") # write out the 2nd tidy dataset
| /run_analysis.R | no_license | razayu/Course03 | R | false | false | 3,360 | r | #set working directory
setwd("D:/Data Science Course Materials/Course03")
#download zip data file
fileURL <- "https://d396qusza40orc.cloudfront.net/getdata%2Fprojectfiles%2FUCI%20HAR%20Dataset.zip"
fileDest <- "wcdata.zip"
download.file(fileURL, fileDest)
###______________________________________________________________________
###STEP 1: Merges the training and the test sets to create one data set
#read train related data
trainData <- read.table("./wcdata/UCI HAR Dataset/train/X_train.txt")
trainLabel <- read.table("./wcdata/UCI HAR Dataset/train/y_train.txt")
trainSubject <- read.table("./wcdata/UCI HAR Dataset/train/subject_train.txt")
#read test related data
testData <- read.table("./wcdata/UCI HAR Dataset/test/X_test.txt")
testLabel <- read.table("./wcdata/UCI HAR Dataset/test/y_test.txt")
testSubject <- read.table("./wcdata/UCI HAR Dataset/test/subject_test.txt")
#merge train and test data (appending)
mergeData <- rbind(trainData, testData)
mergeLabel <- rbind(trainLabel, testLabel)
mergeSubject <- rbind(trainSubject, testSubject)
###______________________________________________________________________
###STEP 2: Extracts only the measurements on the mean and standard deviation for each measurement.
features <- read.table("./wcdata/UCI HAR Dataset/features.txt")
mean_std_only <- grep("mean\\(\\)|std\\(\\)", features[, 2])
#length(mean_std_only) # 66 columns are with mean and std column names
mergeData <- mergeData[, mean_std_only] #get wanted columns with mean and std only
names(mergeData) <- features[mean_std_only, 2] #replace column name
###______________________________________________________________________
###STEP 3: Uses descriptive activity names to name the activities in the data set
activity <- read.table("./wcdata/UCI HAR Dataset/activity_labels.txt")
activityLabel <- activity[mergeLabel[, 1], 2]
mergeLabel[, 1] <- activityLabel
names(mergeLabel) <- "activity" #replace column name
###______________________________________________________________________
###STEP 4: Appropriately labels the data set with descriptive variable names.
names(mergeSubject) <- "subject" #replace column name
allData <- cbind(mergeSubject, mergeLabel, mergeData)
#dim(allData) # 10299*68
write.table(allData, "merged_data.txt") # write out the 1st tidy dataset
###______________________________________________________________________
###STEP 5: From the data set in 4, creates a second, independent tidy data set with the average of each variable for each activity and each subject.
subjectLen <- length(table(mergeSubject)) # 30
activityLen <- dim(activity)[1] # 6
columnLen <- dim(allData)[2]
result <- matrix(NA, nrow=subjectLen*activityLen, ncol=columnLen) #create the matrix to hold aggregate data
result <- as.data.frame(result)
colnames(result) <- colnames(allData) #change column name
row <- 1
for(i in 1:subjectLen) {
for(j in 1:activityLen) {
result[row, 1] <- sort(unique(mergeSubject)[, 1])[i]
result[row, 2] <- activity[j, 2]
bool1 <- i == allData$subject
bool2 <- activity[j, 2] == allData$activity
result[row, 3:columnLen] <- colMeans(allData[bool1&bool2, 3:columnLen])
row <- row + 1
}
}
write.table(result, "merged_data_mean.txt") # write out the 2nd tidy dataset
|
# Code to be run with
# R -d "valgrind --tool=memcheck --leak-check=full --error-exitcode=1" --vanilla < tests/thisfile.R
devtools::run_examples()
| /memcheck/examples.R | no_license | amulmgr/TreeTools | R | false | false | 149 | r | # Code to be run with
# R -d "valgrind --tool=memcheck --leak-check=full --error-exitcode=1" --vanilla < tests/thisfile.R
devtools::run_examples()
|
#' Determine case windows (circles)
#'
#' \code{bn.zones} determines the case windows (circles) for
#' the Besag-Newell method.
#'
#' Using the distances provided in \code{d}, for each
#' observation, the nearest neighbors are included in
#' increasingly larger windows until at least \code{cstar}
#' cases are included in the window. Each row of \code{d}
#' is matched with the same position in \code{cases}.
#' @inheritParams nnpop
#' @param cases A vector of length \eqn{n} containing the
#' observed number of cases for the \eqn{n} region
#' centroids.
#' @param cstar A non-negative integer indicating the
#' minimum number of cases to include in each window.
#' @return Returns the indices of the regions in each case
#' window as a list. For each element of the list, the
#' indices are ordered from nearest to farthest from each
#' centroid (and include the starting region).
#' @references Besag, J. and Newell, J. (1991). The
#' detection of clusters in rare diseases, Journal of the
#' Royal Statistical Society, Series A, 154, 327-333.
#' @export
#' @author Joshua French
#' @examples
#' data(nydf)
#' coords = as.matrix(nydf[,c("longitude", "latitude")])
#' d = sp::spDists(coords, longlat = FALSE)
#' cwins = bn.zones(d, cases = nydf$cases, cstar = 6)
bn.zones = function(d, cases, cstar) {
# order distances for each region
# results has each column showing order of indices from
# smallest to largest distance
od = apply(d, 2, order)
# for each row of ordered distance matrix sum the
# cumulative number of cases for the expanding collection
# of regions return the smallest collection of regions for
# which the cumulative population is less than the desired
# proportion of the total popuation
wins = apply(od, 2, FUN = function(x) cumsum(cases[x]))
size_cwin = apply(wins >= cstar, 2, which.max)
return(sapply(seq_along(size_cwin),
function(i) od[seq_len(size_cwin[i]), i]
))
}
#' @rdname bn.zones
#' @export
casewin = bn.zones
| /smerc/R/bn.zones.R | no_license | akhikolla/InformationHouse | R | false | false | 2,061 | r | #' Determine case windows (circles)
#'
#' \code{bn.zones} determines the case windows (circles) for
#' the Besag-Newell method.
#'
#' Using the distances provided in \code{d}, for each
#' observation, the nearest neighbors are included in
#' increasingly larger windows until at least \code{cstar}
#' cases are included in the window. Each row of \code{d}
#' is matched with the same position in \code{cases}.
#' @inheritParams nnpop
#' @param cases A vector of length \eqn{n} containing the
#' observed number of cases for the \eqn{n} region
#' centroids.
#' @param cstar A non-negative integer indicating the
#' minimum number of cases to include in each window.
#' @return Returns the indices of the regions in each case
#' window as a list. For each element of the list, the
#' indices are ordered from nearest to farthest from each
#' centroid (and include the starting region).
#' @references Besag, J. and Newell, J. (1991). The
#' detection of clusters in rare diseases, Journal of the
#' Royal Statistical Society, Series A, 154, 327-333.
#' @export
#' @author Joshua French
#' @examples
#' data(nydf)
#' coords = as.matrix(nydf[,c("longitude", "latitude")])
#' d = sp::spDists(coords, longlat = FALSE)
#' cwins = bn.zones(d, cases = nydf$cases, cstar = 6)
bn.zones = function(d, cases, cstar) {
# order distances for each region
# results has each column showing order of indices from
# smallest to largest distance
od = apply(d, 2, order)
# for each row of ordered distance matrix sum the
# cumulative number of cases for the expanding collection
# of regions return the smallest collection of regions for
# which the cumulative population is less than the desired
# proportion of the total popuation
wins = apply(od, 2, FUN = function(x) cumsum(cases[x]))
size_cwin = apply(wins >= cstar, 2, which.max)
return(sapply(seq_along(size_cwin),
function(i) od[seq_len(size_cwin[i]), i]
))
}
#' @rdname bn.zones
#' @export
casewin = bn.zones
|
#' Responses to the life satisfaction survey
#'
#' A sample dataset containing responses of 436 individuals to a 5-item Life Satisfaction Survey to test the fuctions of the package
#'
#'
#' @format numeric dataframe of responses
#'
#' @source \url{http://spss.allenandunwin.com.s3-website-ap-southeast-2.amazonaws.com/Files/survey.zip}
#'
"life_satisfaction"
| /R/data.R | no_license | unimi-dse/91ac33e1 | R | false | false | 369 | r | #' Responses to the life satisfaction survey
#'
#' A sample dataset containing responses of 436 individuals to a 5-item Life Satisfaction Survey to test the fuctions of the package
#'
#'
#' @format numeric dataframe of responses
#'
#' @source \url{http://spss.allenandunwin.com.s3-website-ap-southeast-2.amazonaws.com/Files/survey.zip}
#'
"life_satisfaction"
|
library(dplyr)
library(tidyr)
library(ftsa)
library(readxl)
metrics = read.csv('/Users/aaqibjabbarhj/Desktop/4th Sem/BA field project/All files/R studio files/Cleaned data/CSV files/Filtered-Store Business and Scheduling Metrics.csv')
executions = read.csv('/Users/aaqibjabbarhj/Desktop/4th Sem/BA field project/All files/R studio files/Cleaned data/CSV files/Filtered Executions.csv')
df = read.csv('/Users/aaqibjabbarhj/Desktop/4th Sem/BA field project/All files/R studio files/Cleaned data/CSV files/df.csv')
logons = read.csv('/Users/aaqibjabbarhj/Desktop/4th Sem/BA field project/All files/R studio files/Cleaned data/CSV files/Filtered Logons.csv')
str
executions = executions %>%
group_by(`Str.Id`,`Week.Start.Date`) %>%
summarise("Executions Planned" = sum(`Executions.Planned`),
"Executions On-Time" = sum(`Executions.Completed..On.Time`),
"Executions Forced Closed" = sum(`Executions.Forced.Closed`))
df = merge(df, logons, by=c("Str.Id", "Week.Start.Date"))
df = merge(df, executions, by=c("Str.Id", "Week.Start.Date"))
df$SalesPerLH = df$`Act.Sales` / df$`Act.Hrs`
df$EditsPerLH = df$`Sched.Edits` / df$`Act.Hrs`
df$LCbySales = df$`Act.Labor.Cost` / df$`Act.Sales`
df$ShiftRatio = df$`Sched.Shifts.MGR` / df$`Sched.Shifts.SYS`
df$ShiftDifference = df$`Sched.Shifts.MGR` - df$`Sched.Shifts.SYS`
df$EfficiencyRatio = df$`Sched.Efficiency.MGR` / df$`Sched.Efficiency.SYS`
df$EfficiencyDifference = df$`Sched.Efficiency.MGR` - df$`Sched.Efficiency.SYS`
df$Wage = df$`Act.Labor.Cost` / df$`Act.Hrs`
df$LogonsPerLH = df$Logons / df$`Act.Hrs`
df$OnTimePercentage = df$`Executions On-Time`/df$`Executions Planned`
df$ForcedClosedPercentage = df$`Executions On-Time`/df$`Executions Planned`
summary(df)
df = na.omit(df)
df <- df[is.finite(rowSums(df[ ,-1])),]
mdl = lm(SalesPerLH ~ EditsPerLH, data =df)
summary(mdl)
mdl = lm(SalesPerLH ~ EditsPerLH +
ShiftRatio +
EfficiencyRatio +
Wage +
ShiftDifference +
EfficiencyDifference +
LogonsPerLH +
OnTimePercentage +
ForcedClosedPercentage +
`Dist Id`, data=df)
summary(mdl)
x = summary(mdl)
B=data.frame('Full' = x$coefficients[,1])
for (distId in unique(df$`Dist Id`)){
dfDist = df[df$`Dist Id` == distId, ]
mdl = lm(SalesPerLH ~ EditsPerLH +
ShiftRatio +
EfficiencyRatio +
Wage +
ShiftDifference +
EfficiencyDifference +
LogonsPerLH +
OnTimePercentage,
data = dfDist)
x = summary(mdl)
B[,c(distId)] = x$coefficients[,1]
}
View(x$coefficients)
| /Regression.R | no_license | Aaqib7007/Retail-Store-using-R | R | false | false | 2,660 | r | library(dplyr)
library(tidyr)
library(ftsa)
library(readxl)
metrics = read.csv('/Users/aaqibjabbarhj/Desktop/4th Sem/BA field project/All files/R studio files/Cleaned data/CSV files/Filtered-Store Business and Scheduling Metrics.csv')
executions = read.csv('/Users/aaqibjabbarhj/Desktop/4th Sem/BA field project/All files/R studio files/Cleaned data/CSV files/Filtered Executions.csv')
df = read.csv('/Users/aaqibjabbarhj/Desktop/4th Sem/BA field project/All files/R studio files/Cleaned data/CSV files/df.csv')
logons = read.csv('/Users/aaqibjabbarhj/Desktop/4th Sem/BA field project/All files/R studio files/Cleaned data/CSV files/Filtered Logons.csv')
str
executions = executions %>%
group_by(`Str.Id`,`Week.Start.Date`) %>%
summarise("Executions Planned" = sum(`Executions.Planned`),
"Executions On-Time" = sum(`Executions.Completed..On.Time`),
"Executions Forced Closed" = sum(`Executions.Forced.Closed`))
df = merge(df, logons, by=c("Str.Id", "Week.Start.Date"))
df = merge(df, executions, by=c("Str.Id", "Week.Start.Date"))
df$SalesPerLH = df$`Act.Sales` / df$`Act.Hrs`
df$EditsPerLH = df$`Sched.Edits` / df$`Act.Hrs`
df$LCbySales = df$`Act.Labor.Cost` / df$`Act.Sales`
df$ShiftRatio = df$`Sched.Shifts.MGR` / df$`Sched.Shifts.SYS`
df$ShiftDifference = df$`Sched.Shifts.MGR` - df$`Sched.Shifts.SYS`
df$EfficiencyRatio = df$`Sched.Efficiency.MGR` / df$`Sched.Efficiency.SYS`
df$EfficiencyDifference = df$`Sched.Efficiency.MGR` - df$`Sched.Efficiency.SYS`
df$Wage = df$`Act.Labor.Cost` / df$`Act.Hrs`
df$LogonsPerLH = df$Logons / df$`Act.Hrs`
df$OnTimePercentage = df$`Executions On-Time`/df$`Executions Planned`
df$ForcedClosedPercentage = df$`Executions On-Time`/df$`Executions Planned`
summary(df)
df = na.omit(df)
df <- df[is.finite(rowSums(df[ ,-1])),]
mdl = lm(SalesPerLH ~ EditsPerLH, data =df)
summary(mdl)
mdl = lm(SalesPerLH ~ EditsPerLH +
ShiftRatio +
EfficiencyRatio +
Wage +
ShiftDifference +
EfficiencyDifference +
LogonsPerLH +
OnTimePercentage +
ForcedClosedPercentage +
`Dist Id`, data=df)
summary(mdl)
x = summary(mdl)
B=data.frame('Full' = x$coefficients[,1])
for (distId in unique(df$`Dist Id`)){
dfDist = df[df$`Dist Id` == distId, ]
mdl = lm(SalesPerLH ~ EditsPerLH +
ShiftRatio +
EfficiencyRatio +
Wage +
ShiftDifference +
EfficiencyDifference +
LogonsPerLH +
OnTimePercentage,
data = dfDist)
x = summary(mdl)
B[,c(distId)] = x$coefficients[,1]
}
View(x$coefficients)
|
funs <- list(altimetry_currents_polar_files,
altimetry_daily_files,
amps_d1files,
amps_d2files,
amps_files,
amps_model_files,
amsr2_3k_daily_files,
amsr2_daily_files,
amsr_daily_files,
amsre_daily_files,
argo_files,
#bom_tmax_daily_files,
cafe_monthly_files,
cersat_daily_files,
#cmip5_files,
cryosat2_files,
etopo1_files,
etopo2_files,
fasticefiles,
fsle_files,
gebco08_files,
gebco14_files,
gebco19_files,
geoid_files,
#george_v_terre_adelie_1000m_files,
#george_v_terre_adelie_100m_files,
#george_v_terre_adelie_250m_files,
#george_v_terre_adelie_500m_files,
ghrsst_daily_files,
ibcso_background_files,
ibcso_bed_files,
ibcso_digital_chart_files,
ibcso_files,
ibcso_sid_files,
iceclim_north_leadsfiles,
iceclim_south_leadsfiles,
kerguelen_files,
lakesuperior_files,
macquarie100m_57S_files,
macquarie100m_58S_files,
ncep2_uwnd_6hr_files,
ncep2_vwnd_6hr_files,
nsidc_daily_files,
nsidc_monthly_files,
nsidc_north_daily_files,
nsidc_north_monthly_files,
nsidc_south_daily_files,
nsidc_south_monthly_files,
oisst_daily_files,
oisst_monthly_files,
polarview_files,
ramp_files,
rema_100m_aspect_files,
rema_100m_dem_files,
rema_100m_dem_geoid_files,
rema_100m_files,
rema_100m_rock_files,
rema_100m_rugosity_files,
rema_100m_slope_files,
rema_1km_files,
rema_200m_aspect_files,
rema_200m_dem_files,
rema_200m_dem_geoid_files,
rema_200m_files,
rema_200m_rock_files,
rema_200m_rugosity_files,
rema_200m_slope_files,
rema_8m_aspect_files,
rema_8m_dem_files,
rema_8m_dem_geoid_files,
rema_8m_files,
rema_8m_rock_files,
rema_8m_rugosity_files,
rema_8m_slope_files,
rema_8m_tiles,
rema_tile_files,
seapodym_weekly_files,
smap_8day_files,
smith_sandwell_files,
smith_sandwell_lon180_files,
smith_sandwell_unpolished_files,
smith_sandwell_unpolished_lon180_files,
sose_monthly_files,
srtm_files,
thelist_files,
woa13_files)
fullname_check <- function(x) {
"fullname" %in% names(x())
}
library(furrr)
plan(multisession)
lfiles <- future_map(funs, ~try(.x()))
purrr::map_lgl(funs, fullname_check)
| /inst/notes/checkfuns.R | no_license | AustralianAntarcticDivision/raadfiles | R | false | false | 1,988 | r | funs <- list(altimetry_currents_polar_files,
altimetry_daily_files,
amps_d1files,
amps_d2files,
amps_files,
amps_model_files,
amsr2_3k_daily_files,
amsr2_daily_files,
amsr_daily_files,
amsre_daily_files,
argo_files,
#bom_tmax_daily_files,
cafe_monthly_files,
cersat_daily_files,
#cmip5_files,
cryosat2_files,
etopo1_files,
etopo2_files,
fasticefiles,
fsle_files,
gebco08_files,
gebco14_files,
gebco19_files,
geoid_files,
#george_v_terre_adelie_1000m_files,
#george_v_terre_adelie_100m_files,
#george_v_terre_adelie_250m_files,
#george_v_terre_adelie_500m_files,
ghrsst_daily_files,
ibcso_background_files,
ibcso_bed_files,
ibcso_digital_chart_files,
ibcso_files,
ibcso_sid_files,
iceclim_north_leadsfiles,
iceclim_south_leadsfiles,
kerguelen_files,
lakesuperior_files,
macquarie100m_57S_files,
macquarie100m_58S_files,
ncep2_uwnd_6hr_files,
ncep2_vwnd_6hr_files,
nsidc_daily_files,
nsidc_monthly_files,
nsidc_north_daily_files,
nsidc_north_monthly_files,
nsidc_south_daily_files,
nsidc_south_monthly_files,
oisst_daily_files,
oisst_monthly_files,
polarview_files,
ramp_files,
rema_100m_aspect_files,
rema_100m_dem_files,
rema_100m_dem_geoid_files,
rema_100m_files,
rema_100m_rock_files,
rema_100m_rugosity_files,
rema_100m_slope_files,
rema_1km_files,
rema_200m_aspect_files,
rema_200m_dem_files,
rema_200m_dem_geoid_files,
rema_200m_files,
rema_200m_rock_files,
rema_200m_rugosity_files,
rema_200m_slope_files,
rema_8m_aspect_files,
rema_8m_dem_files,
rema_8m_dem_geoid_files,
rema_8m_files,
rema_8m_rock_files,
rema_8m_rugosity_files,
rema_8m_slope_files,
rema_8m_tiles,
rema_tile_files,
seapodym_weekly_files,
smap_8day_files,
smith_sandwell_files,
smith_sandwell_lon180_files,
smith_sandwell_unpolished_files,
smith_sandwell_unpolished_lon180_files,
sose_monthly_files,
srtm_files,
thelist_files,
woa13_files)
fullname_check <- function(x) {
"fullname" %in% names(x())
}
library(furrr)
plan(multisession)
lfiles <- future_map(funs, ~try(.x()))
purrr::map_lgl(funs, fullname_check)
|
#' ISOImageryBandDefinition
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO imagery band definition
#' @return Object of \code{\link{R6Class}} for modelling an ISO Imagery Band definition
#' @format \code{\link{R6Class}} object.
#'
#' @examples
#' #possible values
#' values <- ISOImageryBandDefinition$values(labels = TRUE)
#'
#' #some def
#' fiftyp <- ISOImageryBandDefinition$new(value = "fiftyPercent")
#'
#' @references
#' ISO 19115-2:2009 - Geographic information -- Metadata Part 2: Extensions for imagery and gridded data
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
ISOImageryBandDefinition <- R6Class("ISOImageryBandDefinition",
inherit = ISOCodeListValue,
private = list(
xmlElement = "MI_BandDefinition",
xmlNamespacePrefix = "GMI"
),
public = list(
#'@description Initializes object
#'@param xml object of class \link{XMLInternalNode-class}
#'@param value value
#'@param description description
initialize = function(xml = NULL, value, description = NULL){
super$initialize(xml = xml, id = private$xmlElement, value = value, description = description,
addCodeSpaceAttr = FALSE)
}
)
)
ISOImageryBandDefinition$values <- function(labels = FALSE){
return(ISOCodeListValue$values(ISOImageryBandDefinition, labels))
} | /R/ISOImageryBandDefinition.R | no_license | cran/geometa | R | false | false | 1,467 | r | #' ISOImageryBandDefinition
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO imagery band definition
#' @return Object of \code{\link{R6Class}} for modelling an ISO Imagery Band definition
#' @format \code{\link{R6Class}} object.
#'
#' @examples
#' #possible values
#' values <- ISOImageryBandDefinition$values(labels = TRUE)
#'
#' #some def
#' fiftyp <- ISOImageryBandDefinition$new(value = "fiftyPercent")
#'
#' @references
#' ISO 19115-2:2009 - Geographic information -- Metadata Part 2: Extensions for imagery and gridded data
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
ISOImageryBandDefinition <- R6Class("ISOImageryBandDefinition",
inherit = ISOCodeListValue,
private = list(
xmlElement = "MI_BandDefinition",
xmlNamespacePrefix = "GMI"
),
public = list(
#'@description Initializes object
#'@param xml object of class \link{XMLInternalNode-class}
#'@param value value
#'@param description description
initialize = function(xml = NULL, value, description = NULL){
super$initialize(xml = xml, id = private$xmlElement, value = value, description = description,
addCodeSpaceAttr = FALSE)
}
)
)
ISOImageryBandDefinition$values <- function(labels = FALSE){
return(ISOCodeListValue$values(ISOImageryBandDefinition, labels))
} |
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{concentration.observed}
\alias{concentration.observed}
\title{Market concentration observed by region and year}
\format{
An object of class \code{data.frame} with 5 rows and 10 columns.
}
\usage{
concentration.observed
}
\description{
A normalized Herfindahl-Hirschman index of concentration (Hirschman 1964) by
region for DAP/MAP fertilizer trade volumes 2013-2017.
}
\details{
The index of concentration takes the value 0 when a regional market is
provided equally by all six suppliers (international suppliers +
domestic industry), and approaches 1 when the market in question has
a single supplier.
The following definitions apply: DAP - diammonium phosphate, MAP - monoammonium phosphate.
Regional classification includes: Africa, East Asia, Eastern Europe and Central Asia, Latin America, North America, Oceania, South Asia, Western and Central Europe, and Western Asia.
}
\references{
\itemize{
\item Hirschman, A. (1964). The Paternity of an Index. The American Economic Review, 54(5): 761.
}
}
\keyword{datasets}
| /R/dapmap.model/man/concentration.observed.Rd | permissive | shchipts/phosphorus-affordability | R | false | true | 1,136 | rd | % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{concentration.observed}
\alias{concentration.observed}
\title{Market concentration observed by region and year}
\format{
An object of class \code{data.frame} with 5 rows and 10 columns.
}
\usage{
concentration.observed
}
\description{
A normalized Herfindahl-Hirschman index of concentration (Hirschman 1964) by
region for DAP/MAP fertilizer trade volumes 2013-2017.
}
\details{
The index of concentration takes the value 0 when a regional market is
provided equally by all six suppliers (international suppliers +
domestic industry), and approaches 1 when the market in question has
a single supplier.
The following definitions apply: DAP - diammonium phosphate, MAP - monoammonium phosphate.
Regional classification includes: Africa, East Asia, Eastern Europe and Central Asia, Latin America, North America, Oceania, South Asia, Western and Central Europe, and Western Asia.
}
\references{
\itemize{
\item Hirschman, A. (1964). The Paternity of an Index. The American Economic Review, 54(5): 761.
}
}
\keyword{datasets}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.