跳到主要內容

發表文章

目前顯示的是有「R」標籤的文章

Run Seurat (a R Package) in a notebook interface on a server without root

tl;dr: Dependencies hurts when you try to set up R on server After a while of playing around, I’ll say the best way to use R with a Notebook-style interface on a server where you are no superuser would be using Anaconda, and then run R inside Anaconda to get whatever package you need. It is designed to run for a normal user, so there’s no need for superuser permission, and dependency issue is also taken care of most of the time. If you get the permission on server and are comfortable with R Studio, R Studio Server might be a even better option. That is because even if the packages are in Conda R , Conda Forge , or Bioconda , sometimes they are out of date, which might break dependencies, and conda skeleton and conda build unfortunately come with a lot of dependency issue as well. Besides, the visualization of environment and integration of documentation is better in R Studio for me. What worked for me starts from creating a new environment in Anaconda and install t...

關於Gitk 在 MacOS Sierra 無法啟動一事

最近為了幾個整理資料的小腳本開始使用 Git 來做版本控制 ,假裝自己好像真的會寫程式一樣 。 自己摸索了一會,對於 Git 分支和提交的概念雖然覺得可以想像,不過實作起來又是完全另一回事,每次要提交或放上 Github 都是幾番 Google 以上的工夫。這時看到 這樣的文章 格外的認同。 是啊,終端機界面真的是太黑太危險了,我還是把圖形化的 Gitk 叫出來看看吧。 於是我就 gitk 了一下,發現它崩潰了。 然後又再 gitk 了一下,發現它還是叫不出來。 嗯,看來不是打開的方式不對,是它整個都不太對勁,再一查發現 StackOverflow 早有人解決這個問題。於是先裝 homebrew 讓自己感覺彷彿像學程式的 ,然後 brew cask install tcl 問題解決,不過我反正也沒更新腳本,所以即使 Git 能用了我也沒東西試 (´・ω・`)

第一次的 StackOverflow

今天為一個用 R 畫畫的小腳本第一次到傳說中 的萬事屋 StackOverflow 去 發問 了,謹為文記念。 在我一拐一拐學著 R 的過程中,帶我前進的拉力的成分幾乎全是 StackOverflow (至於推力嘛,當然就是在實驗室生活中越養越肥美的懶病),如果沒有它,我想寫出來偷懶的腳本十個有十一個會寫到 library(stringr) 就結束囉。 今天的問題來自之前為了把電位測定的紀錄畫成圖而寫的腳本,是個裡面充滿巢狀的 for - loop 迴圈的恐怖玩意,它雖然會動但因為難以讀懂所以也不太可能再加功能進去。無奈我發下豪語說「啊,這個反正用 R 弄很快」的那個心血來潮只生出個別樣本的電位圖,至於總結的摘要圖當時就沒做了。 不過說到底,最重要的根本就是總結圖…… 動手改的過程當中對於執行速度之緩慢感到不耐煩,想起之前看過的 讀取速度比較 文,我決定歸咎給最開始的 read.table() 跑太慢,目前讀一個原始檔大概要花十秒。 開開心心的戴入 data.table 套件,我理想的流程是這樣的:把讀取的部分用 fread() 重寫一次,然後進到後面的迴圈海整理出可讀的版本再往下做。事實上…… Error in fread( "test.txt" , fill = TRUE , sep = "\t" , quote = "" , header = FALSE ) : Expecting 3 cols, but line 258088 contains text after processing all cols. Try again with fill= TRUE . Another reason could be that fread 's logic in distinguishing one or more fields having embedded sep=' ' and/or (unescaped) ' \n ' characters within unbalanced unescaped quotes has failed. If quote=' ' doesn' t...

Microsoft R Open 與 Mac OS Sierra不相容

搞了有點久所以記錄一下。Mac OS自Yosemite開始不在系統裡內建X11,所以有些R的Package會無法運作,這個問題可以透過安裝 XQartz 來解決。   通常這個問題的錯誤訊息會是: Warning message : In doTryCatch ( return ( expr ), name , parentenv , handler ) : unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so' : dlopen (/ Library / Frameworks / R.framework / Resources / modules // R_X11.so , 6 ): Symbol not found : _CGBitmapContextCreate Referenced from : / Library / Frameworks / R.framework / Resources / modules // R_X11.so Expected in : flat namespace in / Library / Frameworks / R.framework / Resources / modules // R_X11.so 而這次我碰到的問題是在安裝新版的XQuartz(當時為2.7.9)時仍然在透過biocLite()指令安裝BioConductor上的Package時仍跳出這個訊息,執行的環境是Mac OS Sierra/RStudio 0.99.903/Microsoft R Open v3.3.1。嘗試過移除 R Studio、Microsoft R Open、還有XQuartz重新安裝都無法解決這個問題。 因為問題發生在Microsoft R Open在Mac OS Yosemite之後仍然指向錯誤的路徑來找X11,所以即使安裝了XQuartz也會因為路徑錯誤讓R誤判你沒有安裝,安裝回CRAN版的R之後就可以正常使用了。