Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update summary statistics #63

Merged
merged 4 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.5, 3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping Python 3.5 support.


steps:
- uses: actions/checkout@v1
Expand Down
18 changes: 13 additions & 5 deletions dbbuild/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def construct_variant_map(data):
varlist.append(variant)
markerlist.append(marker)
outdata = pandas.DataFrame({'Variant': varlist, 'Marker': markerlist})
return outdata.sort_values('Variant')
return outdata.sort_values(['Variant', 'Marker'])


def populate_idmap(data):
Expand Down Expand Up @@ -109,17 +109,17 @@ def sort_and_clean(data):
data.drop(columns=['Xref', 'VarRef', 'ChromSort', 'TempPos'], inplace=True)
nr = data.drop_duplicates(subset=('Name', 'Chrom', 'Offsets'))
assert(len(nr.Name) == len(nr.Name.unique())) # If markers are defined in more than one place, make sure the definitions are identical.
return data[['Name', 'PermID', 'Reference', 'Chrom', 'Offsets', 'AvgAe', 'In', 'Source']]
return data[['Name', 'PermID', 'Reference', 'Chrom', 'Offsets', 'Ae', 'In', 'Fst', 'Source']]


def add_avgae(data, aefile):
aes = pandas.read_csv(aefile, sep='\t')
avgae = {'Marker': list(), 'AvgAe': list()}
avgae = {'Marker': list(), 'Ae': list()}
for marker, mdata in aes.groupby('Marker'):
assert len(mdata) == 26
meanae = mdata.Ae.mean()
avgae['Marker'].append(marker)
avgae['AvgAe'].append(meanae)
avgae['Ae'].append(meanae)
return data.join(pandas.DataFrame(avgae).set_index('Marker'), on='Name')


Expand All @@ -128,6 +128,11 @@ def add_informativeness(data, informfile):
return data.join(info.set_index('Marker'), on='Name')


def add_fst(data, fstfile):
info = pandas.read_csv(fstfile, sep='\t')
return data.join(info.set_index('Marker'), on='Name')


SOURCES = [os.path.basename(file) for file in glob('sources/*') if os.path.isdir(file)]


Expand Down Expand Up @@ -189,6 +194,7 @@ rule markers:
config['refr'],
'sources/1kgp/marker-aes.tsv',
'sources/1kgp/marker-informativeness.tsv',
'sources/1kgp/marker-fst.tsv',
expand('sources/{source}/marker.tsv', source=SOURCES),
expand('sources/{source}/source.txt', source=SOURCES),
output:
Expand All @@ -198,7 +204,8 @@ rule markers:
run:
aefile = input[1]
informfile = input[2]
input = input[3:]
fstfile = input[3]
input = input[4:]
numsources = int(len(input) / 2)
markerfiles = input[:numsources]
sourcefiles = input[numsources:]
Expand All @@ -213,6 +220,7 @@ rule markers:

data = add_avgae(data, aefile)
data = add_informativeness(data, informfile)
data = add_fst(data, fstfile)
data = sort_and_clean(data)
data.to_csv(output.table, sep='\t', index=False, float_format='%.4f')

Expand Down
836 changes: 418 additions & 418 deletions dbbuild/marker.tsv

Large diffs are not rendered by default.

Loading