Developer center

Add a new analysis using a base function

It’s easy to add new analysis in DrBioRight! Simply type in :add_pipelines. All available base functions listed in “Top used analyses” will pop out.

Base Function Select
Survival GO
Correlation GO
Differential GO
Lollipop GO

Click the GO button and follow each step to select your samples and molecular data by setting sample filters and molecular data filters.

The selected data will be shown to you in a data summary table. Each line presents a sample, and each column is a feature.

sample_id age gender tissue mrnaseq.TP53
TCGA-AB-01 78 female liver 13.9
TCGA-AB-02 87 male liver 14.6
TCGA-AB-03 35 male liver 4.5
TCGA-AB-04 41 female liver 24.2

For example, you want to perform a Correlation analysis between sample age and TP53 gene expression. Our interface will present you with the configuration file of the Correlation-based function and let you select any numeric columns for your analysis. In this example, you will select age and mrnaseq.TP53 as the two input variables.

var description column
variable1 first variable of correlation analysis, must be numeric age
variable2 second variable of correlation analysis, must be numeric mrnaseq.TP53

After defining the required variables, click submit, and you will see the final results and confirm if it is the analysis you would like to perform. If yes, it will be stored in our database, and you and other general users will be able to use it through human language chatting.

Submit a new base function

To incorporate a new base function, two components are needed.

  • base function source code (python, R, Perl)
  • base function parameter mapping file (JSON)

Use dr.survival.uni as an example

JSON mapping file:

{
        "module" : "dr.survival.uni",
        "keywords" : [
                "survival",
                "tissue",
                "gene expression"
        ],
        "params" : [
                {
                        "var_name" : "time",
                        "desc" : "survival time",
                        "var_field" : "__req_var",
                        "var_type" : "num"
                },
                {
                        "var_name" : "status",
                        "desc" : "survival status",
                        "var_field" : "__req_var",
                        "var_type" : "bool"
                },
                {
                        "var_name" : "var",
                        "desc" : "variable",
                        "var_field" : "__req_var",
                        "var_type" : [
                                "num",
                                "string"
                        ]
                }
        ]
}
# base function

drsurvival <- function(job_dir, infile, analytics_mapper) {
    # job_dir: working directory
    # infile: query data from database
    # analytics_mapper: mapping file

    print("survival analysis")
    fileSep <- .Platform$file.sep
    query_data = read.csv(paste(job_dir, infile, sep=fileSep), sep=",", header=T,
                  check.names=F, stringsAsFactors=F)
    mapper =  fromJSON(paste(job_dir, analytics_mapper, sep=fileSep), flatten=TRUE)

    data = query_data[, mapper$var, drop=F]
    time = query_data[, mapper$time]
    status = query_data[, mapper$status]
    status <- ifelse(status==1, 1, 0)

    Result <- matrix(NA, dim(data)[2], 7, byrow=TRUE)
    rownames(Result) <- colnames(data)
    colnames(Result) <- c("N", "coef", "Exp(coef)", "Coxp", "CoxpFDR")

    foreach( i1 = c(1:ncol(data)) ) %dopar% {
        test.data1 <- list(time     = Time.survival,
                           status   = cen.status,
                           group    = dataused)
        ## Cox regression
        tempresult <- try( model1 <- coxph(Surv(time, status) ~ group,
                                               data=test.data1, na.action = na.exclude), silent=TRUE)
        Result[i1, c("coef", "Exp(coef)", "Coxp")] <-
                    summary(model1)$coefficients[1,c("coef", "exp(coef)", "Pr(>|z|)" )]
    }
}

Request a new module

You can also request a new base function by clicking request a module at the top right corner. By filling out the Module Name and Description fields, this request will be published at our developer forum and solved by DrBioRight administrators or active developers. A message will be sent to you once your request has been implemented. Bravo!