6 Processing of tetraploid-complemented control embryos

setwd(here::here())
library("metacell")
library("tgstat")
library("tgconfig")
library("Matrix")
library("dplyr")
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
scdb_init("scrna_db/", force_reinit = T)
## initializing scdb to scrna_db/
mat1 <- scdb_mat("control_tetra")

6.0.0.1 Remove extraembryonic ectoderm and parietal endoderm cells

source("scripts/pipeline/remove_exe_ectoderm_and_parietal_endo_cls.R")
mat1 <- remove_exe_ectoderm_and_parietal_endoderm(mat_query = mat1)

6.0.0.2 Merge cells with the wildtype atlas

We first merge this matrix with the tetraploid-complemented control embryos from Mittnenzweig, Mayshar et al. Cell (2021)

source("scripts/pipeline/preprocessing_foxc_experiment_control_tetraploid_mat.R")
preprocessing_tetraploid_control_mat_from_embflow_paper()
source("scripts/pipeline/merge_umi_mat_with_wt10_umi_mat.R")
source("scripts/pipeline/merge_umi_mat_with_wt10_umi_mat.R")
mat2 <- scdb_mat("control_tetra_from_embflow_paper_f")

mat_new <- merge_two_scmat(mat1 = mat1, mat2 = mat2)

scdb_add_mat("control_tetra_all", mat = mat_new)

Next merge matrix with WT cells

mat_new <- scdb_mat("control_tetra_all")
mat_new <- merge_umi_mat_with_wt10(scmat = mat_new)
scdb_add_mat(id = "control_tetra_all_wt10", mat = mat_new)

6.0.0.3 Generate single-cell balanced kNN-graph

This step needs the file
data/tet_tko.bad_genes.txt

source("scripts/pipeline/gen_cgraph.R")
## initializing scdb to scrna_db/
gen_cgraph(mat_nm = "control_tetra_all", force_recompute_cgraph = F)
## [1] TRUE
gen_cgraph(mat_nm = "control_tetra_all_wt10", force_recompute_cgraph = F)
## [1] TRUE

6.0.0.4 Transfer cell type annotation to chimera cells

source("scripts/pipeline/transfer_cell_type_annotation.R")
transfer_color_chimera_tetraploid(mat_nm = "control_tetra_all_wt10")

6.0.0.5 Time tetraploid-complemented embryos based on their injected control cells

source("scripts/pipeline/transfer_time_annotation.R")
## Loading required package: slam
## Loading required package: sparsesvd
source("scripts/pipeline/tetraploid_timing.R")
tetra_timing("control_tetra_all_wt10")

6.0.0.6 Export infered time and cell type into table

source("scripts/pipeline/create_metadata.R")
create_control_tetraploid_metadata()