Skip to content
Open
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
24 changes: 13 additions & 11 deletions leafcutter/differential_splicing/leafcutter_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
meta = meta.rename(dict(zip([0, 1], ["sample", "group"])), axis = 1)

# Check if there are more than 2 columns in the metadata DataFrame
confounders = None
if len(meta.columns) > 2:
# Extract the confounders (columns 3 and onwards)
confounders = meta.iloc[:, 2:]
Expand All @@ -71,17 +72,18 @@
#remove samples with missing data (not in origial leafcutter as far as I can tell).
confounders = pd.DataFrame(confounders, index = meta['sample']).dropna()

all_samples = set(meta.loc[:,'sample'])
removed_samples = all_samples - set(confounders.index)
if len(removed_samples) != 0:
print('Samples removed due to missing values in covariates...')
print(','.join(list(removed_samples)))

# Encode the "group" column as numeric (0 and 1)
meta = meta[meta['sample'].isin(confounders.index)]

#if permute: numeric_x = np.random.permutation(numeric_x)
counts = counts[confounders.index]
# indented to here to fix confounders
all_samples = set(meta.loc[:,'sample'])
removed_samples = all_samples - set(confounders.index)
if len(removed_samples) != 0:
print('Samples removed due to missing values in covariates...')
print(','.join(list(removed_samples)))
# Encode the "group" column as numeric (0 and 1)
meta = meta[meta['sample'].isin(confounders.index)]
#if permute: numeric_x = np.random.permutation(numeric_x)
counts = counts[confounders.index]
else:
counts = counts[meta["sample"].tolist()]

scale_factor = 1.

Expand Down