getGenomeAndAnnotation {ORFik} | R Documentation

## Download genome (fasta), annotation (GTF) and contaminants

### Description

This function automatically downloads (if files not already exists) genomes and contaminants specified for genome alignment. Will create a R transcript database (TxDb object) from the annotation.
It will also index the genome for you
If you misspelled something or crashed, delete wrong files and run again.
Do remake = TRUE, to do it all over again.

### Usage

    getGenomeAndAnnotation(
      organism,
      output.dir,
      db = "ensembl",
      GTF = TRUE,
      genome = TRUE,
      merge_contaminants = TRUE,
      phix = FALSE,
      ncRNA = FALSE,
      tRNA = FALSE,
      rRNA = FALSE,
      gunzip = TRUE,
      remake = FALSE,
      assembly_type = "primary_assembly",
      optimize = FALSE
    )

### Arguments

`organism` | scientific name of organism, Homo sapiens, Danio rerio, Mus musculus, etc. See `biomartr:::get.ensembl.info()` for full list of supported organisms.
`output.dir` | directory to save downloaded data
`db` | database to use for genome and GTF, default adviced: "ensembl" (remember to set assembly_type to "primary_assembly", else it will contain haplotypes, very large file!). Alternatives: "refseq" (primary assembly) and "genbank" (mix)
`GTF` | logical, default: TRUE, download gtf of organism specified in "organism" argument. If FALSE, check if the downloaded file already exist. If you want to use a custom gtf from you hard drive, set GTF = FALSE, and assign: annotation <- getGenomeAndAnnotation(gtf = FALSE) annotation["gtf"] = "path/to/gtf.gtf". If db is not "ensembl", you will instead get a gff file.
`genome` | logical, default: TRUE, download genome of organism specified in "organism" argument. If FALSE, check if the downloaded file already exist. If you want to use a custom gtf from you hard drive, set GTF = FALSE, and assign: annotation <- getGenomeAndAnnotation(genome = FALSE) annotation["genome"] = "path/to/genome.fasta". Will download the primary assembly for ensembl
`merge_contaminants` | logical, default TRUE. Will merge the contaminants specified into one fasta file, this considerably saves space and is much quicker to align with STAR than each contamint on it's own. If no contaminants are specified, this is ignored.
`phix` | logical, default FALSE, download phix sequence to filter out with. Phix is used as a contaminant genome. Only use if illumina sequencing. Phix is used in Illumina sequencers for sequencing quality control. Genome is: refseq, Escherichia virus phiX174
`ncRNA` | logical or character, default FALSE (not used, no download), ncRNA is used as a contaminant genome. If TRUE, will try to find ncRNA sequences from the gtf file, usually represented as lncRNA (long noncoding RNA's). Will let you know if no ncRNA sequences were found in gtf. If not found try character input: Alternatives: "auto" or manual assign like "human". If "auto" will try to find ncRNA file on NONCODE from organism, Homo sapiens -> human etc. "auto" will not work for all, then you must specify the name used by NONCODE, go to the link below and find it. If not "auto" / "" it must be a character vector of species common name (not scientific name) Homo sapiens is human, Rattus norwegicus is rat etc, download ncRNA sequence to filter out with. From NONCODE online server, if you cant find common name see: http://www.noncode.org/download.php/
`tRNA` | logical or character, default FALSE (not used, no download), tRNA is used as a contaminant genome. If TRUE, will try to find tRNA sequences from the gtf file, usually represented as Mt_tRNA (mature tRNA's). Will let you know if no tRNA sequences were found in gtf. If not found try character input: if not "" it must be a character vector to valid path of mature tRNAs fasta file to remove as contaminants on your disc. Find and download your wanted mtRNA at: http://gtrnadb.ucsc.edu/, or run trna-scan on you genome.
`rRNA` | logical or character, default FALSE (not used, no download), rRNA is used as a contaminant genome. If TRUE, will try to find rRNA sequences from the gtf file, usually represented as rRNA (ribosomal RNA's). Will let you know if no rRNA sequences were found in gtf. If not found you can try character input: If "silva" will download silva SSU & LSU sequences for all species (250MB file) and use that. If you want a smaller file go to https://www.arb-silva.de/ If not "" or "silva" it must be a character vector to valid path of mature rRNA fasta file to remove as contaminants on your disc.
`gunzip` | logical, default TRUE, uncompress downloaded files that are zipped when downloaded, should be TRUE!
`remake` | logical, default: FALSE, if TRUE remake everything specified
`assembly_type` | a character string specifying from which assembly type the genome shall be retrieved from (ensembl only, else this argument is ignored): Default is `assembly_type = "primary_assembly")`. This will give you all no copies of any chromosomes. As an example, the primary_assembly fasta genome in human is only a few GB uncompressed. `assembly_type = "toplevel")`. This will give you all multi-chromosomes (copies of the same chromosome with small variations). As an example the toplevel fasta genome in human is over 70 GB uncompressed.
`optimize` | logical, default FALSE. Create a folder within the folder of the gtf, that includes optimized objects to speed up loading of annotation regions from up to 15 seconds on human genome down to 0.1 second. ORFik will then load these optimized objects instead. Currently optimizes filterTranscript() and loadRegion().

### Details

If you want custom genome or gtf from you hard drive, assign it after you run this function, like this:
annotation <- getGenomeAndAnnotation(GTF = FALSE, genome = FALSE)
annotation["genome"] = "path/to/genome.fasta"
annotation["gtf"] = "path/to/gtf.gtf"

### Value

a named character vector of path to genomes and gtf downloaded, and additional contaminants if used. If merge_contaminants is TRUE, will not give individual fasta files to contaminants, but only the merged one.

### See Also

Other STAR: `STAR.align.folder()`, `STAR.align.single()`, `STAR.allsteps.multiQC()`, `STAR.index()`, `STAR.install()`, `STAR.multiQC()`, `STAR.remove.crashed.genome()`, `install.fastp()`

### Examples

    ## Get Saccharomyces cerevisiae genome and gtf (create txdb for R)
    #getGenomeAndAnnotation("Saccharomyces cerevisiae", tempdir(), assembly_type = "toplevel")
    ## Get Danio rerio genome and gtf (create txdb for R)
    #getGenomeAndAnnotation("Danio rerio", tempdir())

    output.dir <- "/Bio_data/references/zebrafish"
    ## Get Danio rerio and Phix contamints to deplete during alignment
    #getGenomeAndAnnotation("Danio rerio", output.dir, phix = TRUE)

    ## Optimize for ORFik (speed up for large annotations like human or zebrafish)
    #getGenomeAndAnnotation("Danio rerio", tempdir(), optimize = TRUE)

    ## How to save malformed refseq gffs:
    ## First run function and let it crash:
    #annotation <- getGenomeAndAnnotation(organism = "Arabidopsis thaliana", output.dir = "~/Desktop/test_plant/",
    #  assembly_type = "primary_assembly", db = "refseq")
    ## Then apply a fix (example for linux, too long rows):
    # \code{system("cat ~/Desktop/test_plant/Arabidopsis_thaliana_genomic_refseq.gff | awk '{ if (length($0) < 32768) print }' > ~/Desktop/test_plant/Arabidopsis_thaliana_genomic_refseq_trimmed2.gff")}
    ## Then updated arguments:
    annotation <- c("~/Desktop/test_plant/Arabidopsis_thaliana_genomic_refseq_trimmed.gff",
     "~/Desktop/test_plant/Arabidopsis_thaliana_genomic_refseq.fna")
    names(annotation) <- c("gtf", "genome")
    # Make the txdb (for faster R use)
    # makeTxdbFromGenome(annotation["gtf"], annotation["genome"], organism = "Arabidopsis thaliana")

[Package ORFik version 1.12.13 Index]