Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Originally posted by super0925 View Post
    "Error in letterFrequency(getSeq(FASTA, reducedGTF), "GC") :
    error in evaluating the argument 'x' in selecting a method for function 'letterFrequency': Error in value[[3L]](cond) :
    record 1666 (chr6_ssto_hap7:1871448-1871615) failed
    file: genome.fa
    Calls: getSeq ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
    Execution halted
    "
    GTF files match the "top assembly", rather than the "primary assembly". Either download the matching fasta file or remove the haplotype patches from your GTF.

    Comment


    • #17
      Originally posted by dpryan View Post
      GTF files match the "top assembly", rather than the "primary assembly". Either download the matching fasta file or remove the haplotype patches from your GTF.
      Sorry D, I didn't totally get what you said.
      The genes.gtf and genome.fa are downloaded from the latest UCSC homo sapiens hg19 genome.
      How could I 'download the matching fasta' or 'remove the haplotype patches' to use your script?
      Thank you!

      PS: I only change your script to
      GTF <- import.gff(GTFfile, format="gtf", genome="hg19", asRangedData=F, feature.type="exon")
      grl <- reduce(split(GTF, elementMetadata(GTF)$gene_id))
      reducedGTF <- unlist(grl, use.names=T)

      Comment


      • #18
        If you just need the lengths then remove the code that calculates GC content. Something like the following should work:

        Code:
        #!/usr/bin/Rscript
        library(GenomicRanges)
        library(rtracklayer)
        library(Rsamtools)
        
        GTFfile = "something.GTF"
        
        #Load the annotation and reduce it
        GTF <- import.gff(GTFfile, format="gtf", genome="GRCm38.71", asRangedData=F, feature.type="exon")
        grl <- reduce(split(GTF, elementMetadata(GTF)$gene_id))
        reducedGTF <- unlist(grl, use.names=T)
        elementMetadata(reducedGTF)$gene_id <- rep(names(grl), elementLengths(grl))
        
        elementMetadata(reducedGTF)$widths <- width(reducedGTF)
        
        #Create a list of the ensembl_id/GC
        calc_GC_length <- function(x) {
            sum(elementMetadata(x)$widths)
        }
        output <- sapply(split(reducedGTF, elementMetadata(reducedGTF)$gene_id), calc_GC_length)

        Comment


        • #19
          Originally posted by dpryan View Post
          If you just need the lengths then remove the code that calculates GC content. Something like the following should work:

          Code:
          #!/usr/bin/Rscript
          library(GenomicRanges)
          library(rtracklayer)
          library(Rsamtools)
          
          GTFfile = "something.GTF"
          
          #Load the annotation and reduce it
          GTF <- import.gff(GTFfile, format="gtf", genome="GRCm38.71", asRangedData=F, feature.type="exon")
          grl <- reduce(split(GTF, elementMetadata(GTF)$gene_id))
          reducedGTF <- unlist(grl, use.names=T)
          elementMetadata(reducedGTF)$gene_id <- rep(names(grl), elementLengths(grl))
          
          elementMetadata(reducedGTF)$widths <- width(reducedGTF)
          
          #Create a list of the ensembl_id/GC
          calc_GC_length <- function(x) {
              sum(elementMetadata(x)$widths)
          }
          output <- sapply(split(reducedGTF, elementMetadata(reducedGTF)$gene_id), calc_GC_length)

          Hi D
          Brilliant! It works.
          I have just changed one command
          GTF <- import.gff(GTFfile, format="gtf", genome="hg19", asRangedData=F, feature.type="exon")
          However, the result only contain 25369 genes.
          However, there are 23170 rows in the count table generated by HTseq, which means there are 23170 genes in the human genome.
          Why does the dimension are different? I don't think rpkm() could go further if the dimension are different...
          Thank you!

          Comment


          • #20
            There are some entries that htseq-count will skip (those without exons?), which presumably is why this happens. Anyway, you need to ensure that everything is in the same order anyway, so make sure to write meaningful row names and use those with match().

            Comment


            • #21
              Convert your BAM file to FASTQ, then use Kallisto.

              The crazy thing is that this might actually be quicker than other methods.

              Comment


              • #22
                Originally posted by dpryan View Post
                There are some entries that htseq-count will skip (those without exons?), which presumably is why this happens. Anyway, you need to ensure that everything is in the same order anyway, so make sure to write meaningful row names and use those with match().
                Thank you D. Very helpful.
                And I also found Cufflinks could calculate RPKM directly.
                by
                cufflinks -o OutDir -g hg19/genes.gtf TopHat/accepted_hits.bam

                Comment


                • #23
                  Hi

                  So the script worked for me and I got an mm9.fa.fai file as output, wondering how this can be used with edgeR to generate the RPKMs? Thanks.

                  Comment

                  Latest Articles

                  Collapse

                  • seqadmin
                    Strategies for Sequencing Challenging Samples
                    by seqadmin


                    Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
                    03-22-2024, 06:39 AM
                  • seqadmin
                    Techniques and Challenges in Conservation Genomics
                    by seqadmin



                    The field of conservation genomics centers on applying genomics technologies in support of conservation efforts and the preservation of biodiversity. This article features interviews with two researchers who showcase their innovative work and highlight the current state and future of conservation genomics.

                    Avian Conservation
                    Matthew DeSaix, a recent doctoral graduate from Kristen Ruegg’s lab at The University of Colorado, shared that most of his research...
                    03-08-2024, 10:41 AM

                  ad_right_rmr

                  Collapse

                  News

                  Collapse

                  Topics Statistics Last Post
                  Started by seqadmin, Yesterday, 06:37 PM
                  0 responses
                  11 views
                  0 likes
                  Last Post seqadmin  
                  Started by seqadmin, Yesterday, 06:07 PM
                  0 responses
                  10 views
                  0 likes
                  Last Post seqadmin  
                  Started by seqadmin, 03-22-2024, 10:03 AM
                  0 responses
                  51 views
                  0 likes
                  Last Post seqadmin  
                  Started by seqadmin, 03-21-2024, 07:32 AM
                  0 responses
                  68 views
                  0 likes
                  Last Post seqadmin  
                  Working...
                  X