Commit 1ef96124 authored by Safia Saci's avatar Safia Saci
Browse files

Upload New File

parent f991238f
library(rtracklayer)
library(tidyverse)
# import() retourne un objet GRanges, nous le convertissons en tibble
gencode <- import("data/Sus_scrofa.Sscrofa11.1.102.gtf.gz", format = "GFF") %>% as_tibble
# filtrer en ne garder que les transcrits
transcript <- filter(gencode, type == "transcript")
getMiddleLineFor <- function(gene) {
tempt <- dplyr::filter(transcript, gene_id == gene)
if(tempt$strand[1] == "+") {
# si le gène est '+', le TSS est au 'start'
tempt <- dplyr::arrange(tempt, start)
} else if(tempt$strand[1] == "-") {
# si le gène est '-', le TSS est au 'end'
tempt <- dplyr::arrange(tempt, end)
}
# retourne la ligne du mileur
dplyr::slice(tempt, ceiling(nrow(tempt)/2))
}
midTranscript <- map_dfr(
unique(transcript$gene_id),
getMiddleLineFor
)
write.table(
select(midTranscript, seqnames, start, end, gene_id, score, strand, gene_biotype, gene_name),
file = "data/Sscrofa11.annotation.middleTSStranscript.bed",
quote = FALSE, row.names = FALSE, col.names = FALSE, sep = "\t"
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment