Unconfigured Ad

Collapse
X
 
  • Filter
  • 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
                    Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                    by SEQadmin2



                    Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                    ...
                    07-09-2026, 11:10 AM
                  • SEQadmin2
                    Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                    by SEQadmin2



                    Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                    There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                    07-08-2026, 05:17 AM
                  • GATTACAT
                    Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                    by GATTACAT
                    Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
                    07-01-2026, 11:43 AM

                  ad_right_rmr

                  Collapse

                  News

                  Collapse

                  Topics Statistics Last Post
                  Started by SEQadmin2, 07-13-2026, 10:26 AM
                  0 responses
                  24 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 07-09-2026, 10:04 AM
                  0 responses
                  33 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 07-08-2026, 10:08 AM
                  0 responses
                  21 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 07-07-2026, 11:05 AM
                  0 responses
                  34 views
                  0 reactions
                  Last Post SEQadmin2  
                  Working...