



WGSt <- readRDS(paste0("data-raw/P5931/WGS/raw_counts.rds"))
WGSn <- readRDS(paste0("data-raw/P5931/WGS/ref_counts.rds"))
# Size of each chromosome (hg19 and GRCh38 are provided.)
size <- read.table("sizes.cellranger-GRCh38-1.0.0.txt", stringsAsFactors = F)
# List of cyclegenes retrieved from the "CopyKAT"package (https://github.com/navinlabcode/copykat)
cyclegenes <- readRDS("cyclegenes.rds")
# bed file indicating gene positions (hg19 and GRCh38 are provided.)
bed <- read.table("hg38.genes.bed", sep='\t', header = T)mtx <- readMM("matrix.mtx.gz")
barcodes <- read.table("barcodes.tsv.gz", stringsAsFactors = F, sep='\t', header=F)
features <- read.table("features.tsv.gz", stringsAsFactors = F, sep='\t', header=F)
celltype0 <- readRDS("celltype_all.rds")library(Clonalscope)
dir_path <- "/output/"
Obj_filtered <- Createobj_bulk(raw_counts=WGSt, # from matched DNA sequencing (bulk/single)
ref_counts=WGSn, # from matched DNA sequencing (bulk/single)
samplename= "Sample",
genome_assembly="GRCh38", dir_path=dir_path, size=size, assay='WGS')
Obj_filtered <- Segmentation_bulk(Obj_filtered=Obj_filtered,
plot_seg = TRUE, hmm_states = c(0.8, 1.1, 1.2))celltype <- celltype0
celltype[which(!grepl('Epithelial', celltype[,2])),2] <- 'normal'
clustering_barcodes <- celltype[which(grepl("Epithelial",celltype[,2])),1]
Input_filtered <- FilterFeatures(mtx=mtx, barcodes=barcodes, features=features, cyclegenes=cyclegenes)
# Remove raw inputs
rm(mtx); rm(barcodes); rm(features)
Cov_obj <- RunCovCluster(mtx=Input_filtered$mtx, barcodes=Input_filtered$barcodes,
features=Input_filtered$features, bed=bed,
celltype0=celltype, var_pt=0.99, var_pt_ctrl=0.99, include='all',
alpha_source='all', ctrl_region=NULL,
seg_table_filtered=Obj_filtered$seg_table, size=size,
dir_path=dir_path, breaks=50, prep_mode = 'intersect', est_cap = 2,
clust_mode='cna_only',clustering_barcodes=clustering_barcodes)clustering <- Cov_obj$result_final$clustering
clustering2 <- Cov_obj$result_final$clustering2
result <- Cov_obj$result_final$result
table(result$Zest)
PlotClusters(df = Cov_obj$result_final$df_obj$df, celltype = celltype0, Assign_obj =result, mode = "genome", fontsize = 7, lab_mode='annot')




WGSt <- readRDS(paste0("data-raw/P5931/WGS/raw_counts.rds"))
WGSn <- readRDS(paste0("data-raw/P5931/WGS/ref_counts.rds"))
# Size of each chromosome (hg19 and GRCh38 are provided.)
size <- read.table("sizes.cellranger-GRCh38-1.0.0.txt", stringsAsFactors = F)
# List of cyclegenes retrieved from the "CopyKAT"package (https://github.com/navinlabcode/copykat)
cyclegenes <- readRDS("cyclegenes.rds")
# bed file indicating gene positions (hg19 and GRCh38 are provided.)
bed <- read.table("hg38.genes.bed", sep='\t', header = T)mtx <- readMM("matrix.mtx.gz")
barcodes <- read.table("barcodes.tsv.gz", stringsAsFactors = F, sep='\t', header=F)
features <- read.table("features.tsv.gz", stringsAsFactors = F, sep='\t', header=F)
celltype0 <- readRDS("celltype_all.rds")library(Clonalscope)
dir_path <- "/output/"
Obj_filtered <- Createobj_bulk(raw_counts=WGSt, # from matched DNA sequencing (bulk/single)
ref_counts=WGSn, # from matched DNA sequencing (bulk/single)
samplename= "Sample",
genome_assembly="GRCh38", dir_path=dir_path, size=size, assay='WGS')
Obj_filtered <- Segmentation_bulk(Obj_filtered=Obj_filtered,
plot_seg = TRUE, hmm_states = c(0.8, 1.1, 1.2))celltype <- celltype0
celltype[which(!grepl('Epithelial', celltype[,2])),2] <- 'normal'
clustering_barcodes <- celltype[which(grepl("Epithelial",celltype[,2])),1]
Input_filtered <- FilterFeatures(mtx=mtx, barcodes=barcodes, features=features, cyclegenes=cyclegenes)
# Remove raw inputs
rm(mtx); rm(barcodes); rm(features)
Cov_obj <- RunCovCluster(mtx=Input_filtered$mtx, barcodes=Input_filtered$barcodes,
features=Input_filtered$features, bed=bed,
celltype0=celltype, var_pt=0.99, var_pt_ctrl=0.99, include='all',
alpha_source='all', ctrl_region=NULL,
seg_table_filtered=Obj_filtered$seg_table, size=size,
dir_path=dir_path, breaks=50, prep_mode = 'intersect', est_cap = 2,
clust_mode='cna_only',clustering_barcodes=clustering_barcodes) clustering <- Cov_obj$result_final$clustering
clustering2 <- Cov_obj$result_final$clustering2
result <- Cov_obj$result_final$result
table(result$Zest)
PlotClusters(df = Cov_obj$result_final$df_obj$df, celltype = celltype0, Assign_obj =result, mode = "genome", fontsize = 7, lab_mode='annot')

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。