Sometimes painstaking text modifications specially when one is dealing with large data could easily be solved using few lines of scripts of a programming language. In the following I'll issue an R function that could be used to add a text to the end of the sequence names of a multi/single fasta file. The lines of the fasta file that represent the sequence names start with '>' sign. you can also download the script from here .

addTextToFastaName<-function(fileIn, fileOut, addText){

    # Read fasta file line by line into a vector
    tmp=scan(fileIn, what='character')

    # Replace each element of the vector that starts with '>', i.e. the sequence names, with the same names whilest addText added to them
    res= gsub('(^>.*)', paste('\\1',addText,sep=""), tmp)

    # Write the result line by line to the output file
    cat(res, file=fileOut, sep='\n')
}

0

Add a comment

In this post I show how groupScatterPlot(), function of the rnatoolbox R package can be used for plotting the individual values in several groups together with their mean (or other statistics). I think this is a useful function for plotting grouped data when some groups (or all groups) have few data points ! You may be wondering why to include such function in the rnatoolbox package ?! Well ! I happen to use it quit a bit for plotting expression values of different groups of genes/transcripts in a sample or expression levels of a specific gene/transcript in several sample groups. These expression value are either FPKM, TPM, LCPM, or PSI values (Maybe I should go through these different normalizations later in a different post 😐!). But of course its application is not restricted to gene expression or RNAseq data analysis.

For the test, I first generate a list with three random values. The values are generated randomly using normal distribution, featuring different means and standard deviations.

library(rnatoolbox)
datList<- list(
  l1=rnorm(n=30, mean = 10, sd = 3),
  l2=rnorm(n=20, mean = 0, sd = 1),
  l3=rnorm(n=25, mean = 10, sd = 1)
)


Then I plot the grouped values. By default the mean function is used to add a summary for the values. However, other functions (e.g. median) can be defined as the FUN parameter.


png(
  "/proj/pehackma/ali/test/test_rnatoolbox/test_groupedScatterPlot_3.png",
  width=500, height=500, pointsize=21)
groupScatterPlot(l=datList, col=rainbow(3),
                 lty=1, lwd=1.5,
                 ylab="Test values")
dev.off()



0

Add a comment

Labels
Blog Archive
About Me
About Me
My Photo
I am a Postdoc researcher at the Neuromuscular Disorders Research lab and Genetic Determinants of Osteoporosis Research lab, in University of Helsinki and Folkhälsan RC. I specialize in Bioinformatics. I am interested in Machine learning and multi-omics data analysis. My go-to programming language is R.
My Blog List
My Blog List
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.