I wrote up a short tutorial for
PCA, MDS, k-means, Hierarchical clustering and heatmap for microarray data
and put it on Rpubs.please follow the link https://rpubs.com/crazyhottommy/PCA_MDS
Happy learning!
A wet-dry hybrid biologist's take on genetics and genomics. Mostly is about Linux, R, python, reproducible research, open science and NGS. Grab my book to transform yourself to a computational biologist https://divingintogeneticsandgenomics.ck.page/
${parameter:-defaultValue} | Get default shell variables value |
${parameter:=defaultValue} | Set default shell variables value |
${parameter:?”Error Message”} | Display an error message if parameter is not set |
${#var} | Find the length of the string |
${var%pattern} | Remove from shortest rear (end) pattern |
${var%%pattern} | Remove from longest rear (end) pattern |
${var:num1:num2} | Substring |
${var#pattern} | Remove from shortest front pattern |
${var##pattern} | Remove from longest front pattern |
${var/pattern/string} | Find and replace (only replace first occurrence) |
${var//pattern/string} | Find and replace all occurrences |
command file part_file.result
file
and print it out:file=foo.txt
echo "$file"
foo.txt
txt
to pdf
. one of the commonly known ways is to use thebasename
built-in function:echo "$(basename $file .txt).pdf"
foo.pdf
${string/pattern/replacement}
${string//pattern/replacement}
Following syntax replaces with the replacement string,
Following syntax replaces with the replacement string,
only when the pattern matches at the end of the given $string.
${string/%pattern/replacement}
sed
. see my previous blog post hereecho "${file/txt/pdf}"
foo.pdf
# a more complex exmaple
file_1=foo.txt.foo.txt
echo "${file_1//foo/bar}"
bar.txt.bar.txt
echo "${file_1/foo/bar}"
bar.txt.foo.txt
echo "${file_1/#foo/bar}"
bar.txt.foo.txt
echo "${file_1/%txt/pdf}"
foo.txt.foo.pdf
${string%substring} will delete the shortest match of substring
from back${string%%substring}
will delete the longest match of substring from backecho "${file_1%txt*}pdf"
foo.txt.foo.pdf
echo "${file_1%%txt*}pdf"
foo.pdf
{string#substring}
will delete the shortest match of substring from the begining{string##substring}
will delete the longest match of substring from the beginingecho "bar${file_1#foo*}"
bar.txt.foo.txt
echo "bar${file_1##foo*}.pdf"
bar.pdf
${string:position}
Extract substring from $string at $position
${string:position:length}
$length of characters substring from $string starting from $position
echo "${file_1:4}"
txt.foo.txt
echo "${file_1:4:7}"
txt.foo
echo "${#file_1}"
15