Annotate columns by marker feature information

rcpp_mmutil_annotate_columns(
  pos_labels,
  r_rows = NULL,
  r_cols = NULL,
  r_neg_labels = NULL,
  r_qc_labels = NULL,
  mtx_file = "",
  row_file = "",
  col_file = "",
  r_U = NULL,
  r_D = NULL,
  r_V = NULL,
  KAPPA_MAX = 100,
  TAKE_LN = FALSE,
  BATCH_SIZE = 10000L,
  EM_ITER = 100L,
  EM_TOL = 1e-04,
  VERBOSE = FALSE,
  DO_STD = FALSE
)

Arguments

pos_labels

markers

mtx_file

data file

row_file

row file

col_file

column file

neg_labels

anti-markers

qc_labels

feature-specific threshold

param_kappa_max

Value

a list of inference results

Examples

options(stringsAsFactors = FALSE)
## combine two different mu matrices
rr <- rgamma(1000, 1, 1) # 1000 cells
mm.1 <- matrix(rgamma(100 * 3, 1, 1), 100, 3)
mm.1[1:10, ] <- rgamma(5, 1, .1)
mm.2 <- matrix(rgamma(100 * 3, 1, 1), 100, 3)
mm.2[11:20, ] <- rgamma(5, 1, .1)
mm <- cbind(mm.1, mm.2)
dat <- mmutilR::rcpp_mmutil_simulate_poisson(mm, rr, "sim_test")
rows <- read.table(dat$row)$V1
cols <- read.table(dat$col)$V1
## marker feature
markers <- list(
  annot.1 = list(
    ct1 = rows[1:10],
    ct2 = rows[11:20]
  )
)
## annotation on the MTX file
out <- mmutilR::rcpp_mmutil_annotate_columns(
       row_file = dat$row, col_file = dat$col,
       mtx_file = dat$mtx, pos_labels = markers)
annot <- out$annotation
.pca <- mmutilR::rcpp_mmutil_pca(dat$mtx, 3, TAKE_LN = TRUE)
#> Error: 'rcpp_mmutil_pca' is not an exported object from 'namespace:mmutilR'
out.df <- data.frame(col = as.integer(annot$col),
                     argmax = annot$argmax)
out.df <- cbind(out.df, PC=.pca$V)
#> Error in data.frame(..., check.names = FALSE): object '.pca' not found
plot(out.df$PC.1, out.df$PC.2, xlab = "PC1", ylab = "PC2")
#> Warning: no non-missing arguments to min; returning Inf
#> Warning: no non-missing arguments to max; returning -Inf
#> Warning: no non-missing arguments to min; returning Inf
#> Warning: no non-missing arguments to max; returning -Inf
#> Error in plot.window(...): need finite 'xlim' values

ct1 <- which(out.df$argmax == "ct1")
points(out.df$PC.1[ct1], out.df$PC.2[ct1], pch = 19, col = 2)
ct2 <- which(out.df$argmax == "ct2")
points(out.df$PC.1[ct2], out.df$PC.2[ct2], pch = 19, col = 3)
## annotation on the PC results
out.2 <- mmutilR::rcpp_mmutil_annotate_columns(
         row_file = dat$row, col_file = dat$col,
         pos_labels = markers,
         r_U = .pca$U, r_D = .pca$D, r_V = .pca$V)
#> Error in mmutilR::rcpp_mmutil_annotate_columns(row_file = dat$row, col_file = dat$col,     pos_labels = markers, r_U = .pca$U, r_D = .pca$D, r_V = .pca$V): object '.pca' not found
annot <- out.2$annotation
#> Error in eval(expr, envir, enclos): object 'out.2' not found
out.df <- data.frame(col = as.integer(annot$col),
                     argmax = annot$argmax)
out.df <- cbind(out.df, PC=.pca$V)
#> Error in data.frame(..., check.names = FALSE): object '.pca' not found
plot(out.df$PC.1, out.df$PC.2, xlab = "PC1", ylab = "PC2")
#> Warning: no non-missing arguments to min; returning Inf
#> Warning: no non-missing arguments to max; returning -Inf
#> Warning: no non-missing arguments to min; returning Inf
#> Warning: no non-missing arguments to max; returning -Inf
#> Error in plot.window(...): need finite 'xlim' values
ct1 <- which(out.df$argmax == "ct1")
points(out.df$PC.1[ct1], out.df$PC.2[ct1], pch = 19, col = 2)
ct2 <- which(out.df$argmax == "ct2")
points(out.df$PC.1[ct2], out.df$PC.2[ct2], pch = 19, col = 3)
unlink(list.files(pattern = "sim_test"))