Plotting means in R by normal distributions with alpha levels and barplots and styles (here)
Package for plotting means + SD + SEM on Matlab (NotBoxPlots)
This is a blog about stuff, problems and practical solutions, I run into while doing my PhD research in [Bio|Chemo]informatics and about everything else in interdisciplinary research using Computers applied to Life Sciences
Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts
Thursday, September 13, 2012
Thursday, June 28, 2012
All Machine Learning Methods Explained
I found a good tutorial/wiki course about machine learning methods and some code on how to implement them here
Thursday, June 21, 2012
Thursday, April 5, 2012
SQLite, Python+SQLite + CSV files
Monday, April 2, 2012
Thursday, March 15, 2012
Python, Numpy, Scipy, Matplotlib and many others in one package
Monday, March 5, 2012
Inset to create a plot inside a plot in matlab
figure(1)
clf;
x=[0:0.1:20]
y=sin(x)
subplot(1,1,1) ; % main plot
plot(x,y,'b')
xlabel('x','fontsize',18)
ylabel('sin(x)','fontsize',18)
axes('position',[0.5 0.6 0.3 0.2]) ; % inset
plot(x,abs(y),'r')
xlabel('x','fontsize',15)
ylabel('abs(sin(x))','fontsize',15)
from this matlab intro.
Monday, February 13, 2012
Thursday, January 5, 2012
Saturday, September 17, 2011
Perl one liner to rename files
Where aaa is the pattern we want to replace with bbb
ls | perl -ne 'chomp; next unless -e; $o = $_; s/aaa/bbb/; next if -e; rename $o, $_';
at the /g to search all the string (replace more than once)
ls | perl -ne 'chomp; next unless -e; $o = $_; s/aaa/bbb/g; next if -e; rename $o, $_';
originally posted with a list of other perl one liners.
Thursday, March 18, 2010
Vectorization in Matlab
This i found in the net, (not my material), however i think is actually good to have this at hand.
Faster calculations in Matlab Manual
Faster calculations in Matlab Manual
Saturday, March 6, 2010
File Preprocessing with awk and Perl
In the last week i have been written bash, perl, python, sed, awk scripts, i have been writting even scripts to write my scripts, this are the tricks i want to save for later...
- how to get rid of the blank lines of a file
awk '$1 !~ /(^$)/' someFile > someNewFile
this will do the same
cat somefile | grep -v '^$' >> someNewFile
Other problem i have run into, has been the problems with carriage return in unix and other systems, in some systems is "\r" in unix is "\n", the worst part happens when you want to read a file in bash and nothing happens and then you check by using
od -c
and realize that all the newlines are "\r". I found that the best way to solve this is to use a simple Perl one liner:
perl -pe 's/\r\n|\n|\r/\n/g'
which i found in the newline wiki page
- how to get rid of the blank lines of a file
awk '$1 !~ /(^$)/' someFile > someNewFile
this will do the same
cat somefile | grep -v '^$' >> someNewFile
Other problem i have run into, has been the problems with carriage return in unix and other systems, in some systems is "\r" in unix is "\n", the worst part happens when you want to read a file in bash and nothing happens and then you check by using
od -c
and realize that all the newlines are "\r". I found that the best way to solve this is to use a simple Perl one liner:
perl -pe 's/\r\n|\n|\r/\n/g'
which i found in the newline wiki page
Monday, February 8, 2010
Reading files into a dictionary in python
This one i use all the time to read massive datasets, it is equivalent to what you can do in perl with the @
import os,sys
import linecache
import string
if __name__ == "__main__":
#print len(sys.argv)
if (len(sys.argv) == 2): #arg 0 = name, arg 1 = argument
file=sys.argv[1] #get the pointer to file
rfp = open('results.txt',"w") #open a file to print results
arr = linecache.getlines(file) #get the file into the dictionary called arr
lines = len(arr)
for i in xrange(lines):
arr[i]= arr[i].strip().split() #by default split by \t, but can be changed to whatever symbol
for i in xrange(lines): #remember the line number will be the key to access the list of fields (columns if spreedsheet)
print arr[i]
print arr[i][0], arr[i][n]
import os,sys
import linecache
import string
if __name__ == "__main__":
#print len(sys.argv)
if (len(sys.argv) == 2): #arg 0 = name, arg 1 = argument
file=sys.argv[1] #get the pointer to file
rfp = open('results.txt',"w") #open a file to print results
arr = linecache.getlines(file) #get the file into the dictionary called arr
lines = len(arr)
for i in xrange(lines):
arr[i]= arr[i].strip().split() #by default split by \t, but can be changed to whatever symbol
for i in xrange(lines): #remember the line number will be the key to access the list of fields (columns if spreedsheet)
print arr[i]
print arr[i][0], arr[i][n]
Pick up lines with Perl
There are people who are good at saying or creating pick up lines and use them at bars, pubs and clubs.
Here a Perl 'one-liner' that will help process that 500mb text file (if you are doing bioinformatics, you might know what i am talking about)
If the file has columns separated by space, and you want to get the scores over a certain threshold and print that line to a file (also can be used $. to get the line number)
perl -ane 'if ($F[column_number] > score) {print $_}' filename.txt
if separated by something else
perl -F'symbol' -ane 'if ($F[column_number] > score) {print $_}' filename.txt
some more info
http://www.cbs.dtu.dk/courses/27619/lesson13.html
Here a Perl 'one-liner' that will help process that 500mb text file (if you are doing bioinformatics, you might know what i am talking about)
If the file has columns separated by space, and you want to get the scores over a certain threshold and print that line to a file (also can be used $. to get the line number)
perl -ane 'if ($F[column_number] > score) {print $_}' filename.txt
if separated by something else
perl -F'symbol' -ane 'if ($F[column_number] > score) {print $_}' filename.txt
some more info
http://www.cbs.dtu.dk/courses/27619/lesson13.html
Subscribe to:
Posts (Atom)