page

Feb 11, 2020

Conda - Switching between Python 2 and Python 3 environments

https://docs.anaconda.com/anaconda/user-guide/tasks/switch-environment/


first, you need to install miniconda (minimal installer for conda)
https://docs.conda.io/en/latest/miniconda.html

1. create python 2.7 environment
 [lee@ko44 ~]$ conda create --name py2 python=2.7


2. create python 3.7 environment
 [lee@ko44 ~]$ conda create --name py3 python=3.7


3. activate python 2 environment
 [lee@ko44 ~]$ conda activate py2

 then, you can see (py2) in terminal
 (py2) [lee@ko44 ~]$

4. deactivate python 2 environment
 (py2) [lee@ko44 ~]$ conda deactivate

 then, you will not see (py2) in terminal
  [lee@ko44 ~]$

Jan 29, 2020

grep : Using grep to search for a string that has a dot in it

https://stackoverflow.com/questions/10346816/using-grep-to-search-for-a-string-that-has-a-dot-in-it

 in grep,  . means "any character" in a regex.

-F  : which would interpret the pattern as a fixed string
-w :  Checking for full words, not for sub-strings using grep -w


grep uses regexes; . means "any character" in a regex.
 If you want a literal string, use grep -F, fgrep, or escape the . to \.
Don't forget to wrap your string in double quotes. Or else you should use \\.

Oct 25, 2019

R : EOF within quoted string - read.delim() vs read.table()

https://kbroman.org/blog/2017/08/08/eof-within-quoted-string/

read.table() uses quote="'\"" (that is, looking for either single- or double-quotes) read.delim() uses quote="\"" (just looking for double-quotes).


To solve quote problem,
In read.table(), use quote="", and for that matter also fill=FALSE 

Oct 14, 2019

SAM Format - SAM flags description

https://www.samformat.info/sam-format-flag-single


 SAM Format - SAM flags description

 - if you type in flag number, it shows descriptions of the flag number

transpose a file with awk

https://stackoverflow.com/questions/1729824/an-efficient-way-to-transpose-a-file-in-bash

Q. transpose a file

X column1 column2 column3
row1 0 1 2
row2 3 4 5
row3 6 7 8
row4 9 10 11

to

X row1 row2 row3 row4
column1 0 3 6 9
column2 1 4 7 10
column3 2 5 8 11
 
A.
 
awk '
{ 
    for (i=1; i<=NF; i++)  {
        a[NR,i] = $i
    }
}
NF>p { p = NF }
END {    
    for(j=1; j<=p; j++) {
        str=a[1,j]
        for(i=2; i<=NR; i++){
            str=str" "a[i,j]; # check FS (ex: space, tab, etc)
        }
        print str
    }
}' file

 

Oct 8, 2019

MATLAB - Data label on each point in xy scatter

https://stackoverflow.com/questions/7100398/data-label-on-each-entry-in-xy-scatter



p = rand(10,2);
scatter(p(:,1), p(:,2), 'filled')
axis([0 1 0 1])

labels = num2str((1:size(p,1))','%d');    %'
text(p(:,1), p(:,2), labels, 'horizontal','left', 'vertical','bottom','Fontsize', 7)