R sharp
1.0.0
R#语言是一种在.NET环境下实现的类似R的语言,用于生物信息学数据分析
[警告] 该项目正在开发中,不建议用于生产用途。
还需要最新的 sciBASIC.NET Framework 运行时
R#
语言的语法最初源自R
语言,但具有更现代化的编程风格。 R#
语言的解释器和 .NET 编译器最初是用 VisualBasic 语言编写的,具有对 .NET 运行时的本机支持。
R#
语言不是为一般的数据分析目的而设计的,而是专门为我在公司的工作而设计的,实现了基于GCModeller平台的生物信息学数据分析系统,用于用R和VisualBasic语言构建生物信息学数据科学堆栈。
R#
R# 语言核心运行时和脚本引擎Library
R#脚本系统中的基础库Rscript
R# 脚本主机R-terminal
R# shell 程序Rsharp_kit
R-sharp 工具包njl
Julia 语言喜欢的脚本引擎npy
Python 语言喜欢的脚本引擎RData
R语言数据*.rda/*.rds
文件读取器 # declare a variable
let word as string = [ ' world ' , ' R# user ' , ' GCModeller user ' ];
# declare a function
let echo as function ( words ) {
print( `Hello ${ words }!` );
}
# or declare a lambda function
let echo.lambda = words - > print( `Hello ${ words }!` );
# and then invoke function via pipeline operator
word : > echo ;
# [3] "Hello world!" "Hello R# user!" "Hello GCModeller user!"
word : > echo.lambda ;
# [3] "Hello world!" "Hello R# user!" "Hello GCModeller user!"
在 VisualBasic.NET 编程中使用:
Dim R As New RInterpreter()
' Run script by invoke method
Call R.Evaluate( "
# test script
let word as string = [ 'world', 'R# user', 'GCModeller user'];
let echo as function (words) {
print( ` Hello $ { words }! ` ) ;
}
word :> echo ;
" )
' or assign variable
Call R.Add( "word" , { "world" , "R# user" , "GCModeller user" })
' then declare R function throught script
Call R.Add( "echo" ,
Function (words As String ()) As String ()
Return Internal.print(words)
End Function )
' at last, invoke R function throught Invoke method
Call R.Invoke( "echo" , R!word)
# read scatter point data from a given table file
# and then assign to tuple variables
[ x , y , cluster ] = read.csv( " ./scatter.csv " , row.names = NULL );
# umap scatter with class colors
bitmap( file = " ./scatter.png " ) {
plot( x , y ,
padding = " padding:200px 400px 200px 250px; " ,
class = cluster ,
title = " UMAP 2D Scatter " ,
x.lab = " dimension 1 " ,
y.lab = " dimension 2 " ,
legend.block = 13 ,
colorSet = " paper " ,
grid.fill = " transparent " ,
size = [ 2600 , 1600 ]
);
};
R#
的 ggplotAR语言ggplot2包喜欢R#语言编程的图形库语法。
R#
语言是另一种专为.NET运行时设计的科学计算语言, R#
是从R语言演变而来的。 R语言中有一个著名的图形库叫做ggplot2
,所以保持不变,有一个叫做ggplot
的图形库是为R#
语言开发的。
ggplot( myeloma , aes( x = " molecular_group " , y = " DEPDC1 " ))
+ geom_boxplot( width = 0.65 )
+ geom_jitter( width = 0.3 )
# Add horizontal line at base mean
+ geom_hline( yintercept = mean( myeloma $ DEPDC1 ), linetype = " dash " , line.width = 6 , color = " red " )
+ ggtitle( " DEPDC1 ~ molecular_group " )
+ ylab( " DEPDC1 " )
+ xlab( " " )
+ scale_y_continuous( labels = " F0 " )
# Add global annova p-value
+ stat_compare_means( method = " anova " , label.y = 1600 )
# Pairwise comparison against all
+ stat_compare_means( label = " p.signif " , method = " t.test " , ref.group = " .all. " , hide.ns = TRUE )
+ theme(
axis.text.x = element_text( angle = 45 ),
plot.title = element_text( family = " Cambria Math " , size = 16 )
)
;
R#
系统不仅支持R#语言,还包括运行在R#
运行时上的Python语言脚本和Julia语言脚本引擎。
引用R#
语言中的 python 脚本或 julia 脚本,就像导入其他R#
脚本一样:
# imports an external R# script
imports " ./script.R " ;
# imports an external python script in R#
imports " ./script.py " ;
# imports an external julia script in R#
imports " ./script.jl " ;
您还可以在 python 或 julia 脚本中导入 R 脚本:
# example of import R#/julia script in python
# imports an external R# script in python
import "./script.R"
# imports an external julia script in python
import "./script.jl"
在 julia 脚本中导入 python 和R#
脚本也很简单:
# example of imports R#/python script in julia
# imports an external R# script in julia
include ( " ./script.R " )
# imports an external python script in julia
include ( " ./script.py " )
require ( "GCModeller" ) ;
// load the fastq module from rna-seq package
// inside the GCModeller
import { FastQ } from "rnaseq" ;
// do short reads assembling via SCS algorithm
var assem = FastQ . assemble ( [
"AACAAATGAGACGCTGTGCAATTGCTGA" ,
"AACAAATGAGACGCTGTGCAATTGCAAA" ,
"CAAATGAGACGCTGTGCAATTGCTGAGT" ,
"GCAAATGATACGCTGTGCAATTGCTAGA" ,
"ATGAGACGCTGTGCAATTGCTGAGTACC" ,
"CTGTGCAATTGCTGAGAACAAATGAGAC" ,
"CTGTGCAATTGCTAGAAACAAATGAGAC"
] )
// view the short reads assemble result
console . table ( assem )
// Loading required package: GCModeller
// Loading required package: igraph
// Attaching package: 'igraph'
//
// The following object is masked from 'package:igraph':
//
// eval, class
//
//
//
// GCModeller: genomics CAD(Computer Assistant Design) Modeller System
// author by: [email protected]
//
// (c) 2023 | SMRUCC genomics - GuiLin, China
//
// AssembleResult
// --------------------------------------------------------------------------------------------------------------
// <mode> <string>
// [1, ] "CTGTGCAATTGCTGAGAACAAATGAGACGCTGTGCAATTGCAAATGATACGCTGTGCAATTGCTAGAAACAAATGAGACGCTGTGCAATTGCTGAGTACC"
// [2, ] "...................................................................AACAAATGAGACGCTGTGCAATTGCTGA....."
// [3, ] "................AACAAATGAGACGCTGTGCAATTGCAAA........................................................"
// [4, ] ".....................................................................CAAATGAGACGCTGTGCAATTGCTGAGT..."
// [5, ] ".......................................GCAAATGATACGCTGTGCAATTGCTAGA................................."
// [6, ] "........................................................................ATGAGACGCTGTGCAATTGCTGAGTACC"
// [7, ] "CTGTGCAATTGCTGAGAACAAATGAGAC........................................................................"
// [8, ] "...................................................CTGTGCAATTGCTAGAAACAAATGAGAC....................."
R#
包资源为 R# 编程环境开发的包: