Skip to content

CLI

Command-Line Interface for project

Main command - c19_dfm

Help - c19_dfm --help

Process data and generate parquet DataFrame - c19_dfm process ./outfile.xlsx

create_input_h5ad(h5ad_out, data_path, factor_path, metadata_path=typer.Option(help='Path to metadata (needed if batching data)'))

Convert data, factor, and metadata CSVs to H5AD and save output

Example: c19dfm create_input_h5ad data.h5ad ./data.csv ./factors.csv --metadata ./metadata.csv

Source code in dfmdash/cli.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@app.command("create_input_data")
def create_input_h5ad(
    h5ad_out: Path,
    data_path: Path,
    factor_path: Path,
    metadata_path: Optional[Path] = typer.Option(help="Path to metadata (needed if batching data)"),
):
    """
    Convert data, factor, and metadata CSVs to H5AD and save output

    Example: c19dfm create_input_h5ad data.h5ad ./data.csv ./factors.csv --metadata ./metadata.csv
    """
    print(f"Creating H5AD at {h5ad_out}")
    data = DataLoader().load(data_path, factor_path, metadata_path)
    data.write_h5ad(h5ad_out)

create_project_data(outdir)

Create H5AD object of covid19 response and economic data

Source code in dfmdash/cli.py
62
63
64
65
66
67
68
69
@app.command("create_covid_project_data")
def create_project_data(outdir: Path):
    """
    Create H5AD object of covid19 response and economic data
    """
    ad = get_project_h5ad()
    ad.write(outdir / "data.h5ad")
    print(f"Project data successfully created at {outdir}/data.h5ad !")

launch(port=8501)

Launch Dynamic Factor Dashboard

Source code in dfmdash/cli.py
72
73
74
75
76
77
78
79
@app.command("launch")
def launch(port: str = 8501):
    """
    Launch Dynamic Factor Dashboard
    """
    current_dir = Path(__file__).resolve().parent
    dashboard_path = current_dir / "streamlit" / "Dynamic_Factor_Model.py"
    subprocess.run(["streamlit", "run", dashboard_path, "--server.port", port])