Skip to content

Commit

Permalink
add gene_id for parse_oarfish_sc_output
Browse files Browse the repository at this point in the history
  • Loading branch information
ChangqingW committed Dec 19, 2024
1 parent 596348b commit 80ab567
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: FLAMES
Title: FLAMES: Full Length Analysis of Mutations and Splicing in long read RNA-seq data
Version: 2.1.2
Version: 2.1.3
Date: 2023-03-27
Authors@R: c(
person("Luyi", "Tian", role=c("aut"),
Expand Down
23 changes: 21 additions & 2 deletions R/quantification.R
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,34 @@ parse_oarfish_sc_output <- function(oarfish_out, annotation, outdir) {

annotation_grl <- get_GRangesList(annotation)
if (file.exists(file.path(outdir, "isoform_annotated.gff3"))) {
isoform_grl <- get_GRangesList(file.path(outdir, "isoform_annotated.gff3"))
novel_annotation <- file.path(outdir, "isoform_annotated.gff3")
} else if (file.exists(file.path(outdir, "isoform_annotated.gtf"))) {
novel_annotation <- file.path(outdir, "isoform_annotated.gtf")
} else {
novel_annotation <- NULL
message("No novel annotation found.")
}
if (!is.null(novel_annotation)) {
novel_grl <- get_GRangesList(novel_annotation)
annotation_grl <- c(annotation_grl,
isoform_grl[!names(isoform_grl) %in% names(annotation_grl)]
novel_grl[!names(novel_grl) %in% names(annotation_grl)]
)
}

annotation_grl <- annotation_grl[names(annotation_grl) %in% rownames(sce)]
SummarizedExperiment::rowRanges(sce)[names(annotation_grl)] <- annotation_grl
rowData(sce)$transcript_id <- rownames(sce)

# add gene ID
gene_id_tb <- c(annotation, novel_annotation) |>
lapply(txdbmaker::makeTxDbFromGFF) |>
lapply(\(x) GenomicFeatures::transcriptsBy(x, by="gene")) %>%
do.call(c, .) |>
lapply(\(x) GenomicRanges::mcols(x)[, 'tx_name', drop=FALSE]) |>
lapply(as.data.frame) |>
dplyr::bind_rows(.id = "gene_id")
rowData(sce)$gene_id <- gene_id_tb[match(rownames(sce), gene_id_tb$tx_name), "gene_id"]

return(sce)
}

Expand Down

0 comments on commit 80ab567

Please sign in to comment.