Skip to contents

find out the spatially connected transcripts among chosen_transcripts based on SVM spatial model which scores each cell for how much their transcripts change their goodness-of-fit over space.

Usage

flag_bad_transcripts(
  chosen_cells,
  score_GeneMatrix,
  transcript_df,
  cellID_coln = "CellId",
  transID_coln = "transcript_id",
  transGene_coln = "target",
  score_coln = "score",
  spatLocs_colns = c("x", "y", "z"),
  model_cutoff = 50,
  score_cutoff = -2,
  svm_args = list(kernel = "radial", scale = TRUE, gamma = 0.1)
)

Arguments

chosen_cells

the cell_ID of chosen cells

score_GeneMatrix

the gene x cell-type matrix of log-like score of gene in each cell type

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

transGene_coln

the column name of target or gene name in transcript_df

score_coln

the column name of score in transcript_df

spatLocs_colns

the column names of 1st, 2nd, optional 3rd spatial dimension of each transcript in transcript_df

model_cutoff

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

score_cutoff

the cutoff of score to separate between high and low score transcripts (default = -2)

svm_args

a list of arguments to pass to svm function, typically involve kernel, gamma, scale

Value

a data.frame

  1. cellID_coln, original cell id

  2. SVM_class, 0 for below cutoff, 1 for above cutoff

  3. transID_coln, original transcript_id

  4. transGene_coln, target gene of transcript

  5. score_coln, score in transcript_df

  6. spatLocs_colns for spatial coorindates of transcript

  7. DecVal, decision values of svm model output

  8. SVM_cell_type, new cell type for each transcript groups within each cells

Details

For score of transcripts within each cell, assign 0 or 1 label to each transcript based on whether the score is above score_cutoff; then run support vector machine on svm(above_cutoff ~ x + y) for 2D, svm(above_cutoff ~ x + y + z) for 3D, default to do radial kernal with scale = TRUE and gamma = 0.1.