Skip to content

Latest commit

 

History

History
57 lines (36 loc) · 1.28 KB

Random_Plot.md

File metadata and controls

57 lines (36 loc) · 1.28 KB
title author date output
Random Plot
Jia Zhao
7/9/2020
html_document
keep_md
true

Function "random_plot"

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"))
}

Here are some examples of calling the function

  1. De fault (chr 1, position 1-1000)
random_plot()

  1. Chr 2, position 300-700
random_plot(chromosome = "chr 2", start = 300, end = 700)

  1. Whole chr 2
random_plot(chromosome = "chr 2" ,start = 1, end = Inf)