title | author | date | output | ||||
---|---|---|---|---|---|---|---|
Random Plot |
Jia Zhao |
7/9/2020 |
|
This function takes three four arguments: data, chromosome, start and end. The results will be a line plot with x axis as position of a chromosome and y axis as corresponded data value.
random_plot <- function(data= final_table, chromosome="chr 1", start=1, end=1000){
# data is a data frame; chromosome is a string/character and a column of data, start and end are integers
sub_data <- data[data$chromosome == chromosome,]
position <- as.numeric(sub_data$position)
sub_data <- sub_data[position >= start & position <= end,]
x <- chromosome
with(sub_data, plot(position, data_value, pch = 19, main = x, ylab= "data value", type = "l"))
}
- De fault (chr 1, position 1-1000)
random_plot()
- Chr 2, position 300-700
random_plot(chromosome = "chr 2", start = 300, end = 700)
- Whole chr 2
random_plot(chromosome = "chr 2" ,start = 1, end = Inf)