Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnfarrell committed Feb 2, 2019
1 parent 4c35f9c commit 112b9f6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
inst_requires = ['numpy>=1.10',
'pandas>=0.20',
'seaborn>=0.7',
'scikit-learn>=0.18',
'scikit-learn==0.19.1',
'pyfaidx>=0.5.4',
'pysam>=0.10.0',
'HTSeq>=0.6',
Expand Down
39 changes: 35 additions & 4 deletions smallrnaseq/data/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ hr
margin-top: 30px;
padding: 1em 1.25em;
background-color: #fff;
width: 70%;
width: 65%;
float: right;
overflow: hidden;
}
Expand Down Expand Up @@ -127,9 +127,9 @@ a:active { color: red; }
padding: 5px;
margin-top: 40px;
margin-right: 5px;
float: right;
float: left;
height: 650px;
width: 25%;
width: 30%;
position: fixed;
overflow:hidden;
top: 30;
Expand All @@ -147,8 +147,39 @@ a:active { color: red; }

.sidebar td, th {
text-align: left;
font-size: 12px;
font-size: 11px;
}

/* Sortable tables */
.sortable {
margin:0px;padding:0px;
width:100%;
border:1px solid #b2a7a7;
font-family: monospace;
font-size:11px;
}
.sortable table{
table-layout: fixed;
border-collapse: collapse;
border-spacing: 0;
height:100%;
margin:0px;padding:2px;
}
.sortable td{
font-size: 11px;
border-width: 0px 0px 0px 0px;
margin: 1px;
padding: 2px 3px;
width: 100%;
}
.sortable th{
background-color: #ECF0F1;
border-width: 0px 0px 0px 0px;
max-width: 300px;
min-width: 40px;
word-wrap: break-word;
}
.sortable tr:nth-child(even){ background-color:#F7F7F7; }

.main, .aside
{
Expand Down
17 changes: 14 additions & 3 deletions smallrnaseq/novel.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ def build_classifier(known, neg):
def precursor_classifier():
"""Get the stored miRNA precursor classifier model"""

#avoid being flooded with userwarnings
import warnings
warnings.filterwarnings("ignore", category=UserWarning)
from sklearn.externals import joblib
rf = joblib.load(os.path.join(datadir, 'premirna_model.joblib'))
return rf
Expand Down Expand Up @@ -432,7 +435,10 @@ def get_read_clusters(reads, cluster_distance=0, min_size=3, key='align_id'):
c = c.groupby(['strand']).filter(lambda x: len(x) > 1)
groups.append(c)
i+=1
df = pd.concat(groups)
if len(groups) > 0:
df = pd.concat(groups)
else:
df = pd.DataFrame()
return df

def get_cluster_groups(rcl):
Expand Down Expand Up @@ -707,6 +713,9 @@ def find_mirnas(reads, ref_fasta, score_cutoff=.8, read_cutoff=50, species='',
rcl=rcl, ref_fasta=ref_fasta, score_cutoff=score_cutoff,
read_cutoff=read_cutoff)

if len(new) == 0:
print ('no precursors found above cutoff')
return None, None
new['seed'] = new.apply(lambda x: x.mature[1:7], 1)
#get coords column
new['coords'] = new.apply(get_coords_string,1)
Expand All @@ -720,6 +729,7 @@ def find_mirnas(reads, ref_fasta, score_cutoff=.8, read_cutoff=50, species='',

u = summarize(new)
print ('found %s unique novel mirnas' %len(u))
print ('score cutoff=%s' %score_cutoff)
print ('%s with known mature sequences' %len(u[-u.known_id.isnull()]))
#also return all the reads found in clusters
#found = pd.concat(X)
Expand Down Expand Up @@ -836,15 +846,16 @@ def create_report(df, reads, species=None, outfile='report.html'):
css = get_css()
h = '<html><head><meta charset="utf-8"> <title>novel miRNA</title>'
h += '<style media="screen" type="text/css"> %s </style>' %css
h += '<script src="https://cdnjs.cloudflare.com/ajax/libs/sortable/0.8.0/js/sortable.js"></script>'
h += '</head>'
h += '<body>'
h += '<div class="header">'
h += '<h3>novel miRNA predictions</h3>'
h += '</div>'
h += '<div class="sidebar">'
links = df[['mature_id','mature_reads','chrom','start','score']].copy()
links = df[['mature_id','mature_reads','coords','score']].copy()
links['mature_id'] = links.mature_id.apply(lambda x: ('<a href=#%s > %s </a>' %(x,x)))
links = links.set_index(['mature_id','chrom','start']).sort_index()
links = links.set_index(['mature_id','coords']).sort_index()
#link = links.set_index('mature_id').sort_values(['chrom','start'])
h += links.to_html(escape=False, classes='sidebar', sparsify=True)#, index=False)
h += '</div>'
Expand Down

0 comments on commit 112b9f6

Please sign in to comment.