[R] How to create errorbars with overlaid points using ggplot
library(ggplot2) library(dplyr) Sometimes you may want to create a plot with the following features:
a point to indicate the mean of a group error bars to indicate the standard deviation of the group and each group may have subgroups, which are represented by different colors. In this post, I will show you how to create such a plot using the ggplot2 package in R.
We will use the builtin mtcars dataset as an example.
[git] Exclude a path when staging files
Occasionally, you may want to exclude a specific path when staging files in Git. This can be useful when you have a directory with many files, but you only want to stage some of them. Today I will show how to do it.
Preparation First, let’s clone a git repository and create some files to demonstrate the process.
The repository used here is one of my own, which contains some bioinformatics tools.
[Linux] How to set limit on memory usage in a shell?
Occasionally, my computer crashed when I ran a program which ate up all the memory. To prevent this from happening again, I want to set a limit on the memory usage in a shell, so any command run in that shell will be limited to set memory usage.
My system OS: Ubuntu 22.04 Solution not working I searched Google and many suggested to use
1 ulimit -m <value> to set memory usage, but it did not work – no restriction on memory at all.
[R] data.table's frank()
knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE) library(knitr) library(data.table) One can use data.table::frank() to rank the rows of a data.table or simply a vector. Compared to the base R function rank(), frank() is faster. Today I will show how to use this function.
First, let’s generate a example data.table with 10 rows and 3 columns, for simplicity, we will make first 2 columns are integer and the last one is a character.
[LibreOffice] How to shrink print an excel sheet
I have been using opensource LibreOffice to handle my office documents, which is convenient and free.
Today, I found one trick for shrinking documents when printing in order to print it in one page. More specifically, I was working on an excel sheet, which is opened with the Calc app of LibreOffice.
To do so, one just need to open the excel file, and then choose File -> Print Preview, and can see the menu in the following screenshot.
[Linux] "NO EFI System Partition was found" when installing Ubuntu 22.04
Background I have an old Lenovo Ideapad U410 machine, which has an updated Windows 10 system (original was Windows 7).
Given that the system is so slow after a decade, I decide to install Ubuntu onto it and make it dual-boot.
So I created a bootable USB disk with Ubuntu 22.04 installation media on it and start to install it by following the tutorial.
The problem When I chose a free disk partition to install Ubuntu, it first popped a message No root file system defined.
[R] How to install R package from a private git repo in Dockerfile
What if you see a great R package, but it is in a private git repo; moreover, you need to build a docker image and install the package into it? The main challenge is how can you provide the git credentials to the package installer in Dockerfile.
I did Google search and found this post, in which a Personal Access Token (PAT) is passed into docker building process via an argument.
[R] Set temporary folder for R in Rstudio server
In another post, I described how to install Rstudio server on Ubuntu. In this post, I will describe how to set temporary folders for R sessions connected to an Rstudio server. This is important, because the default temporary folder /tmp could get overload easily when multiple R sessions are connected and/or big data are stored, yielding lack of space issue.
Temporary folder in R One can get the temporary directory set for the current R session by typing the following command in R terminal:
[Linux] How to clone a private git repo in Dockerfile
Sometimes, one may want to download code from a private repo when building a docker image based on a Dockerfile. However, the process building the docker image doesn’t have the same privilege as the host running docker build. Fortunately, the newer version docker has provided the capability for us to pass git secrets to the image-building process. Let’s see how.
Step 1: add an ssh key to github account Follow this post to generate and add ssh key to your github account, and this github account should contain the private repo to access from Dockerfile.
[Tips] Replace SAM header in a bam file
Sometimes one need to replace the SAM header lines in a bam file in order to change the order of chromosomes in the sorted bam file.
Note the output of samtools sort is determined by the order of chromosomes in the SAM header (i.e., @SQ lines), so if in the header, chr1 appears after chr2, then after sorting, all the reads aligned to chr1 will appear after those aligned to chr2.