Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zouter committed May 22, 2024
1 parent c0458c7 commit 392bd43
Show file tree
Hide file tree
Showing 14 changed files with 175 additions and 142 deletions.
Binary file modified src/chromatinhd/data/examples/pbmc10ktiny/fragments.tsv.gz
Binary file not shown.
Binary file modified src/chromatinhd/data/examples/pbmc10ktiny/fragments.tsv.gz.tbi
Binary file not shown.
Binary file modified src/chromatinhd/data/examples/pbmc10ktiny/transcriptome.h5ad
Binary file not shown.
6 changes: 5 additions & 1 deletion src/chromatinhd/data/peakcounts/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ def extract_peaks(peaks_bed, promoter, peakcaller):
peaks = peaks.rename(columns={"name": "cluster"})
peaks["cluster"] = peaks["cluster"].astype(int)

if peakcaller == "rolling_500":
peaks["start"] = peaks["start"] + 250
peaks["end"] = peaks["end"] + 250

if len(peaks) > 0:
peaks["peak"] = peaks["chrom"] + ":" + peaks["start"].astype(str) + "-" + peaks["end"].astype(str)
peaks = center_peaks(peaks, promoter)
Expand Down Expand Up @@ -337,7 +341,7 @@ def _plot_peaks(ax, plotdata, y, lw=0.5, fc="#555"):
peak["end"] - peak["start"],
1,
fc=fc,
lw=0,
lw=0.5,
)
ax.add_patch(rect)
# ax.plot([peak["start"]] * 2, [y, y + 1], color="grey", lw=lw)
Expand Down
2 changes: 1 addition & 1 deletion src/chromatinhd/grid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .grid import Grid, Figure, Panel, Wrap, Ax
from .broken import Broken, BrokenGrid
from .broken import Broken, BrokenGrid, Breaking
8 changes: 6 additions & 2 deletions src/chromatinhd/grid/broken.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@dataclasses.dataclass
class Breaking:
regions: pd.DataFrame
gap: int
gap: int = 0.1
resolution: int = 5000

@property
Expand All @@ -29,7 +29,11 @@ def __init__(self, breaking, height=0.5, margin_height=0.0, *args, **kwargs):
regions["ix"] = np.arange(len(regions))

for i, (region, region_info) in enumerate(regions.iterrows()):
subpanel_width = region_info["width"] / breaking.resolution
if "resolution" in region_info.index:
resolution = region_info["resolution"]
else:
resolution = breaking.resolution
subpanel_width = region_info["width"] / resolution
panel, ax = self.add_right(
Panel((subpanel_width, height + 1e-4)),
)
Expand Down
10 changes: 8 additions & 2 deletions src/chromatinhd/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,21 @@ def height(self):
h += AXIS_HEIGHT
return h

@height.setter
def height(self, value):
self.dim = (self.dim[0], value)

@property
def width(self):
w = self.dim[0]
if self.ax.axison:
w += AXIS_WIDTH
return w

@width.setter
def width(self, value):
self.dim = (value, self.dim[1])

def align(self):
pass

Expand Down Expand Up @@ -218,9 +226,7 @@ def __getitem__(self, key):

def get_bottom_left_corner(self):
nrow = (len(self.elements) - 1) // self.ncol
print(len(self.elements))
ix = (nrow) * self.ncol
print(nrow, self.ncol, ix)
return self.elements[ix]
# return self.elements[self.ncol * ((len(self.elements) % self.ncol) - 1)]

Expand Down
2 changes: 1 addition & 1 deletion src/chromatinhd/models/pred/interpret/censorers.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __call__(self, data):


class MultiWindowCensorer:
def __init__(self, window, window_sizes=(50, 100, 200, 500), relative_stride=0.5):
def __init__(self, window, window_sizes=(25, 50, 100, 200, 500), relative_stride=0.5):
design = [{"window": "control"}]
for window_size in window_sizes:
cuts = np.arange(*window, step=int(window_size * relative_stride))
Expand Down
4 changes: 0 additions & 4 deletions src/chromatinhd/models/pred/interpret/regionmultiwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ def create(

regions = fragments.regions.var.index

print(len(folds))

coords_pointed = {
regions.name: regions,
"fold": pd.Index(range(len(folds)), name="fold"),
Expand Down Expand Up @@ -305,8 +303,6 @@ def _interpolate(self, region):
effects = np.stack(effects)
losts = np.stack(losts)

print(deltacors.min())

scores_statistical = []
for i in range(deltacors.shape[1]):
if deltacors.shape[0] > 1:
Expand Down
1 change: 1 addition & 0 deletions src/chromatinhd/models/pred/model/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import additive
from . import nonadditive
from . import better as multiscale
Loading

0 comments on commit 392bd43

Please sign in to comment.