text: """In this question you will create a Manhattan (scatter) plot from a genome-wide association study (GWAS)
  generated by Wocjcik et al (ftp://ftp.ebi.ac.uk/pub/databases/gwas/summary_statistics/WojcikGL_31217584_GCST008025)
  
  The format in this question is the same as the previous questions.
  Good luck, and have fun!
  """
  import os
  
  import pandas as pd
  from plotnine import ggplot, geom_point, geom_hline, aes
  
  
  def read_data(data_path):
      """This function reads in the histogram data from the provided path
         and returns a pandas dataframe
      """
      gwas_df = pd.read_csv(data_path)
      return gwas_df
  
  
  def create_scatter_plot(gwas_df):
      """This function should create a scatter plot where the x-axis is the
      genomics position and the y axis is the negative log p_value for the SNP.
  
      Inputs
      ------
      gwas_df: pandas.DataFrame
          A dataframe containing information from a genome-wide association study
  
      Return
      ------
      plot: plotnine.ggplot
          The scatter plot representing the GWAS data
      """
      plot = ggplot(gwas_df, aes(x='Position_hg19', y='neg_log_p')) + geom_point()
  
      return plot
  
  
  def add_hline(plot):
      """This function adds a horizontal line at the y-value 6
  
      Inputs
      ------
      plot: plotnine.ggplot
          The scatter plot to add the line to
  
      Return
      ------
      plot: plotnine.ggplot
          The scatter plot with the line addded
      """
      plot = plot + geom_hline(yintercept=6, color='red')
      return plot
  
  
  def create_highlighted_scatter_plot(gwas_df):
      """This function creates a scatter plot with certain points highlighted.
      Doing so will require modifying gwas_df to reflect which points should be highlighted,
      then actually creating the scatter plot
  
      Inputs
      ------
      gwas_df: pandas.DataFrame
          A dataframe containing information from a genome-wide association study
  
      Return
      ------
      plot: plotnine.ggplot
          The scatter plot representing the GWAS data
      """
      snps_of_interest = ['rs12752601', 'rs117018967', 'rs188695075', 'rs6604965', 'rs542289952']
  
      gwas_df['snp_of_interest'] = gwas_df['rsid'].isin(snps_of_interest)
  
      return ggplot(gwas_df, aes(x='Position_hg19', y='neg_log_p', color='snp_of_interest'))\
             + geom_point()\
             + geom_hline(yintercept=6, color='red')
  
  
  def main():
      current_dir = os.path.dirname(os.path.abspath(__file__))
      data_path = os.path.join(current_dir, 'data/gwas.csv')
  
      # 1. Read in data
      gwas_df = read_data(data_path)
  
      # 2. Create a scatter plot
      plot = create_scatter_plot(gwas_df)
      print(plot)
  
  
      # 3. Add a horizontal line to the scatter plot
      print(add_hline(plot))
  
      # 4. Highlight SNPs of interest
      print(create_highlighted_scatter_plot(gwas_df))
  
  
  if __name__ == '__main__':
      main()
  