Skip to content

Commit

Permalink
Merge pull request #47 from ygidtu/dev
Browse files Browse the repository at this point in the history
update web to v0.0.5, fix several bugs, update docs
  • Loading branch information
ygidtu authored Oct 31, 2022
2 parents 94464be + abf01aa commit 51700c2
Show file tree
Hide file tree
Showing 20 changed files with 584 additions and 837 deletions.
2 changes: 1 addition & 1 deletion WebDockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ RUN cd $ROOT_DIR && \
pip install -i $PYPI fastapi uvicorn pydantic jinja2 && \
pip install -r requirements.txt && ls -l $ROOT_DIR

ENTRYPOINT ["python", "/opt/sashimi/server.py"]
ENTRYPOINT ["python", "/opt/sashimi/server.py", "--host", "0.0.0.0"]
Binary file modified docs/imgs/web/add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/imgs/web/draw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/imgs/web/main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/imgs/web/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ docker run --rm -v $PWD:$PWD --user $(id -u):$(id -g) ygidtu/sashimi --help

- `-v`, `--volumn`: mount the working directory to docker container
- `--user`: prevent docker read and write file using root privileges
- the rest usage please check [Command line usage](./command_line_usage.md)
- the rest usage please check [Command line usage](./command.md)

**Note: ** detailed command line usage please check [Command line Usage](./command_line_usage.md)
**Note: ** detailed command line usage please check [Command line Usage](./command.md)


## Build Web interface from source
Expand Down Expand Up @@ -101,6 +101,8 @@ python server.py --help
```bash
docker pull ygidtu/sashimiweb

export PORT=8080 # the port your are trying to exposed
docker run --rm -v $PWD:$PWD --user $(id -u):$(id -g) -p $PORT:5000 ygidtu/sashimiweb
docker run --name sashimiweb \
--rm -v $PWD:$PWD \
-p 5000:5000 \
ygidtu/sashimiweb
```
4 changes: 3 additions & 1 deletion docs/web.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

#### 1. requirements

Except the sashimi, we still required `fastapi`, `uvicorn` and `pydantic`
Except the sashimi, we required `fastapi`, `uvicorn` and `pydantic` and `nodejs`

The deployment please check the [Build Web interface from source](./installation.md)

## Usage

