find out the spatially connected transcripts among chosen_transcripts based on LDA hyperplane spatial model which scores each cell for how much their transcripts change their goodness-of-fit over space.
Usage
flagTranscripts_LDA_hyperplane(
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
)
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)
Value
a data.frame
cellID_coln, original cell id
LDA_class, 0 for below cutoff, 1 for above cutoff
transID_coln, original transcript_id
transGene_coln, target gene of transcript
score_coln, score in transcript_df
spatLocs_colns for spatial coorindates of transcript
LD1, LD1 value of LDA model output
LDA_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 linear discriminant analysis on lda(above_cutoff ~ x + y + xy + x^2 + y^2) for 2D, lda(above_cutoff ~ x + y + z+ xy +xz + yz + x^2 + y^2 + z^2) for 3D. Coordinate variables with variance less than 1e-8 would not be used. Z-step of 5E-4mm or similar often resulted in too small of variables for z2.