Skip to contents

Score each cell for how much their transcripts change their goodness-of-fit over space.

Usage

score_cell_segmentation_error(
  chosen_cells,
  transcript_df,
  cellID_coln = "CellId",
  transID_coln = "transcript_id",
  score_coln = "score",
  spatLocs_colns = c("x", "y", "z"),
  model_cutoff = 50
)

Arguments

chosen_cells

the cell_ID of chosen cells

transcript_df

the data.frame of transcript_ID, cell_ID, score, spatial coordinates

cellID_coln

the column name of cell_ID in transcript_df

transID_coln

the column name of transcript_ID in transcript_df

score_coln

the column name of score in transcript_df

spatLocs_colns

column names for 1st, 2nd and optional 3rd dimension of spatial coordinates in transcript_df

model_cutoff

the cutoff of transcript number to do spatial modeling (default = 50)

Value

data.frame with columns for

  1. cell_ID, cell id

  2. transcript_num, number of transcripts in given cell

  3. modAlt_rsq, summary(mod_alternative)$r.squared

  4. lrtest_ChiSq, lrtest chi-squared value

  5. lrtest_Pr, lrtest probability larger than chi-squared value, p-value

Details

For tLLRv2 score of transcripts within each cell, run a quadratic model: mod_alternative = lm(tLLRv2 ~ x + y + x2 + y2 +xy) for 2D, lm(tLLRv2 ~ x + y + z + x2 + y2 +z2 +xy + xz + yz) for 3D and a null model: mod_null = lm(tLLRv2 ~ 1); then run lmtest::lrtest(mod_alternative, mod_null). Return statistics for mod_alternative$fitted.values (standard deviation and minimal value), summary(mod_alternative)$r.squared and as well as lrtest chi-squared value.