-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix multiple errors, some code was only commented
- Loading branch information
Showing
9 changed files
with
130 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,40 @@ | ||
import tiledb | ||
import numpy as np | ||
def create_tiledb_schema(uri,cfg): | ||
|
||
|
||
def create_tiledb_schema(uri, cfg): | ||
pos_domain = (1, 3000000000) | ||
dom = tiledb.Domain( | ||
tiledb.Dim(name="CHR", dtype=np.bytes_, var=False), | ||
tiledb.Dim(name="POS", domain = pos_domain, dtype=np.uint32, var=False), | ||
tiledb.Dim(name="TRAITID", dtype=np.bytes_, var=True)) | ||
tiledb.Dim(name="POS", domain=pos_domain, dtype=np.uint32, var=False), | ||
tiledb.Dim(name="TRAITID", dtype=np.bytes_, var=True), | ||
) | ||
schema = tiledb.ArraySchema( | ||
domain=dom, | ||
sparse=True, | ||
allows_duplicates=True, | ||
attrs=[ | ||
tiledb.Attr(name="BETA", dtype=np.float64, var=False,filters=tiledb.FilterList([tiledb.ZstdFilter(level=5)]) ), | ||
tiledb.Attr(name="SE", dtype=np.float64, var=False,filters=tiledb.FilterList([tiledb.ZstdFilter(level=5)])), | ||
tiledb.Attr(name="EAF", dtype=np.float64, var=False,filters=tiledb.FilterList([tiledb.ZstdFilter(level=5)])), | ||
tiledb.Attr(name="MLOG10P", dtype=np.float64, var=False,filters=tiledb.FilterList([tiledb.ZstdFilter(level=5)])), | ||
tiledb.Attr(name="ALLELE0", dtype=np.bytes_, var=True,filters=tiledb.FilterList([tiledb.ZstdFilter(level=5)])), | ||
tiledb.Attr(name="ALLELE1", dtype=np.bytes_, var=True,filters=tiledb.FilterList([tiledb.ZstdFilter(level=5)])), | ||
tiledb.Attr(name="SNPID", dtype=np.bytes_, var=True,filters=tiledb.FilterList([tiledb.ZstdFilter(level=5)])) | ||
] | ||
tiledb.Attr( | ||
name="BETA", dtype=np.float64, var=False, filters=tiledb.FilterList([tiledb.ZstdFilter(level=5)]) | ||
), | ||
tiledb.Attr( | ||
name="SE", dtype=np.float64, var=False, filters=tiledb.FilterList([tiledb.ZstdFilter(level=5)]) | ||
), | ||
tiledb.Attr( | ||
name="EAF", dtype=np.float64, var=False, filters=tiledb.FilterList([tiledb.ZstdFilter(level=5)]) | ||
), | ||
tiledb.Attr( | ||
name="MLOG10P", dtype=np.float64, var=False, filters=tiledb.FilterList([tiledb.ZstdFilter(level=5)]) | ||
), | ||
tiledb.Attr( | ||
name="ALLELE0", dtype=np.bytes_, var=True, filters=tiledb.FilterList([tiledb.ZstdFilter(level=5)]) | ||
), | ||
tiledb.Attr( | ||
name="ALLELE1", dtype=np.bytes_, var=True, filters=tiledb.FilterList([tiledb.ZstdFilter(level=5)]) | ||
), | ||
tiledb.Attr( | ||
name="SNPID", dtype=np.bytes_, var=True, filters=tiledb.FilterList([tiledb.ZstdFilter(level=5)]) | ||
), | ||
], | ||
) | ||
tiledb.Array.create(uri, schema, ctx=cfg) | ||
tiledb.Array.create(uri, schema, ctx=cfg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
from utils import compute_sha256 | ||
import pandas as pd | ||
import tiledb | ||
|
||
from gwasstudio.utils import compute_sha256 | ||
|
||
|
||
def process_and_ingest(file_path, uri, checksum_dict, dict_type, renaming_columns, attributes_columns, cfg): | ||
# Read file with Dask | ||
df = pd.read_csv( | ||
file_path, | ||
compression="gzip", | ||
sep="\t", | ||
usecols = attributes_columns | ||
#usecols=["Chrom", "Pos", "Name", "effectAllele", "Beta", "SE", "ImpMAF"] | ||
usecols=attributes_columns, | ||
# usecols=["Chrom", "Pos", "Name", "effectAllele", "Beta", "SE", "ImpMAF"] | ||
) | ||
sha256 = compute_sha256(file_path) | ||
# Rename columns and modify 'chrom' field | ||
df = df.rename(columns = renaming_columns) | ||
df["chrom"] = df["chrom"].str.replace('chr', '') | ||
df["chrom"] = df["chrom"].str.replace('X', '23') | ||
df["chrom"] = df["chrom"].str.replace('Y', '24') | ||
df = df.rename(columns=renaming_columns) | ||
df["chrom"] = df["chrom"].str.replace("chr", "") | ||
df["chrom"] = df["chrom"].str.replace("X", "23") | ||
df["chrom"] = df["chrom"].str.replace("Y", "24") | ||
# Add trait_id based on the checksum_dict | ||
file_name = file_path.split('/')[-1] | ||
# file_name = file_path.split("/")[-1] | ||
df["trait_id"] = sha256 | ||
|
||
# Store the processed data in TileDB | ||
tiledb.from_pandas( | ||
uri=uri, | ||
dataframe=df, | ||
index_dims=["chrom", "pos", "trait_id"], | ||
mode="append", | ||
column_types=dict_type, | ||
ctx = ctx | ||
) | ||
uri=uri, dataframe=df, index_dims=["chrom", "pos", "trait_id"], mode="append", column_types=dict_type, ctx=cfg | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.