fitNBth {GeoDiff}R Documentation

Negative Binomial threshold model

Description

Estimate the signal size factor for features above the background

Estimate the signal size factor for features above the background

Usage

fitNBth(object, ...)

## S4 method for signature 'NanoStringGeoMxSet'
fitNBth(
  object,
  features_high = NULL,
  sizefact_BG = NULL,
  sizefact_start = sizefact_BG,
  size_scale = c("sum", "first"),
  threshold_start = NULL,
  threshold_fix = FALSE,
  tol = 0.001,
  iterations = 5,
  start_para = c(threshold_start, 0.5),
  lower_sizefact = 0.01,
  lower_threshold = 0.01
)

## S4 method for signature 'matrix'
fitNBth(
  object,
  features_high,
  probenum,
  sizefact_BG,
  sizefact_start = sizefact_BG,
  size_scale = c("sum", "first"),
  threshold_start,
  threshold_fix = FALSE,
  tol = 0.001,
  iterations = 5,
  start_para = c(threshold_start, 1),
  lower_sizefact = 0,
  lower_threshold = threshold_start/5
)

Arguments

object

count matrix with features in rows and samples in columns

...

additional argument list that might be used

features_high

subset of features which are well above the background

sizefact_BG

size factors for the background

sizefact_start

initial value for size factors

size_scale

method to scale the sizefact, sum(sizefact)=1 when size_scale="sum", sizefact[1]=1 when size_scale="first"

threshold_start

initial value for threshold

threshold_fix

whether to fix the threshold, default=FALSE

tol

tolerance to determine convergence, default=1e-3

iterations

maximum iterations to be run, default=5

start_para

starting values for parameter estimation, default=c(threshold_start, 1)

lower_sizefact

lower limit for sizefact, default=0

lower_threshold

lower limit for threshold

probenum

a vector of numbers of probes in each gene

Value

a valid GeoMx S4 object

a list of following items, some items are place holders = NA

Examples


library(Biobase)
library(dplyr)
data(demoData)
demoData <- fitPoisBG(demoData, size_scale = "sum")
demoData <- aggreprobe(demoData, use = "cor")
demoData <- BGScoreTest(demoData)
thmean <- 1 * mean(fData(demoData)$featfact, na.rm = TRUE)
demo_pos <- demoData[which(!fData(demoData)$CodeClass == "Negative"), ]
demo_neg <- demoData[which(fData(demoData)$CodeClass == "Negative"), ]
sc1_scores <- fData(demo_pos)[, "scores"]
names(sc1_scores) <- fData(demo_pos)[, "TargetName"]
features_high <- ((sc1_scores > quantile(sc1_scores, probs = 0.4)) &
   (sc1_scores < quantile(sc1_scores, probs = 0.95))) |>
    which() |>
    names()
set.seed(123)
features_high <- sample(features_high, 100)
demoData <- fitNBth(demoData,
                    features_high = features_high,
                    sizefact_BG = demo_neg$sizefact,
                    threshold_start = thmean,
                    iterations = 5,
                    start_para = c(200, 1),
                    lower_sizefact = 0,
                    lower_threshold = 100,
                    tol = 1e-8)


[Package GeoDiff version 0.99.5 Index]