Installation of Atom on Windows 10
Atom is a very cool editor built with HTML, JavaScript, CSS, and Node.js. Due to this, one can customize Atom with the web tools. Atom runs on Electron, a framework for building cross platform apps using web technologies. Today, I just installed Atom, and here I would like to share some tips on the process. Installation There are two ways to install Atom version 1.55.0. Using exe file: Download the exe file, and then double click it to install as usual.
2021-04-07   schedule 1 min 22 s  
[R] Rmarkdown themes
Rmarkdown is a powerful tool to write documents once and can generate different kinds of output formats such as PDF, html, docx, etc. Along with it, there are many resources for using the rmarkdown. One of them is tons of themes for shaping the output style. For the html_document output, in addition to the default theme, there are other builtin ones, including: “cerulean”, “cosmo”, “flatly”, “journal”, “lumen”, “paper”, “readable”, “sandstone”, “simplex”, “spacelab”, “united”, and “yeti”.
2021-02-03   schedule 1 min 4 s  
[R] Arrange images in a table
library(knitr) library(kableExtra) Sometimes, we need arrange images into a grid. I know two approaches for this. One is to manually fill table cells with strings like ![](path/to/img), and the other is to use function column_spec(column, image=vector_of_files) from kableExtra. In this post, I am going to show both approaches. First, let’s generate some figures. Generating figures We will use the builtin dataset mtcars. figFiles<-file.path( c("scatter.png","hist.png", "boxplot.png","density.png", "barplot.png","line.png") ) i=1; width=5; height=5; unit="in"; dpi=300; png(figFiles[i], width=width, height = height, units = unit, res = dpi) with(mtcars, plot(mpg ~ cyl, main="scatter plot")) tmp<-dev.
2021-02-01   schedule 1 min 21 s  
[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