-
find LCA using nested dictionary in Python
Least common ancestor (LCA) is an extremely useful algorithm in taxonomy assignment which enables the identification of the shared parent node for a list of given child nodes. Here is a piece of code …
-
Tricks of shell
Note: some comands refer to commandlinefu website Combining find with xargs The combination of find print0 and xargs -0 is extremely useful when dealing with multiple files which may contain space in …
-
R coding tricks
“[“ is actually a function in R. When using FUN=”[“, the first argument to “[“ is the current element of the list (being iterated over), ie, the object being subsetted. While the subsequent arguments …
-
Math equation test
$$\frac{\partial u}{\partial t}= h^2 \left( \frac{\partial^2 u}{\partial x^2} +\frac{\partial^2 u}{\partial y^2} +\frac{\partial^2 u}{\partial z^2}\right)$$ …
-
Survival analysis using R and Python
生存期分析在疾病研究中十分重要这自然不必说。目前有很多工具支持survival analysis,比如R中的survival包,Python的lifelines。我对Python更加熟悉,所以更倾向于使用lifelines,lifelines提供了Cox regression和kaplan-meier plot,十分方便。但是R的survival也是相当常用的,网上可以找到很多这种例子,以下代码实 …
-
Calculate the identity of the BWA alignments
Since BWA does not report the similarity of the read to reference, we can use the edit distance tag “NM” to retrieve the information regarding the difference between read and reference on sequence. Af …
-
Plot heatmap with side color indicating the class of variables
Sometimes, we need to make heatmaps for the matrix data with class information of categorical variables. In this case, we may want to use side color to mark the classes. Since neither matplotlib nor s …
-
Some useful tips for pandas
Select or groupby one column in pandas datafram with multi-level index To select one column in a datafram with multi-level index, you can use a tuple containing the names of the column in different …
-
Taxonomy tree constructio and visualization
Here is a list of some commanly used tools for taxonomy tree constructio and visualization: iTOL, ete3, fasttree, QIIME, PhyloToAST, PhyloT, jsPhyloSVG, newick.js + D3.js …
-
Data visualization with Python
最近经常用Python画柱状图和heatmap,一般需要存储为矢量图的PDF文件,方便后期编辑。 这里面有些需要注意的地方,记录如下:(另外我还发现在Jupyter中运行Python代码save的图像文件的字体有写异常,往往不是字母重叠就是距离太远,但是在Jupyter以外生成的图片正常。目前我还没有找到其中原因。) 关于pdf的图中启用Truetype字体方便编辑 1 plt.rcParam …