Commit 0c4e14c9 authored by Chaos's avatar Chaos
Browse files

add function tx2gene

parent 8846c34a
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -91,3 +91,27 @@ txdb <- function(
		txdb
	}
}

tx2gene <- function(organism){
	tx2gene_file <- file.path(dir,paste0("tx2gene_for_dturtle",organism,"rds",sep = "."))
	if(!file.exists(tx2_gene_file)){
		tx2gene <-	gtf("mouse") |>
					as.data.table() |> 
					move_columns_to_front(
						columns = c("transcript_name", "gene_name")
					)

		tx2gene$gene_name <- one_to_one_mapping(
								name = tx2gene$gene_name, 
								id = tx2gene$gene_id
							) 
		tx2gene$transcript_name <- one_to_one_mapping(
										name = tx2gene$transcript_name, 
										id = tx2gene$transcript_id
									)
		saveRDS(tx2gene,tx2gene_file,compress = "xz")
	}else{
		tx2gene <- readRDS(tx2gene_file)
	}
	tx2gene
}
 No newline at end of file