Announcement

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

  • R script help

    Hey everyone,

    I am working on an R script that will pull contig ID and ranges of differentially expressed transcripts out of the genomic reference I used as input for Cuffdiff. I have the script working, but when it runs into transcripts with the same contig ID (Different ranges) it will only count the first one it encounters and skips the redunancy.

    The format of my contig name and range is formatted like this:

    NAME START END
    gi340012932gbAFJA01012285.1 0 524
    gi340012938gbAFJA01012279.1 10334 12405
    gi340012938gbAFJA01012279.1 2260 7496
    gi340012938gbAFJA01012279.1 69 2164
    gi340012938gbAFJA01012279.1 9069 10084
    gi340013005gbAFJA01012212.1 5696 9927
    gi340013006gbAFJA01012211.1 4079 11139

    As you can see, there is redundancy in the contig ID, but the ranges are different.



    I am getting warning messages looking something like this:

    Warning messages:
    1: In St:Ed : numerical expression has 2 elements: only the first used
    2: In St:Ed : numerical expression has 2 elements: only the first used
    3: In St:Ed : numerical expression has 2 elements: only the first used
    4: In St:Ed : numerical expression has 2 elements: only the first used

    I have copied my script here:

    setwd("C:/Users/Insect1/Documents/Alex/fasta/Treatment_Specific_Analysis")
    files <- list.files(".") # Will list all your files
    library("seqinr") # load the seqinr package
    dnafile <- ("Mrotcontig.fsa") # change the fasta file into an R object
    data <- read.csv("R_Index_N6NF_Apr_9_2013.csv") #reads the csv file "Index" into R
    myseq <- read.fasta(file = dnafile) # creates a fasta file
    for(i in 1:length(data$NAME)){seqname <-data$NAME[i]
    #seqnameB <- noquote(seqname)
    seqB <- getSequence(eval(parse(text=paste("myseq$", seqname, sep = "")))) # the eval and paste functions are needed to construct the search oommand "myseq$MORT00010950" without spaces or quotes mark which make the command nonfunctional
    St <- data[which(data$NAME == seqname), 2]
    Ed <- data[which(data$NAME == seqname), 3]
    trimmedseq <- seqB[St:Ed]
    seqnameC <- paste(seqname,St,"-",Ed)
    write.fasta(sequences = trimmedseq, names = seqnameC, file.out = "Blast.txt", open = "a")
    }
    Blast <-read.fasta("blast.txt", as.string = TRUE)

    Is there an easy fix for making the script address the redundancy in the contig IDs?

    Thanks,
    Alex

  • #2
    Hi Bioinformaticsnewb,
    My experience in R is below standard. Intuitively, what I'll do which you can try while awaiting a better suggestion would be to rename the ID like so:
    gi340012932gbAFJA01012285.1_0-524
    gi340012938gbAFJA01012279.1-10334-12405
    gi340012938gbAFJA01012279.1_2260-7496

    This will mitigate the effect of redundancy.

    HTH

    Comment


    • #3
      R script help

      Hi,

      I'm not sure that I follow what you're trying to do, but

      Is your 'data' object a data frame, and do columns 2 and 3 have names?

      Does the 'R_Index_ ..' file contain the data that you showed an example of with
      columns for NAME START END ?

      One of the components of 'data' appears to be called 'NAME', because
      you refer to data$NAME[i] at the beginning of the for loop.

      I would try changing

      Code:
      St <- data[which(data$NAME == seqname), 2]
      Ed <- data[which(data$NAME == seqname), 3]
      to

      Code:
      St <-data$START[i]
      Ed <- data$END[i]
      but that depends on what is in your 'index' file.

      Comment

      Latest Articles

      Collapse

      • seqadmin
        Advanced Tools Transforming the Field of Cytogenomics
        by seqadmin


        At the intersection of cytogenetics and genomics lies the exciting field of cytogenomics. It focuses on studying chromosomes at a molecular scale, involving techniques that analyze either the whole genome or particular DNA sequences to examine variations in structure and behavior at the chromosomal or subchromosomal level. By integrating cytogenetic techniques with genomic analysis, researchers can effectively investigate chromosomal abnormalities related to diseases, particularly...
        09-26-2023, 06:26 AM
      • seqadmin
        How RNA-Seq is Transforming Cancer Studies
        by seqadmin



        Cancer research has been transformed through numerous molecular techniques, with RNA sequencing (RNA-seq) playing a crucial role in understanding the complexity of the disease. Maša Ivin, Ph.D., Scientific Writer at Lexogen, and Yvonne Goepel Ph.D., Product Manager at Lexogen, remarked that “The high-throughput nature of RNA-seq allows for rapid profiling and deep exploration of the transcriptome.” They emphasized its indispensable role in cancer research, aiding in biomarker...
        09-07-2023, 11:15 PM
      • seqadmin
        Methods for Investigating the Transcriptome
        by seqadmin




        Ribonucleic acid (RNA) represents a range of diverse molecules that play a crucial role in many cellular processes. From serving as a protein template to regulating genes, the complex processes involving RNA make it a focal point of study for many scientists. This article will spotlight various methods scientists have developed to investigate different RNA subtypes and the broader transcriptome.

        Whole Transcriptome RNA-seq
        Whole transcriptome sequencing...
        08-31-2023, 11:07 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by seqadmin, Yesterday, 06:57 AM
      0 responses
      10 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 09-26-2023, 07:53 AM
      0 responses
      10 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 09-25-2023, 07:42 AM
      0 responses
      15 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 09-22-2023, 09:05 AM
      0 responses
      45 views
      0 likes
      Last Post seqadmin  
      Working...
      X