<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Subset the genes based on their total number of transcripts
Step1:  Look at gene's median transcript count
Step2:  Clean data matrix to be compatible with the cluster labels and identities
Currently, cells are labeled by their barcode, e.g. GCGCAACTGCTC, and genes are labeled by their chrom
<ASSISTANT_TASK:>
Python Code:
(n_transcripts_per_gene > 1e3).sum()
n_transcripts_per_gene[n_transcripts_per_gene > 1e4]
Explanation: Subset the genes based on their total number of transcripts
End of explanation
median_transcripts_per_gene = table1_t.median()
median_transcripts_per_gene.head()
sns.distplot(median_transcripts_per_gene)
fig = plt.gcf()
fig.savefig('median_transcripts_per_gene.png')
data = median_transcripts_per_gene
mask = data > 0
sns.distplot(data[mask])
fig = plt.gcf()
fig.savefig('median_transcripts_per_gene_greater0.png')
Explanation: Look at gene's median transcript count
End of explanation
gene_symbols = table1_t.columns.map(lambda x: x.split(':')[-1].upper())
gene_symbols.name = 'symbol'
table1_t.columnsmns = gene_symbols
table1_t.head()
barcodes = 'r1_' + table1_t.index
barcodes.name = 'barcode'
table1_t.index = barcodes
table1_t.head()
table1_t.to_csv('expression_table1.csv')
Explanation: Clean data matrix to be compatible with the cluster labels and identities
Currently, cells are labeled by their barcode, e.g. GCGCAACTGCTC, and genes are labeled by their chrom:start-end:symbol, e.g. 6:51460434-51469894:Hnrnpa2b1. But, in the supplementary data, the genes are all uppercase, e.g. HNRNPA2B1 (which is incorrect since this is mouse data.. ) and the barcodes have r1_ prepended before the id, e.g. r1_GCGCAACTGCTC.
So we need to clean the data to be compatible with this
End of explanation
<END_TASK>