Skip to content

Instantly share code, notes, and snippets.

@larssono
Created November 10, 2016 21:54
Show Gist options
  • Save larssono/308c8e8399cd9060b76f11881b4f2536 to your computer and use it in GitHub Desktop.
Save larssono/308c8e8399cd9060b76f11881b4f2536 to your computer and use it in GitHub Desktop.
import synapseclient
syn=synapseclient.Synapse()
syn.login()
def determineNewSampleCount():
"""
"""
table = syn.tableQuery('SELECT * FROM syn3281840')
df = table.asDataFrame()
#Create a summary of the number of samples for each platform and disease
return df.pivot_table('patient_barcode', columns=['acronym'], index=['platform'], aggfunc=lambda x:len(set(x)))
wiki = syn.getWiki('syn2485697', '409059')
table = determineNewSampleCount()
tablestr = table.to_csv(sep='|')
startIndex = wiki.markdown.index('1|2|3')
endIndex = wiki.markdown.index('Table x')
wiki.markdown = '%s\n%s\n%s' %(wiki.markdown[:startIndex], tablestr, wiki.markdown[endIndex:])
syn.store(wiki)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment