Skip to main content

Posts

Showing posts from 2012

Matlab plot figure modifying tips pixed dpi relationship

Matlab  plot figure all basic operation =========================== x = [1:5]; y = [7 8 1 9  10] h =figure plot(x,y) hold on plot(x, y+5); % change axis properties set(gca,'box','off'); % remove box around figure set(gca,'FontSize',fontsize_tick-1); % set tick size in figure set(gca,'LooseInset',get(gca,'TightInset'));  % if you want to remove space on right of figure xlabel(commonLabelWindow,'fontsize' , fontsize_label); ylabel('Average AT-skew','fontsize' , fontsize_label_special); xlim ( [ min(myX)   max(myX)]) ylim ( [ min( [myY1  myY2  ])   max([ myY1  myY2  ])  ]) % change size of figure http://www.mathworks.com/help/matlab/creating_plots/positioning-figures.html %  set size of figure's "drawing" area on screen ( 5.5 cm  width ) by ( 4.0 cm height) set(gcf, 'Units','centimeters', 'Position',[0 0 5.5 4.0]) % change resolution 600 dpi http

R tutorial

Install R in linux ============ In CRAN home page, the latest version is not available. So, in fedora, Open the terminal yum list R  --> To check the latest available version of r yum install R --> install R version yum update R --> update current version to latest one 0 find help ============ ?exact topic name (  i.e.   ?mean ) 0.0 INSTALL 3rd party package  ==================== install.packages('mvtnorm' , dependencies = TRUE , lib='/home/alamt/myRlibrary/')   #  install new package BED file parsing (Always use read.delim it is the best) library(MASS) #library(ggplot2) dirRoot="D:/research/F5shortRNA/TestRIKEN/Rscripts/" dirData="D:/research/F5shortRNA/TestRIKEN/" setwd(dirRoot) getwd() myBed="test.bed" fnmBed=paste(dirData, myBed, sep="") # ccdsHh19.bed   tmp.bed ## Read bed use read.delim - it is the  best mybed=read.delim(fnmBed, header = FALSE, sep = "\t", quote = &q

Java run with external jar

1. When classpath is used, jar command is ignored . So use "classpath" with class file and "cp" with jar file 2. NEVER FORGET TO PUT : even you use only 1 external jar. In some cases you will get compilation error if you don't put : java  -classpath  /media/Data/eclipseWorkspace/myExternalJar/commons-math-1.2.jar :   com.cbrc.motifmap.CombinationOfTF java  -cp /media/Data/eclipseWorkspace/myExternalJar/commons-math-1.2.jar:    -jar myJar.jar

java comparator sorted linked hash map treemap

////////////  inner class /////////////////     class ValueComparator implements Comparator {         LinkedHashMap  base;         public ValueComparator(LinkedHashMap hMap) {             this.base = hMap;         }         public int compare(Object a, Object b) {             Myclass obj1 = (Myclass) base.get(a);             Myclass obj2 = (Myclass) base.get(b);             if( obj1.getRankDistance() > obj2.getRankDistance()    ) {                 return -1;             }  else {                 return 1;             }         }     }     class Myclass     {         double rankDistance;         DMFmotif  motif;         public Myclass( double rankDistance, DMFmotif motif) {             super();             this.rankDistance = rankDistance;             this.motif = motif;         }         public double getRankDistance() {             return rankDistance;         }         public void setRankDistance(double rankDistance) {             this.rankDistance = rankDistance;         }

LATEX basic command

Float 3 float Table, Figure, Picture Caption can be given only to figure tabular   is just an array. Not float \begin{table} \begin{center} \begin{tabular} { |r | r | r | c | } \hline \multicolumn{4}{c}{this is header of table} \\ \hline 1 & 2 & 3 & 4 \\ \hline \multicolumn{4}{c}{this is text} \\ \hline \bf 4 & \it 5 & 6 & val \\ \hline \hline \end{tabular} \caption{mycaption} \label{lbl:mylabel1} \end{center} \end{table} Math environment running text  $  write here $  centered & new line \[  ]\  \[ \left( \begin{array}{cc} a & b \end{array} \right) \] \[  2^{2^{\cdot{^2}}}  \] Bibtex ..... at end of document write \bibliography{mybib.bib} to cite \cite{label1} \cite{lab1} \bibliography{1} \bibliographystyle{plain} % alpha / unsrt / siam / ieeetr \end{document}

LATEX beamer tutorial

% This text is proprietary. % It's a part of presentation made by myself. % It may not used commercial. % The noncommercial use such as private and study is free % Dec 2007 % Author: Sascha Frank % University Freiburg % www.informatik.uni-freiburg.de/~frank/ % % \documentclass{beamer} \setbeamertemplate{navigation symbols}{} \usetheme{Warsaw} \beamersetuncovermixins{\opaqueness<1>{25}}{\opaqueness<2 -="-">{15}} \begin{document} \title{Beamer Class Warsaw} \author{Sascha Frank} \date{\today} \begin{frame} \titlepage \end{frame} \begin{frame}\frametitle{Table of contents}\tableofcontents \end{frame} \section{Section no.1} \begin{frame}\frametitle{Title} Each frame should have a title. \end{frame} \subsection{Subsection no.1.1  } \begin{frame} Without title somethink is missing. \end{frame} \section{Section no. 2} \subsection{Lists I} \begin{frame}\frametitle{unnumbered lists} \begin{itemize} \item Introduction to  \LaTeX \item Course 2 \item Termpapers and pres

C/C++ header file inlcude "" OR<> how to use std ?

Suppose your project current directory is 0.   /home/myproj/ Let assume include foder are 1. /home/include1/ 2. /home/include2/ ==>  # include "myhead.h"    search for directory in order 0 , then 1 , then 2 AS IT SEARCH CURRENT DIR FIRST, USUALLY user defined headers used in this way. ==>  # include    search for directory in order 1 , then 2 , then 0 AS IT SEARCH INCLUDE DIR FIRST,  standard headers used in this way. Header file extension: ================== In C : In early days it was .hxx, .hpp . Then it was .h     #include myheader.hxx     #include myheader.hp     #include myheader.hpp In C++ : No extension. They are included in namespaces.    #include    using namespace std; // use original namespace you can also use it in code as std::stringfunction

linux configuration file : bash_profile / bash_logout / bashrc

see also : http://www.troubleshooters.com/linux/prepostpath.htm source : http://www.hypexr.org/bash_tutorial.php#whatis In your home directory, 3 files have a special meaning to Bash, allowing you to set up your environment automatically when you log in and when you invoke another Bash shell, and allow you to execute commands when you log out. These files may exist in your home directory, but that depends largely on the Linux distro you're using and how your sysadmin (if not you) has set up your account. If they're missing, Bash defaults to /etc/profile . You can easily create these files yourself using your favorite texteditor. They are: .bash_profile : read and the commands in it executed by Bash every time you log in to the system .bashrc : read and executed by Bash every time you start a subshell .bash_logout : read and executed by Bash every time a login shell exits Bash allows 2 synonyms for .bash_profile : .bash_login and

Sun Grid Engine : SGE : Basic Commands

http://www.ats.ucla.edu/clusters/common/computing/batch/sge.htm http://web.njit.edu/topics/HPC/basement/sge/SGE.html http://star.mit.edu/cluster/docs/0.92rc2/guides/sge.html 0. First see available q : qstat -g c 1. ALWAYS USE -q queuename 2. To use any particular node use -l hostname (  -l hostname=himem03 ) qsub   -q  normal.q   -e pythonTeswt.err -o pythonTeswt.out   -cwd -S /bin/bash   -l hostname=himem03  testSingledataprep.sh ## using specific node qsub   -q  normal.q   -e pythonTeswt.err -o pythonTeswt.out   -cwd -l hostname=himem03  -S /bin/bash   -l hostname=himem03  testSingledataprep.sh python mafParser.py $mafRoot  $dataRoot  $fNameSpecies $fNameSubEXONLncrna  $fnmStatCount $fnmStatPrcnt $fnmStatSub $fnmSUBEXONStatDETECT  $fnapslncBed /// check my submitted jobs qstat // alluser qstat -u "*" ///// all details of user and nodes userstat /// details of queues qstat -g c // delete jobs qdel jobID // node informations qh

code p-value calculation

  pvalue/p-value calculation HYPERGEOMETRIC TEST http://mengnote.blogspot.com/2012/12/calculate-correct-hypergeometric-p.html # x, q     vector of quantiles representing the number of white balls drawn without replacement from an urn which contains both black and white balls. # m     the number of white balls in the urn. # n     the number of black balls in the urn. # k     the number of balls drawn from the urn. # phyper(q, m, n, k, lower.tail = TRUE, log.p = FALSE) sucessDrawn=1 sucessTotal=2 sampleSize=24 populatonSizeWithoutSample=1751-sampleSize phyper(sucessDrawn-1, sucessTotal, populatonSizeWithoutSample, sampleSize, lower.tail = FALSE, log.p = FALSE) FISHER EXACT TEST Bonferroni correction: Pvalue* (#of test cases) http://www.une.edu.au/WebStat/unit_materials/c7_anova/oneway_bonferroni_adjust.htm http://www.langsrud.com/stat/fisher.htm Code done by  Benoit Marchand /*  * pvalcalc.cpp  *      Author:  Benoit Marchand  */ #include #include     /*   

Python tutorial

How to install different packages: In MAC, use pip pip install -U numpy scipy scikit-learn How to see where the package is installed In MAC: pip show numpy Import all ============ import className OR from package import className Code Structure ======================== 1.  just write script one line by one print "ab" print "cd" 2. Use function (Here you must need a main function ): def myfunc():     print "Inside fnc ab" if __name__ == '__main__':     pass     myfunc()     objUtil = Utilities.printString("Hello world") 3. Use like java, class + function +main myclass.py -------------------- class LncRNA(object):     def __init__(self,chr , chrStart , chrEnd):         self.chr = chr         self.chrStart = chrStart         self.chrEnd = chrEnd           def classfunction():         sOut='';         sOut+= str(self.chr) + '\t' + str(self.chrStart) + '\t' + str