lsatPairs: Function to get Hungarian sort pairs via clue::lsat

View source: R/functions.R

lsatPairsR Documentation

Function to get Hungarian sort pairs via clue::lsat

Description

Finds best matches between cell-types that correlate between beta or theta matrices that have been compared via getCorrMtx(). Each row is paired with a column in the output matrix from getCorrMtx(). If there are less rows than columns, then some columns will not be matched and not part of the output.

Usage

lsatPairs(mtx)

Arguments

mtx

output correlation matrix from getCorrMtx(). Must not have more rows than columns

Value

A list that contains

  • pairs: output of clue::solve_LSAP. A vectorized object where for each position the first element is a row and the second is the paired column.

  • rowix: the indices of the rows. Essentially seq_along(pairing)

  • colsix: the indices of each column paired to each row

Examples

data(mOB)
pos <- mOB$pos
cd <- mOB$counts
counts <- cleanCounts(cd, min.lib.size = 100)
corpus <- restrictCorpus(counts, removeAbove=1.0, removeBelow = 0.05)
ldas <- fitLDA(t(as.matrix(corpus)), Ks = 3)
optLDA <- optimalModel(models = ldas, opt = 3)
results <- getBetaTheta(optLDA, perc.filt = 0.05, betaScale = 1000)
deconProp <- results$theta
corMtx <- getCorrMtx(m1 = as.matrix(deconProp), m2 = as.matrix(deconProp), type = "t")
pairs <- lsatPairs(corMtx)
pairs


JEFworks-Lab/STdeconvolve documentation built on Nov. 14, 2024, 7:24 p.m.