Expand Down
8 changes: 5 additions & 3 deletions sashimi/base/ReadDepth.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ def __init__(self,

@property
def wiggle(self) -> np.array:
if self.plus is None or np.sum(self.plus) == 0:
if (self.plus is None or np.sum(self.plus) == 0) and self.minus is not None:
return self.minus
elif self.minus is None or np.sum(self.minus) == 0:
return self.plus

if self.plus is not None and self.minus is not None:
return self.plus + self.minus

return self.plus

def __add__(self, other):
Expand Down
3 changes: 2 additions & 1 deletion sashimi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ def main(**kwargs):
n_y_ticks=kwargs["n_y_ticks"],
show_y_label=not kwargs["hide_y_label"],
show_site_plot=kwargs["show_site"],
strand_choice=kwargs["site_strand"])
strand_choice=kwargs["site_strand"],
density_by_strand=kwargs["density_by_strand"],)
elif key == "heatmap":
for f in process_file_list(kwargs[key], key):
if barcodes and f.label in barcodes.keys() and f.category in ["bam", "atac"]:
Expand Down
10 changes: 6 additions & 4 deletions sashimi/file/Bam.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def create(cls,
barcodes: Optional[Set[str]] = None,
barcode_tag: str = "CB",
umi_tag: str = "UB",
library: str = "fru"
library: str = "fru",
density_by_strand: bool = False
):
u"""
Expand Down Expand Up @@ -88,7 +89,8 @@ def create(cls,
barcodes=barcode,
barcode_tag=barcode_tag,
umi_tag=umi_tag,
library=library
library=library,
density_by_strand=density_by_strand
)

def __hash__(self):
Expand Down Expand Up @@ -282,11 +284,11 @@ def load(self,
spanned_junctions_plus, spanned_junctions_minus = {}, {}

self.data = ReadDepth(
plus,
plus if self.density_by_strand else plus + minus,
junctions_dict=filtered_junctions,
site_plus=site_plus,
site_minus=site_minus,
minus=minus,
minus=minus if self.density_by_strand else None,
junction_dict_plus=spanned_junctions_plus,
junction_dict_minus=spanned_junctions_minus,
strand_aware=False if self.library == "fru" else True)
Expand Down
7 changes: 5 additions & 2 deletions sashimi/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def __init_input_file__(path: str,
deletion_ignore: Optional[int] = True,
del_ratio_ignore: float = .5,
exon_focus: Optional[str] = None,
density_by_strand: bool = False,

# for hic plot
trans: Optional[str] = None,
Expand All @@ -389,6 +390,7 @@ def __init_input_file__(path: str,
barcode_tag=barcode_tag,
umi_tag=umi_tag,
library=library,
density_by_strand=density_by_strand
)
elif category == "atac":
obj = ATAC.create(
Expand Down Expand Up @@ -500,7 +502,8 @@ def add_density(self,
barcode_tag=barcode_tag,
umi_tag=umi_tag,
library=library,
size_factor=size_factor
size_factor=size_factor,
density_by_strand=density_by_strand
)

type_ = "density"
Expand All @@ -515,7 +518,7 @@ def add_density(self,
for p in self.plots:
if p.category == info.category:
for obj_ in p.obj:
if obj_.label == label and label:
if obj_.label == label and label and not barcode:
param = self.params.pop(p)
p.obj.append(obj)
new_obj = False
Expand Down
4 changes: 1 addition & 3 deletions sashimi/plot_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,6 @@ def plot_density(
y_label: str = "",
theme: str = "ticks_blank",
max_used_y_val: Optional[float] = None,
density_by_plot: bool = False,
raster: bool = False,
**kwargs
):
Expand All @@ -628,8 +627,7 @@ def plot_density(
:param show_y_label: whether to show y-axis label
:param y_label: the text of y-axis title
:param theme: the theme name
:param max_used_y_val: used to set same max y axis
:param density_by_plot: whether to draw density plot in strand-specific manner.
:param max_used_y_val: used to set same max y-axis
:param raster:
:param kwargs:
:return:
Expand Down
26 changes: 25 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
from fastapi.templating import Jinja2Templates
from pydantic import BaseModel

from sashimi.cli import load_barcodes
from sashimi.plot import *


__DIR__ = os.path.abspath(os.path.dirname(__file__))
__UI__ = os.path.join(__DIR__, "ui")

Expand Down Expand Up @@ -133,6 +135,12 @@ async def params(target: Optional[str] = None):
if param.name == "return_image":
continue

if param.name == "sc_height_ratio":
continue

if param.name == "barcode":
continue

res.append(Param(
key=param.name,
annotation=clean(str(param.annotation)),
Expand Down Expand Up @@ -174,7 +182,23 @@ async def plot(pid: str, param: PlotParam, func: str):
elif func == "set_region":
p.set_region(**kwargs)
else:
getattr(p, func)(param.path, **kwargs)
if "barcode_groups" in kwargs.keys() and kwargs["barcode_groups"]:
barcodes, sc_colors = load_barcodes(kwargs["barcode_groups"])
kwargs["barcode_groups"] = barcodes
for group in barcodes[kwargs["label"]].keys():
kwargs["barcode"] = group
kwargs["color"] = sc_colors[group]
kwargs["y_label"] = group
getattr(p, func)(param.path, **kwargs)
else:
for tag in ["vmin", "vmax"]:
if tag in kwargs.keys():
try:
kwargs[tag] = float(kwargs[tag])
except Exception:
kwargs[tag] = None

getattr(p, func)(param.path, **kwargs)
except (AssertionError, OSError, TypeError) as err:
exc_type, exc_value, exc_traceback = sys.exc_info()
raise HTTPException(status_code=404,
Expand Down
3 changes: 2 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sashimi.py",
"private": true,
"version": "0.0.0",
"version": "0.0.5",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -13,6 +13,7 @@
"element-plus": "^2.2.12",
"file-saver": "^2.0.5",
"vue": "^3.2.37",
"vue-axios": "^3.5.1",
"vue-cookies": "^1.8.1",
"vue-router": "4"
},
Expand Down
Loading

0 comments on commit 51700c2

Please sign in to comment.