BridgeRDataSetFromCuffnorm: Prepare your BRIC-seq dataset analyzed

Description Usage Arguments Details Value Note Author(s) References Examples

View source: R/Z1_calc_relative_expression.r

Description

Prepare your BRIC-seq dataset analyzed

Usage

1
BridgeRDataSetFromCuffnorm(CuffnormFiles, group, hour, cutoff = 0.1, InforColumn = 4, OutputFile = "BridgeR_1_Relative_expression_data.txt")

Arguments

CuffnormFiles

File path/name

group

Vector(string)

hour

Vector(number)

cutoff

Number(integer, float)

InforColumn

Integer

OutputFile

File path/name

Details

Prepare your BRIC-seq dataset analyzed

Value

text file

Note

2015-11-05

Author(s)

Naoto Imamachi

References

https://github.com/Naoto-Imamachi/BRIC-seq_data_analysis/tree/master/BridgeR

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.
#inputfile <- c("Control_genes_RefSeq_result_mRNA.fpkm_table",
#               "Knockdown_genes_RefSeq_result_mRNA.fpkm_table")
#outputfile <- "BridgeR_1_Relative_expression_dataset.txt"
#group <- c("Control","knockdown1","knockdown2")
#hour <- c(0,1,2,4,8,12)

#BridgeRDataSetFromCuffnorm(CuffnormFiles=inputfile, group=group, hour=hour, OutputFile=outputfile)

## The function is currently defined as
function (CuffnormFiles, group, hour, cutoff = 0.1, InforColumn = 4, 
    OutputFile = "BridgeR_1_Relative_expression_data.txt") 
{
    time_points <- length(hour)
    input_file_numbers <- length(CuffnormFiles)
    input_file <- NULL
    for (filename in CuffnormFiles) {
        if (is.null(input_file)) {
            input_file <- suppressWarnings(fread(filename, header = T))
        }
        else {
            input_file <- cbind(input_file, suppressWarnings(fread(filename, 
                header = T)))
        }
    }
    output_file <- OutputFile
    cat("", file = output_file)
    hour_label <- NULL
    for (a in 1:length(group)) {
        if (!is.null(hour_label)) {
            cat("\t", file = output_file, append = T)
        }
        hour_label <- NULL
        for (x in hour) {
            label <- x
            if (x < 10) {
                label <- paste("0", x, sep = "")
            }
            hour_label <- append(hour_label, paste("T", label, 
                "_", a, sep = ""))
        }
        infor_st <- 1 + (a - 1) * (time_points + InforColumn)
        infor_ed <- (InforColumn) * a + (a - 1) * time_points
        infor <- colnames(input_file)[infor_st:infor_ed]
        cat(infor, hour_label, sep = "\t", file = output_file, 
            append = T)
    }
    cat("\n", sep = "", file = output_file, append = T)
    gene_number <- length(input_file[[1]])
    sample_size <- length(group)
    for (x in 1:gene_number) {
        data <- as.vector(as.matrix(input_file[x, ]))
        for (a in 1:sample_size) {
            if (a != 1) {
                cat("\t", sep = "", file = output_file, append = T)
            }
            infor_st <- 1 + (a - 1) * (time_points + InforColumn)
            infor_ed <- (InforColumn) * a + (a - 1) * time_points
            gene_infor <- data[infor_st:infor_ed]
            cat(gene_infor, sep = "\t", file = output_file, append = T)
            cat("\t", sep = "", file = output_file, append = T)
            exp_st <- infor_ed + 1
            exp_ed <- infor_ed + time_points
            exp <- data[exp_st:exp_ed]
            exp <- as.numeric(exp)
            start_time <- exp[1]
            if (start_time <= cutoff) {
                cat(rep(0, time_points), sep = "\t", file = output_file, 
                  append = T)
                next
            }
            rel_exp <- NULL
            for (y in 1:time_points) {
                rel_exp <- append(rel_exp, exp[y]/start_time)
            }
            cat(rel_exp, sep = "\t", file = output_file, append = T)
        }
        cat("\n", sep = "", file = output_file, append = T)
    }
  }

Naoto-Imamachi/BridgeR documentation built on May 7, 2019, 6:05 p.m.