fitNBth-methods: Negative Binomial threshold model

fitNBthR 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,
  split = TRUE,
  features_high = NULL,
  sizefact_BG = NULL,
  sizefact_start = sizefact_BG,
  size_scale = c("sum", "first"),
  threshold_start = NULL,
  threshold_fix = FALSE,
  tol = 1e-07,
  iterations = 8,
  start_para = c(threshold_start, 0.5),
  lower_sizefact = 0,
  lower_threshold = threshold_start/5
)

## 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 = 1e-07,
  iterations = 8,
  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

split

indicator variable on whether it is for multiple slides (Yes, TRUE; No, FALSE)

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

  • para0 = "NA", in experimentData

  • para, estimated parameters, "signal" "r" in rows and features in columns, in featureData

  • sizefact, estimated size factor, in phenoData

  • preci1 = "NA", in experimentData

  • conv0 = "NA", in experimentData

  • conv = "NA", in experimentData

  • Im = "NA", in experimentData

  • features_high, a vector of indicators, in featureData (0: No; 1: Yes; NA: not included in features_high)

  • features_all = "NA", in experimentData

  • threshold, estimated threshold, when threshold_fix, equals to threshold_start, in experimentData

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

  • para0 = NA,

  • para, estimated parameters, "signal" "r" in rows and features in columns

  • sizefact, estimated size factor

  • preci1 = NA

  • conv0 = NA

  • conv = NA

  • Im = NA

  • features_high = features_high

  • features_all = NA

  • threshold, estimated threshold, when threshold_fix, equals to threshold_start

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)


Nanostring-Biostats/GeoDiff documentation built on April 11, 2024, 5:31 a.m.