Skip to content

Commit

Permalink
bumping to 1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cmatKhan committed Dec 16, 2023
1 parent a9fcbc0 commit 47304a8
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 12 deletions.
25 changes: 24 additions & 1 deletion callingcardstools/Analysis/yeast/chipexo_promoter_sig.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,34 @@ def read_in_chipexo_data(
Returns:
pandas.DataFrame: A pandas DataFrame containing the chipexo
allevents data
Raises:
AttributeError: If the chipexo table does not contain at least the
following columns: `chr`, `start`, `end`, `YPD_log2Fold`,
`YPD_log2P`. Note that the `start` column is the original
`coord` column from the yeastepigenome.org data and `end` is
simply `coord` + 1. It is in this format to make it somewhat
easier to input to other processes that accept bed-like files.
"""
df = pd.read_csv(chipexo_data_path,
header=0,
index_col=False)

if not {'chr', 'start', 'end',
'YPD_log2Fold', 'YPD_log2P'}.issubset(df.columns):
raise AttributeError('The chipexo table must contain at least the '
'following columns: `chr`, `start`, `end`, '
'`YPD_log2Fold`, `YPD_log2P`. Note that the '
'`start` column is the original `coord` column '
'from the yeastepigenome.org data and `end` '
'is simply `coord` + 1. It is in this format '
'to make it somewhat easier to input to other '
'processes that accept bed-like files.')

df.rename(columns={'start': 'chipexo_start',
'end': 'chipexo_end'},
inplace=True)

return relabel_chr_column(df,
chrmap_df,
curr_chr_convention,
Expand Down Expand Up @@ -110,7 +133,7 @@ def chipexo_promoter_sig(chipexo_data_path: str,
return pd.merge(promoter_df, chipexo_df,
on='chr',
how='inner')\
.query('start <= coord <= end')\
.query('start <= chipexo_start <= end')\
.groupby(['chr', 'start', 'end', 'name', 'strand'])\
.agg(
n_sig_peaks=pd.NamedAgg(column='chr',
Expand Down
9 changes: 9 additions & 0 deletions docs/home/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## Version 1.4.1

### Changes

- chipexo_promoter_sig now checks the columns and expects the original
yeastepigenome.org allevents `coord` column to be split into `start`
and `end` where `end` is simply coord + 1. This is to be consistent
with the other bed-type files.

## Version 1.4.0

### Additions
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "callingCardsTools"
version = "1.4.0"
version = "1.4.1"
description = "A collection of objects and functions to work with calling cards sequencing tools"
authors = ["chase mateusiak <[email protected]>"]
license = "MIT"
Expand Down
42 changes: 32 additions & 10 deletions tests/Analysis/yeast/test_chipexo_promoter_sig.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import argparse
import os

import pandas as pd
from callingcardstools.Analysis.yeast.chipexo_promoter_sig \
import chipexo_promoter_sig
from callingcardstools.Analysis.yeast.chipexo_promoter_sig \
import main as chipexo_main

from callingcardstools.Analysis.yeast.chipexo_promoter_sig import \
chipexo_promoter_sig
from callingcardstools.Analysis.yeast.chipexo_promoter_sig import \
main as chipexo_main


def test_chipexo_promoter_sig(tmp_path):
# Create DataFrames
chipexo_df = pd.DataFrame({
'chr': ['chr1'],
'coord': [150],
'start': [150],
'end': [151],
'YPD_log2Fold': [2.0],
'YPD_log2P': [0.05]
})
Expand Down Expand Up @@ -61,22 +64,41 @@ def test_chipexo_data(tmpdir):

assert os.path.isdir(test_data_directory) is True

# chipexo_data_path = os.path.join(test_data_directory,
# 'chipexo_10352.csv.gz')
# chrmap_data_path = os.path.join(test_data_directory,
# 'chrmap.csv.gz')
# promoter_data_path = os.path.join(test_data_directory,
# 'yiming_promoters.bed.gz')

# output_path = os.path.join(tmpdir, 'chipexo_promoter_sig.csv')

chipexo_data_path = os.path.join(test_data_directory,
'chipexo_10352.csv.gz')
'test_user_count0/binding/pugh_none/49.csv.gz')
chrmap_data_path = os.path.join(test_data_directory,
'chrmap.csv.gz')
'test_user_count0/chrmap.csv')
promoter_data_path = os.path.join(test_data_directory,
'yiming_promoters.bed.gz')
'test_user_count0/promotersets/yiming/33.bed.gz')

output_path = os.path.join(tmpdir, 'chipexo_promoter_sig.csv')

# args = argparse.Namespace(
# chipexo_data_path=chipexo_data_path,
# chipexo_orig_chr_convention='chr',
# unified_chr_convention='ucsc',
# chrmap_data_path=chrmap_data_path,
# promoter_data_path=promoter_data_path,
# promoter_orig_chr_convention='id',
# output_file=output_path,
# compress=False)

args = argparse.Namespace(
chipexo_data_path=chipexo_data_path,
chipexo_orig_chr_convention='chr',
chipexo_orig_chr_convention='ucsc',
unified_chr_convention='ucsc',
chrmap_data_path=chrmap_data_path,
promoter_data_path=promoter_data_path,
promoter_orig_chr_convention='id',
promoter_orig_chr_convention='ucsc',
output_file=output_path,
compress=False)

Expand Down

0 comments on commit 47304a8

Please sign in to comment.