Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #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

    • super0925
      Senior Member
      • Feb 2014
      • 206

      #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

      • dpryan
        Devon Ryan
        • Jul 2011
        • 3478

        #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

        • super0925
          Senior Member
          • Feb 2014
          • 206

          #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

          • dpryan
            Devon Ryan
            • Jul 2011
            • 3478

            #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

            • gringer
              David Eccles (gringer)
              • May 2011
              • 845

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

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

              Comment

              • super0925
                Senior Member
                • Feb 2014
                • 206

                #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

                • LacquerHead
                  Member
                  • Nov 2015
                  • 31

                  #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

                  • SEQadmin2
                    Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
                    by SEQadmin2



                    Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

                    Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
                    ...
                    10-14-2026, 09:55 AM
                  • SEQadmin2
                    New Genomics Technologies Take Aim at Long-Standing Limits
                    by SEQadmin2


                    Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

                    We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
                    ...
                    09-28-2026, 10:25 AM

                  ad_right_rmr

                  Collapse

                  News

                  Collapse

                  Topics Statistics Last Post
                  Started by SEQadmin2, 10-15-2026, 10:52 AM
                  0 responses
                  12 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 10-14-2026, 05:39 AM
                  0 responses
                  19 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 10-13-2026, 09:56 AM
                  0 responses
                  19 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 10-09-2026, 11:14 AM
                  0 responses
                  27 views
                  0 reactions
                  Last Post SEQadmin2  
                  Working...