[git] add flake8 and black hooks to git repository
PEP8 provides guideline on writing python code. To make the compliance to the guideline easy, one can automate this process. There are two ways to achieve this: pre-commit check and github actions. Today, we will talk about how to implement pre-commit check. pre-commit check installs hooks to a git repo, and when committing new code, the hooks will be triggered. Let’s start. Step 1. Install pre-commit package 1 pip install pre-commit After this, add ‘pre-commit’ to the ‘requirements.
2021-01-23   schedule 2 min 6 s  
Add office 365 calendar to Thunderbird
Thunderbird is a powerful software to handle emails and calendar accounts. Recently, I had a new laptop and installed the latest Thunderbird version 78.6.0, and want to add my office 365 calender into it. ). Steps After searching internet for a while, I found that the following solution worked out: Install TbSync addon. Install Provide for Exchange ActiveSync addon. Start the TbSync Addon from Tools->Addon options->TbSync.
2021-01-11   schedule 39 s  
[Learning notes] R S4 classes
There are three kinds of classes in R, S3, S4, and RC (or R6). The S3 class is simply created by adding a ‘class’ attribute to an object. The S4 class is stricter and need formally created, but it is still different from the classes in other object-oriented programming languages such as Java, in terms of class inheritance and method dispatch. The RC/R6 classes are more like the classes in Java.
2020-10-03   schedule 3 min 20 s  
[R] Use variables in RMarkdown chunk options
One can use variables as chunk options, which gives convenience in controlling the document appearance programmatically. Normally one need set up a variable in prior chunks to use it in current chunk. Here is an example. The code ```{r set-var, eval=F} cat("Chunk 1") outWid="50%" ``` ```{r plot1, fig.cap=paste("out.width =", outWid), out.width=outWid} cat("Chunk 2") outWid="20%" plot(1:10) ``` ```{r plot2, fig.cap=paste("out.width =", outWid), out.width=outWid} cat("Chunk 3") plot(1:10) ``` The output cat("Chunk 1") ## Chunk 1 outWid="50%" cat("Chunk 2") ## Chunk 2 outWid="20%" plot(1:10) Figure 1: out.
2020-07-18   schedule 1 min 3 s  
[Python] Add pushback capacity to generators
Generators are a special kind of functions which return values using the keyword yield. The function itself is actually an iterator, allowing traversing its returned values in a for loop. Sometimes, one may want to push back a obtained value to the generator and read again next time. To do so, one can create a iterable class to wrap generators. Below is an example: A generator First, let’s construct a generator.
2020-06-10   schedule 1 min 31 s  
[R] minfi ERROR; return code from pthread_create() is 22
minfi is an R package to analyze DNA methylation arrays, such Illumina 450K and EPIC arrays. One main function in the minfi package is estimateCellCounts; it can be used to estimate immuno cell fractions from a sample based on DNA methylation values. However, recently when I tried to run the function, I met the following problem during the normalization step: 1 2 3 4 5 6 7 8 9 10 Loading required package: FlowSorted.
2020-04-10   schedule 2 min 6 s  
[Linux] Caution: using command 'less' on gzipped file
A couple of years ago, I found that I can use Linux command less to view gzipped file, such as: 1 less in.gz This is very convenient to view gzipped file content. However, recently, I noticed a problem with it. For a file which has 42196516 lines, if I opened it with less, it gave me a count of 30356021 lines: 1 2 less test.fq.gz | wc -l; # giving 30356021 gzip -dc test.
2019-12-27   schedule 28 s  
[Tips] Get the OS version of Linux
There are many variants of Unix/Linux systems, such as Ubuntu, Redhat, and even some versions in Windows system such as MinGW/Msys and Cygwin. Today I am going to introduce a way to get such information, which is simple, run the following command 1 uname -o Running this command in Ubuntu and Redhat will yield GNU/Linux, while running it under MinGW/Msys yields Msys. If you run 1 uname -r will give you kernel release.
2019-11-02   schedule 36 s  
[Bioinfo] Extract data using NCBI E-utilities
Today I am going to introduce a powerful tool to retrieve data from NCBI – E-utilities. This is a REST API for NCBI databases. I used the API several years ago, but recently I picked it up again for my projects, so I think that this is a good opportunity to make some records for my future use as well as for internet users. So let’s start. Introduction The use of the API has the following format:
2019-10-16   schedule 2 min 55 s  
[Linux] Input password automatically
In this post, I will introduce an approach to input password programatically, which is useful if a repeated command needs password. Note: this approach is subject to the risk of exposing your passwords to others, so use it with caution. Let’s use sudo as an example. Normally when you type 1 sudo ls It will prompt for a password if you set one. However, if you type
2019-10-07   schedule 28 s