compareModeltoTruth: Compare result of binary classification to truth

Description Usage Arguments Value Examples

View source: R/prepareDataforGlm.R

Description

Given two vectors of factors (two identical levels) of equal length, calculate confusion matrix marginals

Usage

1
compareModeltoTruth(estim, truth)

Arguments

estim

Vector holding a two level factor with the classification result.

truth

Vector holding a two level factor with the truth.

Value

A list with various key charactereistics of the resulting confusion matrix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# get gene locations
mtor.loc <- findWells(experiments="brucella-du-k1", contents="MTOR")
scra.loc <- findWells(plates=sapply(mtor.loc, getBarcode),
                      contents="SCRAMBLED", well.names="G23")
# combine for faster fetching
data     <- getSingleCellData(list(mtor.loc[[1]], scra.loc[[1]]))
mtor.dat <- meltData(cleanData(data[[1]]$H6))
scra.dat <- meltData(cleanData(data[[1]]$G23))
# prepare data for glm
data <- prepareDataforGlm(mtor.dat$mat$Cells, scra.dat$mat$Cells)
data <- makeRankFull(data)
# run glm
model <- glm("Response ~ .", binomial, data$train)
# compare to testing data
predi <- as.factor(round(predict(model, newdata=data$test,
                                 type="response")))
levels(predi) <- c("active", "control")
comparison <- compareModeltoTruth(predi, data$test$Response)

nbenn/singleCellFeatures documentation built on May 23, 2019, 12:24 p.m.