repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
pyhys/minimalmodbus
minimalmodbus.py
Instrument.read_bit
def read_bit(self, registeraddress, functioncode=2): """Read one bit from the slave. Args: * registeraddress (int): The slave register address (use decimal numbers, not hex). * functioncode (int): Modbus function code. Can be 1 or 2. Returns: The bit value 0...
python
def read_bit(self, registeraddress, functioncode=2): """Read one bit from the slave. Args: * registeraddress (int): The slave register address (use decimal numbers, not hex). * functioncode (int): Modbus function code. Can be 1 or 2. Returns: The bit value 0...
[ "def", "read_bit", "(", "self", ",", "registeraddress", ",", "functioncode", "=", "2", ")", ":", "_checkFunctioncode", "(", "functioncode", ",", "[", "1", ",", "2", "]", ")", "return", "self", ".", "_genericCommand", "(", "functioncode", ",", "registeraddres...
Read one bit from the slave. Args: * registeraddress (int): The slave register address (use decimal numbers, not hex). * functioncode (int): Modbus function code. Can be 1 or 2. Returns: The bit value 0 or 1 (int). Raises: ValueError, TypeError,...
[ "Read", "one", "bit", "from", "the", "slave", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L178-L193
pyhys/minimalmodbus
minimalmodbus.py
Instrument.write_bit
def write_bit(self, registeraddress, value, functioncode=5): """Write one bit to the slave. Args: * registeraddress (int): The slave register address (use decimal numbers, not hex). * value (int): 0 or 1 * functioncode (int): Modbus function code. Can be 5 or 15. ...
python
def write_bit(self, registeraddress, value, functioncode=5): """Write one bit to the slave. Args: * registeraddress (int): The slave register address (use decimal numbers, not hex). * value (int): 0 or 1 * functioncode (int): Modbus function code. Can be 5 or 15. ...
[ "def", "write_bit", "(", "self", ",", "registeraddress", ",", "value", ",", "functioncode", "=", "5", ")", ":", "_checkFunctioncode", "(", "functioncode", ",", "[", "5", ",", "15", "]", ")", "_checkInt", "(", "value", ",", "minvalue", "=", "0", ",", "m...
Write one bit to the slave. Args: * registeraddress (int): The slave register address (use decimal numbers, not hex). * value (int): 0 or 1 * functioncode (int): Modbus function code. Can be 5 or 15. Returns: None Raises: ValueError,...
[ "Write", "one", "bit", "to", "the", "slave", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L196-L213
pyhys/minimalmodbus
minimalmodbus.py
Instrument.read_register
def read_register(self, registeraddress, numberOfDecimals=0, functioncode=3, signed=False): """Read an integer from one 16-bit register in the slave, possibly scaling it. The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16"). Args: * registeraddress ...
python
def read_register(self, registeraddress, numberOfDecimals=0, functioncode=3, signed=False): """Read an integer from one 16-bit register in the slave, possibly scaling it. The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16"). Args: * registeraddress ...
[ "def", "read_register", "(", "self", ",", "registeraddress", ",", "numberOfDecimals", "=", "0", ",", "functioncode", "=", "3", ",", "signed", "=", "False", ")", ":", "_checkFunctioncode", "(", "functioncode", ",", "[", "3", ",", "4", "]", ")", "_checkInt",...
Read an integer from one 16-bit register in the slave, possibly scaling it. The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16"). Args: * registeraddress (int): The slave register address (use decimal numbers, not hex). * numberOfDecimals (int):...
[ "Read", "an", "integer", "from", "one", "16", "-", "bit", "register", "in", "the", "slave", "possibly", "scaling", "it", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L216-L258
pyhys/minimalmodbus
minimalmodbus.py
Instrument.write_register
def write_register(self, registeraddress, value, numberOfDecimals=0, functioncode=16, signed=False): """Write an integer to one 16-bit register in the slave, possibly scaling it. The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16"). Args: * register...
python
def write_register(self, registeraddress, value, numberOfDecimals=0, functioncode=16, signed=False): """Write an integer to one 16-bit register in the slave, possibly scaling it. The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16"). Args: * register...
[ "def", "write_register", "(", "self", ",", "registeraddress", ",", "value", ",", "numberOfDecimals", "=", "0", ",", "functioncode", "=", "16", ",", "signed", "=", "False", ")", ":", "_checkFunctioncode", "(", "functioncode", ",", "[", "6", ",", "16", "]", ...
Write an integer to one 16-bit register in the slave, possibly scaling it. The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16"). Args: * registeraddress (int): The slave register address (use decimal numbers, not hex). * value (int or float): T...
[ "Write", "an", "integer", "to", "one", "16", "-", "bit", "register", "in", "the", "slave", "possibly", "scaling", "it", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L261-L296
pyhys/minimalmodbus
minimalmodbus.py
Instrument.read_long
def read_long(self, registeraddress, functioncode=3, signed=False): """Read a long integer (32 bits) from the slave. Long integers (32 bits = 4 bytes) are stored in two consecutive 16-bit registers in the slave. Args: * registeraddress (int): The slave register start address (use d...
python
def read_long(self, registeraddress, functioncode=3, signed=False): """Read a long integer (32 bits) from the slave. Long integers (32 bits = 4 bytes) are stored in two consecutive 16-bit registers in the slave. Args: * registeraddress (int): The slave register start address (use d...
[ "def", "read_long", "(", "self", ",", "registeraddress", ",", "functioncode", "=", "3", ",", "signed", "=", "False", ")", ":", "_checkFunctioncode", "(", "functioncode", ",", "[", "3", ",", "4", "]", ")", "_checkBool", "(", "signed", ",", "description", ...
Read a long integer (32 bits) from the slave. Long integers (32 bits = 4 bytes) are stored in two consecutive 16-bit registers in the slave. Args: * registeraddress (int): The slave register start address (use decimal numbers, not hex). * functioncode (int): Modbus function cod...
[ "Read", "a", "long", "integer", "(", "32", "bits", ")", "from", "the", "slave", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L299-L325
pyhys/minimalmodbus
minimalmodbus.py
Instrument.write_long
def write_long(self, registeraddress, value, signed=False): """Write a long integer (32 bits) to the slave. Long integers (32 bits = 4 bytes) are stored in two consecutive 16-bit registers in the slave. Uses Modbus function code 16. For discussion on number of bits, number of register...
python
def write_long(self, registeraddress, value, signed=False): """Write a long integer (32 bits) to the slave. Long integers (32 bits = 4 bytes) are stored in two consecutive 16-bit registers in the slave. Uses Modbus function code 16. For discussion on number of bits, number of register...
[ "def", "write_long", "(", "self", ",", "registeraddress", ",", "value", ",", "signed", "=", "False", ")", ":", "MAX_VALUE_LONG", "=", "4294967295", "# Unsigned INT32", "MIN_VALUE_LONG", "=", "-", "2147483648", "# INT32", "_checkInt", "(", "value", ",", "minvalue...
Write a long integer (32 bits) to the slave. Long integers (32 bits = 4 bytes) are stored in two consecutive 16-bit registers in the slave. Uses Modbus function code 16. For discussion on number of bits, number of registers, the range and on alternative names, see :meth:`.read_long`. ...
[ "Write", "a", "long", "integer", "(", "32", "bits", ")", "to", "the", "slave", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L328-L355
pyhys/minimalmodbus
minimalmodbus.py
Instrument.read_float
def read_float(self, registeraddress, functioncode=3, numberOfRegisters=2): """Read a floating point number from the slave. Floats are stored in two or more consecutive 16-bit registers in the slave. The encoding is according to the standard IEEE 754. There are differences in the byte ...
python
def read_float(self, registeraddress, functioncode=3, numberOfRegisters=2): """Read a floating point number from the slave. Floats are stored in two or more consecutive 16-bit registers in the slave. The encoding is according to the standard IEEE 754. There are differences in the byte ...
[ "def", "read_float", "(", "self", ",", "registeraddress", ",", "functioncode", "=", "3", ",", "numberOfRegisters", "=", "2", ")", ":", "_checkFunctioncode", "(", "functioncode", ",", "[", "3", ",", "4", "]", ")", "_checkInt", "(", "numberOfRegisters", ",", ...
Read a floating point number from the slave. Floats are stored in two or more consecutive 16-bit registers in the slave. The encoding is according to the standard IEEE 754. There are differences in the byte order used by different manufacturers. A floating point value of 1.0 is encoded...
[ "Read", "a", "floating", "point", "number", "from", "the", "slave", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L358-L392
pyhys/minimalmodbus
minimalmodbus.py
Instrument.write_float
def write_float(self, registeraddress, value, numberOfRegisters=2): """Write a floating point number to the slave. Floats are stored in two or more consecutive 16-bit registers in the slave. Uses Modbus function code 16. For discussion on precision, number of registers and on byte ord...
python
def write_float(self, registeraddress, value, numberOfRegisters=2): """Write a floating point number to the slave. Floats are stored in two or more consecutive 16-bit registers in the slave. Uses Modbus function code 16. For discussion on precision, number of registers and on byte ord...
[ "def", "write_float", "(", "self", ",", "registeraddress", ",", "value", ",", "numberOfRegisters", "=", "2", ")", ":", "_checkNumerical", "(", "value", ",", "description", "=", "'input value'", ")", "_checkInt", "(", "numberOfRegisters", ",", "minvalue", "=", ...
Write a floating point number to the slave. Floats are stored in two or more consecutive 16-bit registers in the slave. Uses Modbus function code 16. For discussion on precision, number of registers and on byte order, see :meth:`.read_float`. Args: * registeraddress (int)...
[ "Write", "a", "floating", "point", "number", "to", "the", "slave", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L395-L419
pyhys/minimalmodbus
minimalmodbus.py
Instrument.read_string
def read_string(self, registeraddress, numberOfRegisters=16, functioncode=3): """Read a string from the slave. Each 16-bit register in the slave are interpreted as two characters (1 byte = 8 bits). For example 16 consecutive registers can hold 32 characters (32 bytes). Args: ...
python
def read_string(self, registeraddress, numberOfRegisters=16, functioncode=3): """Read a string from the slave. Each 16-bit register in the slave are interpreted as two characters (1 byte = 8 bits). For example 16 consecutive registers can hold 32 characters (32 bytes). Args: ...
[ "def", "read_string", "(", "self", ",", "registeraddress", ",", "numberOfRegisters", "=", "16", ",", "functioncode", "=", "3", ")", ":", "_checkFunctioncode", "(", "functioncode", ",", "[", "3", ",", "4", "]", ")", "_checkInt", "(", "numberOfRegisters", ",",...
Read a string from the slave. Each 16-bit register in the slave are interpreted as two characters (1 byte = 8 bits). For example 16 consecutive registers can hold 32 characters (32 bytes). Args: * registeraddress (int): The slave register start address (use decimal numbers, not hex...
[ "Read", "a", "string", "from", "the", "slave", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L422-L443
pyhys/minimalmodbus
minimalmodbus.py
Instrument.write_string
def write_string(self, registeraddress, textstring, numberOfRegisters=16): """Write a string to the slave. Each 16-bit register in the slave are interpreted as two characters (1 byte = 8 bits). For example 16 consecutive registers can hold 32 characters (32 bytes). Uses Modbus function...
python
def write_string(self, registeraddress, textstring, numberOfRegisters=16): """Write a string to the slave. Each 16-bit register in the slave are interpreted as two characters (1 byte = 8 bits). For example 16 consecutive registers can hold 32 characters (32 bytes). Uses Modbus function...
[ "def", "write_string", "(", "self", ",", "registeraddress", ",", "textstring", ",", "numberOfRegisters", "=", "16", ")", ":", "_checkInt", "(", "numberOfRegisters", ",", "minvalue", "=", "1", ",", "description", "=", "'number of registers for write string'", ")", ...
Write a string to the slave. Each 16-bit register in the slave are interpreted as two characters (1 byte = 8 bits). For example 16 consecutive registers can hold 32 characters (32 bytes). Uses Modbus function code 16. Args: * registeraddress (int): The slave register start...
[ "Write", "a", "string", "to", "the", "slave", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L446-L472
pyhys/minimalmodbus
minimalmodbus.py
Instrument.write_registers
def write_registers(self, registeraddress, values): """Write integers to 16-bit registers in the slave. The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16"). Uses Modbus function code 16. The number of registers that will be written is defined by the l...
python
def write_registers(self, registeraddress, values): """Write integers to 16-bit registers in the slave. The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16"). Uses Modbus function code 16. The number of registers that will be written is defined by the l...
[ "def", "write_registers", "(", "self", ",", "registeraddress", ",", "values", ")", ":", "if", "not", "isinstance", "(", "values", ",", "list", ")", ":", "raise", "TypeError", "(", "'The \"values parameter\" must be a list. Given: {0!r}'", ".", "format", "(", "valu...
Write integers to 16-bit registers in the slave. The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16"). Uses Modbus function code 16. The number of registers that will be written is defined by the length of the ``values`` list. Args: * regi...
[ "Write", "integers", "to", "16", "-", "bit", "registers", "in", "the", "slave", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L501-L529
pyhys/minimalmodbus
minimalmodbus.py
Instrument._genericCommand
def _genericCommand(self, functioncode, registeraddress, value=None, \ numberOfDecimals=0, numberOfRegisters=1, signed=False, payloadformat=None): """Generic command for reading and writing registers and bits. Args: * functioncode (int): Modbus function code. * regis...
python
def _genericCommand(self, functioncode, registeraddress, value=None, \ numberOfDecimals=0, numberOfRegisters=1, signed=False, payloadformat=None): """Generic command for reading and writing registers and bits. Args: * functioncode (int): Modbus function code. * regis...
[ "def", "_genericCommand", "(", "self", ",", "functioncode", ",", "registeraddress", ",", "value", "=", "None", ",", "numberOfDecimals", "=", "0", ",", "numberOfRegisters", "=", "1", ",", "signed", "=", "False", ",", "payloadformat", "=", "None", ")", ":", ...
Generic command for reading and writing registers and bits. Args: * functioncode (int): Modbus function code. * registeraddress (int): The register address (use decimal numbers, not hex). * value (numerical or string or None or list of int): The value to store in the regist...
[ "Generic", "command", "for", "reading", "and", "writing", "registers", "and", "bits", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L536-L750
pyhys/minimalmodbus
minimalmodbus.py
Instrument._performCommand
def _performCommand(self, functioncode, payloadToSlave): """Performs the command having the *functioncode*. Args: * functioncode (int): The function code for the command to be performed. Can for example be 'Write register' = 16. * payloadToSlave (str): Data to be transmitted to ...
python
def _performCommand(self, functioncode, payloadToSlave): """Performs the command having the *functioncode*. Args: * functioncode (int): The function code for the command to be performed. Can for example be 'Write register' = 16. * payloadToSlave (str): Data to be transmitted to ...
[ "def", "_performCommand", "(", "self", ",", "functioncode", ",", "payloadToSlave", ")", ":", "DEFAULT_NUMBER_OF_BYTES_TO_READ", "=", "1000", "_checkFunctioncode", "(", "functioncode", ",", "None", ")", "_checkString", "(", "payloadToSlave", ",", "description", "=", ...
Performs the command having the *functioncode*. Args: * functioncode (int): The function code for the command to be performed. Can for example be 'Write register' = 16. * payloadToSlave (str): Data to be transmitted to the slave (will be embedded in slaveaddress, CRC etc) Retur...
[ "Performs", "the", "command", "having", "the", "*", "functioncode", "*", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L757-L799
pyhys/minimalmodbus
minimalmodbus.py
Instrument._communicate
def _communicate(self, request, number_of_bytes_to_read): """Talk to the slave via a serial port. Args: request (str): The raw request that is to be sent to the slave. number_of_bytes_to_read (int): number of bytes to read Returns: The raw data (string) retu...
python
def _communicate(self, request, number_of_bytes_to_read): """Talk to the slave via a serial port. Args: request (str): The raw request that is to be sent to the slave. number_of_bytes_to_read (int): number of bytes to read Returns: The raw data (string) retu...
[ "def", "_communicate", "(", "self", ",", "request", ",", "number_of_bytes_to_read", ")", ":", "_checkString", "(", "request", ",", "minlength", "=", "1", ",", "description", "=", "'request'", ")", "_checkInt", "(", "number_of_bytes_to_read", ")", "if", "self", ...
Talk to the slave via a serial port. Args: request (str): The raw request that is to be sent to the slave. number_of_bytes_to_read (int): number of bytes to read Returns: The raw data (string) returned from the slave. Raises: TypeError, ValueErr...
[ "Talk", "to", "the", "slave", "via", "a", "serial", "port", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L802-L932
TaylorSMarks/playsound
playsound.py
_playsoundWin
def _playsoundWin(sound, block = True): ''' Utilizes windll.winmm. Tested and known to work with MP3 and WAVE on Windows 7 with Python 2.7. Probably works with more file formats. Probably works on Windows XP thru Windows 10. Probably works with all versions of Python. Inspired by (but not copie...
python
def _playsoundWin(sound, block = True): ''' Utilizes windll.winmm. Tested and known to work with MP3 and WAVE on Windows 7 with Python 2.7. Probably works with more file formats. Probably works on Windows XP thru Windows 10. Probably works with all versions of Python. Inspired by (but not copie...
[ "def", "_playsoundWin", "(", "sound", ",", "block", "=", "True", ")", ":", "from", "ctypes", "import", "c_buffer", ",", "windll", "from", "random", "import", "random", "from", "time", "import", "sleep", "from", "sys", "import", "getfilesystemencoding", "def", ...
Utilizes windll.winmm. Tested and known to work with MP3 and WAVE on Windows 7 with Python 2.7. Probably works with more file formats. Probably works on Windows XP thru Windows 10. Probably works with all versions of Python. Inspired by (but not copied from) Michael Gundlach <gundlach@gmail.com>'s mp3p...
[ "Utilizes", "windll", ".", "winmm", ".", "Tested", "and", "known", "to", "work", "with", "MP3", "and", "WAVE", "on", "Windows", "7", "with", "Python", "2", ".", "7", ".", "Probably", "works", "with", "more", "file", "formats", ".", "Probably", "works", ...
train
https://github.com/TaylorSMarks/playsound/blob/907f1fe73375a2156f7e0900c4b42c0a60fa1d00/playsound.py#L4-L41
TaylorSMarks/playsound
playsound.py
_playsoundOSX
def _playsoundOSX(sound, block = True): ''' Utilizes AppKit.NSSound. Tested and known to work with MP3 and WAVE on OS X 10.11 with Python 2.7. Probably works with anything QuickTime supports. Probably works on OS X 10.5 and newer. Probably works with all versions of Python. Inspired by (but not...
python
def _playsoundOSX(sound, block = True): ''' Utilizes AppKit.NSSound. Tested and known to work with MP3 and WAVE on OS X 10.11 with Python 2.7. Probably works with anything QuickTime supports. Probably works on OS X 10.5 and newer. Probably works with all versions of Python. Inspired by (but not...
[ "def", "_playsoundOSX", "(", "sound", ",", "block", "=", "True", ")", ":", "from", "AppKit", "import", "NSSound", "from", "Foundation", "import", "NSURL", "from", "time", "import", "sleep", "if", "'://'", "not", "in", "sound", ":", "if", "not", "sound", ...
Utilizes AppKit.NSSound. Tested and known to work with MP3 and WAVE on OS X 10.11 with Python 2.7. Probably works with anything QuickTime supports. Probably works on OS X 10.5 and newer. Probably works with all versions of Python. Inspired by (but not copied from) Aaron's Stack Overflow answer here: ...
[ "Utilizes", "AppKit", ".", "NSSound", ".", "Tested", "and", "known", "to", "work", "with", "MP3", "and", "WAVE", "on", "OS", "X", "10", ".", "11", "with", "Python", "2", ".", "7", ".", "Probably", "works", "with", "anything", "QuickTime", "supports", "...
train
https://github.com/TaylorSMarks/playsound/blob/907f1fe73375a2156f7e0900c4b42c0a60fa1d00/playsound.py#L43-L71
TaylorSMarks/playsound
playsound.py
_playsoundNix
def _playsoundNix(sound, block=True): """Play a sound using GStreamer. Inspired by this: https://gstreamer.freedesktop.org/documentation/tutorials/playback/playbin-usage.html """ if not block: raise NotImplementedError( "block=False cannot be used on this platform yet") # p...
python
def _playsoundNix(sound, block=True): """Play a sound using GStreamer. Inspired by this: https://gstreamer.freedesktop.org/documentation/tutorials/playback/playbin-usage.html """ if not block: raise NotImplementedError( "block=False cannot be used on this platform yet") # p...
[ "def", "_playsoundNix", "(", "sound", ",", "block", "=", "True", ")", ":", "if", "not", "block", ":", "raise", "NotImplementedError", "(", "\"block=False cannot be used on this platform yet\"", ")", "# pathname2url escapes non-URL-safe characters", "import", "os", "try", ...
Play a sound using GStreamer. Inspired by this: https://gstreamer.freedesktop.org/documentation/tutorials/playback/playbin-usage.html
[ "Play", "a", "sound", "using", "GStreamer", "." ]
train
https://github.com/TaylorSMarks/playsound/blob/907f1fe73375a2156f7e0900c4b42c0a60fa1d00/playsound.py#L73-L112
mfitzp/padua
padua/filters.py
remove_rows_matching
def remove_rows_matching(df, column, match): """ Return a ``DataFrame`` with rows where `column` values match `match` are removed. The selected `column` series of values from the supplied Pandas ``DataFrame`` is compared to `match`, and those rows that match are removed from the DataFrame. :param ...
python
def remove_rows_matching(df, column, match): """ Return a ``DataFrame`` with rows where `column` values match `match` are removed. The selected `column` series of values from the supplied Pandas ``DataFrame`` is compared to `match`, and those rows that match are removed from the DataFrame. :param ...
[ "def", "remove_rows_matching", "(", "df", ",", "column", ",", "match", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "mask", "=", "df", "[", "column", "]", ".", "values", "!=", "match", "return", "df", ".", "iloc", "[", "mask", ",", ":", "]" ...
Return a ``DataFrame`` with rows where `column` values match `match` are removed. The selected `column` series of values from the supplied Pandas ``DataFrame`` is compared to `match`, and those rows that match are removed from the DataFrame. :param df: Pandas ``DataFrame`` :param column: Column indexe...
[ "Return", "a", "DataFrame", "with", "rows", "where", "column", "values", "match", "match", "are", "removed", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L4-L18
mfitzp/padua
padua/filters.py
remove_rows_containing
def remove_rows_containing(df, column, match): """ Return a ``DataFrame`` with rows where `column` values containing `match` are removed. The selected `column` series of values from the supplied Pandas ``DataFrame`` is compared to `match`, and those rows that contain it are removed from the DataFrame. ...
python
def remove_rows_containing(df, column, match): """ Return a ``DataFrame`` with rows where `column` values containing `match` are removed. The selected `column` series of values from the supplied Pandas ``DataFrame`` is compared to `match`, and those rows that contain it are removed from the DataFrame. ...
[ "def", "remove_rows_containing", "(", "df", ",", "column", ",", "match", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "mask", "=", "[", "match", "not", "in", "str", "(", "v", ")", "for", "v", "in", "df", "[", "column", "]", ".", "values", ...
Return a ``DataFrame`` with rows where `column` values containing `match` are removed. The selected `column` series of values from the supplied Pandas ``DataFrame`` is compared to `match`, and those rows that contain it are removed from the DataFrame. :param df: Pandas ``DataFrame`` :param column: Col...
[ "Return", "a", "DataFrame", "with", "rows", "where", "column", "values", "containing", "match", "are", "removed", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L21-L35
mfitzp/padua
padua/filters.py
filter_localization_probability
def filter_localization_probability(df, threshold=0.75): """ Remove rows with a localization probability below 0.75 Return a ``DataFrame`` where the rows with a value < `threshold` (default 0.75) in column 'Localization prob' are removed. Filters data to remove poorly localized peptides (non Class-I by...
python
def filter_localization_probability(df, threshold=0.75): """ Remove rows with a localization probability below 0.75 Return a ``DataFrame`` where the rows with a value < `threshold` (default 0.75) in column 'Localization prob' are removed. Filters data to remove poorly localized peptides (non Class-I by...
[ "def", "filter_localization_probability", "(", "df", ",", "threshold", "=", "0.75", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "localization_probability_mask", "=", "df", "[", "'Localization prob'", "]", ".", "values", ">=", "threshold", "return", "df",...
Remove rows with a localization probability below 0.75 Return a ``DataFrame`` where the rows with a value < `threshold` (default 0.75) in column 'Localization prob' are removed. Filters data to remove poorly localized peptides (non Class-I by default). :param df: Pandas ``DataFrame`` :param threshold:...
[ "Remove", "rows", "with", "a", "localization", "probability", "below", "0", ".", "75" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L77-L90
mfitzp/padua
padua/filters.py
minimum_valid_values_in_any_group
def minimum_valid_values_in_any_group(df, levels=None, n=1, invalid=np.nan): """ Filter ``DataFrame`` by at least n valid values in at least one group. Taking a Pandas ``DataFrame`` with a ``MultiIndex`` column index, filters rows to remove rows where there are less than `n` valid values per group. Gro...
python
def minimum_valid_values_in_any_group(df, levels=None, n=1, invalid=np.nan): """ Filter ``DataFrame`` by at least n valid values in at least one group. Taking a Pandas ``DataFrame`` with a ``MultiIndex`` column index, filters rows to remove rows where there are less than `n` valid values per group. Gro...
[ "def", "minimum_valid_values_in_any_group", "(", "df", ",", "levels", "=", "None", ",", "n", "=", "1", ",", "invalid", "=", "np", ".", "nan", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "if", "levels", "is", "None", ":", "if", "'Group'", "in"...
Filter ``DataFrame`` by at least n valid values in at least one group. Taking a Pandas ``DataFrame`` with a ``MultiIndex`` column index, filters rows to remove rows where there are less than `n` valid values per group. Groups are defined by the `levels` parameter indexing into the column index. For example...
[ "Filter", "DataFrame", "by", "at", "least", "n", "valid", "values", "in", "at", "least", "one", "group", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L93-L129
mfitzp/padua
padua/filters.py
search
def search(df, match, columns=['Proteins','Protein names','Gene names']): """ Search for a given string in a set of columns in a processed ``DataFrame``. Returns a filtered ``DataFrame`` where `match` is contained in one of the `columns`. :param df: Pandas ``DataFrame`` :param match: ``str`` to se...
python
def search(df, match, columns=['Proteins','Protein names','Gene names']): """ Search for a given string in a set of columns in a processed ``DataFrame``. Returns a filtered ``DataFrame`` where `match` is contained in one of the `columns`. :param df: Pandas ``DataFrame`` :param match: ``str`` to se...
[ "def", "search", "(", "df", ",", "match", ",", "columns", "=", "[", "'Proteins'", ",", "'Protein names'", ",", "'Gene names'", "]", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "dft", "=", "df", ".", "reset_index", "(", ")", "mask", "=", "np",...
Search for a given string in a set of columns in a processed ``DataFrame``. Returns a filtered ``DataFrame`` where `match` is contained in one of the `columns`. :param df: Pandas ``DataFrame`` :param match: ``str`` to search for in columns :param columns: ``list`` of ``str`` to search for match :r...
[ "Search", "for", "a", "given", "string", "in", "a", "set", "of", "columns", "in", "a", "processed", "DataFrame", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L132-L152
mfitzp/padua
padua/filters.py
filter_exclude
def filter_exclude(df, s): """ Filter dataframe to exclude matching columns, based on search for "s" :param s: string to search for, exclude matching columns """ keep = ~np.array( [s in c for c in df.columns.values] ) return df.iloc[:, keep]
python
def filter_exclude(df, s): """ Filter dataframe to exclude matching columns, based on search for "s" :param s: string to search for, exclude matching columns """ keep = ~np.array( [s in c for c in df.columns.values] ) return df.iloc[:, keep]
[ "def", "filter_exclude", "(", "df", ",", "s", ")", ":", "keep", "=", "~", "np", ".", "array", "(", "[", "s", "in", "c", "for", "c", "in", "df", ".", "columns", ".", "values", "]", ")", "return", "df", ".", "iloc", "[", ":", ",", "keep", "]" ]
Filter dataframe to exclude matching columns, based on search for "s" :param s: string to search for, exclude matching columns
[ "Filter", "dataframe", "to", "exclude", "matching", "columns", "based", "on", "search", "for", "s", ":", "param", "s", ":", "string", "to", "search", "for", "exclude", "matching", "columns" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L154-L161
mfitzp/padua
padua/filters.py
filter_select_columns_intensity
def filter_select_columns_intensity(df, prefix, columns): """ Filter dataframe to include specified columns, retaining any Intensity columns. """ # Note: I use %s.+ (not %s.*) so it forces a match with the prefix string, ONLY if it is followed by something. return df.filter(regex='^(%s.+|%s)$' % (pr...
python
def filter_select_columns_intensity(df, prefix, columns): """ Filter dataframe to include specified columns, retaining any Intensity columns. """ # Note: I use %s.+ (not %s.*) so it forces a match with the prefix string, ONLY if it is followed by something. return df.filter(regex='^(%s.+|%s)$' % (pr...
[ "def", "filter_select_columns_intensity", "(", "df", ",", "prefix", ",", "columns", ")", ":", "# Note: I use %s.+ (not %s.*) so it forces a match with the prefix string, ONLY if it is followed by something.", "return", "df", ".", "filter", "(", "regex", "=", "'^(%s.+|%s)$'", "%...
Filter dataframe to include specified columns, retaining any Intensity columns.
[ "Filter", "dataframe", "to", "include", "specified", "columns", "retaining", "any", "Intensity", "columns", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L163-L168
mfitzp/padua
padua/filters.py
filter_intensity
def filter_intensity(df, label="", with_multiplicity=False): """ Filter to include only the Intensity values with optional specified label, excluding other Intensity measurements, but retaining all other columns. """ label += ".*__\d" if with_multiplicity else "" dft = df.filter(regex="^(?!Int...
python
def filter_intensity(df, label="", with_multiplicity=False): """ Filter to include only the Intensity values with optional specified label, excluding other Intensity measurements, but retaining all other columns. """ label += ".*__\d" if with_multiplicity else "" dft = df.filter(regex="^(?!Int...
[ "def", "filter_intensity", "(", "df", ",", "label", "=", "\"\"", ",", "with_multiplicity", "=", "False", ")", ":", "label", "+=", "\".*__\\d\"", "if", "with_multiplicity", "else", "\"\"", "dft", "=", "df", ".", "filter", "(", "regex", "=", "\"^(?!Intensity)....
Filter to include only the Intensity values with optional specified label, excluding other Intensity measurements, but retaining all other columns.
[ "Filter", "to", "include", "only", "the", "Intensity", "values", "with", "optional", "specified", "label", "excluding", "other", "Intensity", "measurements", "but", "retaining", "all", "other", "columns", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L177-L187
mfitzp/padua
padua/filters.py
filter_ratio
def filter_ratio(df, label="", with_multiplicity=False): """ Filter to include only the Ratio values with optional specified label, excluding other Intensity measurements, but retaining all other columns. """ label += ".*__\d" if with_multiplicity else "" dft = df.filter(regex="^(?!Ratio).*$") ...
python
def filter_ratio(df, label="", with_multiplicity=False): """ Filter to include only the Ratio values with optional specified label, excluding other Intensity measurements, but retaining all other columns. """ label += ".*__\d" if with_multiplicity else "" dft = df.filter(regex="^(?!Ratio).*$") ...
[ "def", "filter_ratio", "(", "df", ",", "label", "=", "\"\"", ",", "with_multiplicity", "=", "False", ")", ":", "label", "+=", "\".*__\\d\"", "if", "with_multiplicity", "else", "\"\"", "dft", "=", "df", ".", "filter", "(", "regex", "=", "\"^(?!Ratio).*$\"", ...
Filter to include only the Ratio values with optional specified label, excluding other Intensity measurements, but retaining all other columns.
[ "Filter", "to", "include", "only", "the", "Ratio", "values", "with", "optional", "specified", "label", "excluding", "other", "Intensity", "measurements", "but", "retaining", "all", "other", "columns", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L201-L211
mfitzp/padua
padua/io.py
read_maxquant
def read_maxquant(f, header=0, index_col='id', **kwargs): """ Load the quantified table output from MaxQuant run, e.g. - Proteingroups.txt - Phospho (STY)Sites.txt :param f: Source file :return: Pandas dataframe of imported data """ df = pd.read_csv(f, delimiter='\t', header=he...
python
def read_maxquant(f, header=0, index_col='id', **kwargs): """ Load the quantified table output from MaxQuant run, e.g. - Proteingroups.txt - Phospho (STY)Sites.txt :param f: Source file :return: Pandas dataframe of imported data """ df = pd.read_csv(f, delimiter='\t', header=he...
[ "def", "read_maxquant", "(", "f", ",", "header", "=", "0", ",", "index_col", "=", "'id'", ",", "*", "*", "kwargs", ")", ":", "df", "=", "pd", ".", "read_csv", "(", "f", ",", "delimiter", "=", "'\\t'", ",", "header", "=", "header", ",", "index_col",...
Load the quantified table output from MaxQuant run, e.g. - Proteingroups.txt - Phospho (STY)Sites.txt :param f: Source file :return: Pandas dataframe of imported data
[ "Load", "the", "quantified", "table", "output", "from", "MaxQuant", "run", "e", ".", "g", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/io.py#L6-L18
mfitzp/padua
padua/io.py
read_perseus
def read_perseus(f): """ Load a Perseus processed data table :param f: Source file :return: Pandas dataframe of imported data """ df = pd.read_csv(f, delimiter='\t', header=[0,1,2,3], low_memory=False) df.columns = pd.MultiIndex.from_tuples([(x,) for x in df.columns.get_level_values(0)]) ...
python
def read_perseus(f): """ Load a Perseus processed data table :param f: Source file :return: Pandas dataframe of imported data """ df = pd.read_csv(f, delimiter='\t', header=[0,1,2,3], low_memory=False) df.columns = pd.MultiIndex.from_tuples([(x,) for x in df.columns.get_level_values(0)]) ...
[ "def", "read_perseus", "(", "f", ")", ":", "df", "=", "pd", ".", "read_csv", "(", "f", ",", "delimiter", "=", "'\\t'", ",", "header", "=", "[", "0", ",", "1", ",", "2", ",", "3", "]", ",", "low_memory", "=", "False", ")", "df", ".", "columns", ...
Load a Perseus processed data table :param f: Source file :return: Pandas dataframe of imported data
[ "Load", "a", "Perseus", "processed", "data", "table" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/io.py#L21-L30
mfitzp/padua
padua/io.py
write_perseus
def write_perseus(f, df): """ Export a dataframe to Perseus; recreating the format :param f: :param df: :return: """ ### Generate the Perseus like type index FIELD_TYPE_MAP = { 'Amino acid':'C', 'Charge':'C', 'Reverse':'C', 'Potential contaminant':'C', ...
python
def write_perseus(f, df): """ Export a dataframe to Perseus; recreating the format :param f: :param df: :return: """ ### Generate the Perseus like type index FIELD_TYPE_MAP = { 'Amino acid':'C', 'Charge':'C', 'Reverse':'C', 'Potential contaminant':'C', ...
[ "def", "write_perseus", "(", "f", ",", "df", ")", ":", "### Generate the Perseus like type index", "FIELD_TYPE_MAP", "=", "{", "'Amino acid'", ":", "'C'", ",", "'Charge'", ":", "'C'", ",", "'Reverse'", ":", "'C'", ",", "'Potential contaminant'", ":", "'C'", ",",...
Export a dataframe to Perseus; recreating the format :param f: :param df: :return:
[ "Export", "a", "dataframe", "to", "Perseus", ";", "recreating", "the", "format" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/io.py#L33-L82
mfitzp/padua
padua/io.py
write_phosphopath
def write_phosphopath(df, f, extra_columns=None): """ Write out the data frame of phosphosites in the following format:: protein, protein-Rsite, Rsite, multiplicity Q13619 Q13619-S10 S10 1 Q9H3Z4 Q9H3Z4-S10 S10 1 Q6GQQ9 Q6GQQ9-S100 S100 1 Q86YP4 Q86YP4-S100 S100 1 ...
python
def write_phosphopath(df, f, extra_columns=None): """ Write out the data frame of phosphosites in the following format:: protein, protein-Rsite, Rsite, multiplicity Q13619 Q13619-S10 S10 1 Q9H3Z4 Q9H3Z4-S10 S10 1 Q6GQQ9 Q6GQQ9-S100 S100 1 Q86YP4 Q86YP4-S100 S100 1 ...
[ "def", "write_phosphopath", "(", "df", ",", "f", ",", "extra_columns", "=", "None", ")", ":", "proteins", "=", "[", "_protein_id", "(", "k", ")", "for", "k", "in", "df", ".", "index", ".", "get_level_values", "(", "'Proteins'", ")", "]", "amino_acids", ...
Write out the data frame of phosphosites in the following format:: protein, protein-Rsite, Rsite, multiplicity Q13619 Q13619-S10 S10 1 Q9H3Z4 Q9H3Z4-S10 S10 1 Q6GQQ9 Q6GQQ9-S100 S100 1 Q86YP4 Q86YP4-S100 S100 1 Q9H307 Q9H307-S100 S100 1 Q8NEY1 Q8NEY1-S1000 S1000 ...
[ "Write", "out", "the", "data", "frame", "of", "phosphosites", "in", "the", "following", "format", "::" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/io.py#L95-L127
mfitzp/padua
padua/io.py
write_phosphopath_ratio
def write_phosphopath_ratio(df, f, a, *args, **kwargs): """ Write out the data frame ratio between two groups protein-Rsite-multiplicity-timepoint ID Ratio Q13619-S10-1-1 0.5 Q9H3Z4-S10-1-1 0.502 Q6GQQ9-S100-1-1 0.504 Q86YP4-S100-1-1 0.506 Q9H307-S100-1-1 0.508 Q8NEY1-S1000-1-1 0...
python
def write_phosphopath_ratio(df, f, a, *args, **kwargs): """ Write out the data frame ratio between two groups protein-Rsite-multiplicity-timepoint ID Ratio Q13619-S10-1-1 0.5 Q9H3Z4-S10-1-1 0.502 Q6GQQ9-S100-1-1 0.504 Q86YP4-S100-1-1 0.506 Q9H307-S100-1-1 0.508 Q8NEY1-S1000-1-1 0...
[ "def", "write_phosphopath_ratio", "(", "df", ",", "f", ",", "a", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "timepoint_idx", "=", "kwargs", ".", "get", "(", "'timepoint_idx'", ",", "None", ")", "proteins", "=", "[", "get_protein_id", "(", "k"...
Write out the data frame ratio between two groups protein-Rsite-multiplicity-timepoint ID Ratio Q13619-S10-1-1 0.5 Q9H3Z4-S10-1-1 0.502 Q6GQQ9-S100-1-1 0.504 Q86YP4-S100-1-1 0.506 Q9H307-S100-1-1 0.508 Q8NEY1-S1000-1-1 0.51 Q13541-S101-1-1 0.512 O95785-S1012-2-1 0.514 O95785-...
[ "Write", "out", "the", "data", "frame", "ratio", "between", "two", "groups", "protein", "-", "Rsite", "-", "multiplicity", "-", "timepoint", "ID", "Ratio", "Q13619", "-", "S10", "-", "1", "-", "1", "0", ".", "5", "Q9H3Z4", "-", "S10", "-", "1", "-", ...
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/io.py#L129-L185
mfitzp/padua
padua/io.py
write_r
def write_r(df, f, sep=",", index_join="@", columns_join="."): """ Export dataframe in a format easily importable to R Index fields are joined with "@" and column fields by "." by default. :param df: :param f: :param index_join: :param columns_join: :return: """ df = df.copy() ...
python
def write_r(df, f, sep=",", index_join="@", columns_join="."): """ Export dataframe in a format easily importable to R Index fields are joined with "@" and column fields by "." by default. :param df: :param f: :param index_join: :param columns_join: :return: """ df = df.copy() ...
[ "def", "write_r", "(", "df", ",", "f", ",", "sep", "=", "\",\"", ",", "index_join", "=", "\"@\"", ",", "columns_join", "=", "\".\"", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "df", ".", "index", "=", "[", "\"@\"", ".", "join", "(", "[",...
Export dataframe in a format easily importable to R Index fields are joined with "@" and column fields by "." by default. :param df: :param f: :param index_join: :param columns_join: :return:
[ "Export", "dataframe", "in", "a", "format", "easily", "importable", "to", "R" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/io.py#L188-L203
mfitzp/padua
padua/imputation.py
gaussian
def gaussian(df, width=0.3, downshift=-1.8, prefix=None): """ Impute missing values by drawing from a normal distribution :param df: :param width: Scale factor for the imputed distribution relative to the standard deviation of measured values. Can be a single number or list of one per column. :para...
python
def gaussian(df, width=0.3, downshift=-1.8, prefix=None): """ Impute missing values by drawing from a normal distribution :param df: :param width: Scale factor for the imputed distribution relative to the standard deviation of measured values. Can be a single number or list of one per column. :para...
[ "def", "gaussian", "(", "df", ",", "width", "=", "0.3", ",", "downshift", "=", "-", "1.8", ",", "prefix", "=", "None", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "imputed", "=", "df", ".", "isnull", "(", ")", "# Keep track of what's real", "...
Impute missing values by drawing from a normal distribution :param df: :param width: Scale factor for the imputed distribution relative to the standard deviation of measured values. Can be a single number or list of one per column. :param downshift: Shift the imputed values down, in units of std. dev. Can ...
[ "Impute", "missing", "values", "by", "drawing", "from", "a", "normal", "distribution" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/imputation.py#L14-L63
mfitzp/padua
padua/imputation.py
pls
def pls(df): """ A simple implementation of a least-squares approach to imputation using partial least squares regression (PLS). :param df: :return: """ if not sklearn: assert('This library depends on scikit-learn (sklearn) to perform PLS-based imputation') df = df.copy() ...
python
def pls(df): """ A simple implementation of a least-squares approach to imputation using partial least squares regression (PLS). :param df: :return: """ if not sklearn: assert('This library depends on scikit-learn (sklearn) to perform PLS-based imputation') df = df.copy() ...
[ "def", "pls", "(", "df", ")", ":", "if", "not", "sklearn", ":", "assert", "(", "'This library depends on scikit-learn (sklearn) to perform PLS-based imputation'", ")", "df", "=", "df", ".", "copy", "(", ")", "df", "[", "np", ".", "isinf", "(", "df", ")", "]"...
A simple implementation of a least-squares approach to imputation using partial least squares regression (PLS). :param df: :return:
[ "A", "simple", "implementation", "of", "a", "least", "-", "squares", "approach", "to", "imputation", "using", "partial", "least", "squares", "regression", "(", "PLS", ")", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/imputation.py#L66-L114
mfitzp/padua
padua/visualize.py
plot_cov_ellipse
def plot_cov_ellipse(cov, pos, nstd=2, **kwargs): """ Plots an `nstd` sigma error ellipse based on the specified covariance matrix (`cov`). Additional keyword arguments are passed on to the ellipse patch artist. Parameters ---------- cov : The 2x2 covariance matrix to base the ellipse o...
python
def plot_cov_ellipse(cov, pos, nstd=2, **kwargs): """ Plots an `nstd` sigma error ellipse based on the specified covariance matrix (`cov`). Additional keyword arguments are passed on to the ellipse patch artist. Parameters ---------- cov : The 2x2 covariance matrix to base the ellipse o...
[ "def", "plot_cov_ellipse", "(", "cov", ",", "pos", ",", "nstd", "=", "2", ",", "*", "*", "kwargs", ")", ":", "def", "eigsorted", "(", "cov", ")", ":", "vals", ",", "vecs", "=", "np", ".", "linalg", ".", "eigh", "(", "cov", ")", "order", "=", "v...
Plots an `nstd` sigma error ellipse based on the specified covariance matrix (`cov`). Additional keyword arguments are passed on to the ellipse patch artist. Parameters ---------- cov : The 2x2 covariance matrix to base the ellipse on pos : The location of the center of the ellipse. Exp...
[ "Plots", "an", "nstd", "sigma", "error", "ellipse", "based", "on", "the", "specified", "covariance", "matrix", "(", "cov", ")", ".", "Additional", "keyword", "arguments", "are", "passed", "on", "to", "the", "ellipse", "patch", "artist", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L81-L113
mfitzp/padua
padua/visualize.py
_pca_scores
def _pca_scores( scores, pc1=0, pc2=1, fcol=None, ecol=None, marker='o', markersize=30, label_scores=None, show_covariance_ellipse=True, optimize_label_iter=OPTIMIZE_LABEL_ITER_DEFAULT, **kwargs ): """ Plot a scores plot...
python
def _pca_scores( scores, pc1=0, pc2=1, fcol=None, ecol=None, marker='o', markersize=30, label_scores=None, show_covariance_ellipse=True, optimize_label_iter=OPTIMIZE_LABEL_ITER_DEFAULT, **kwargs ): """ Plot a scores plot...
[ "def", "_pca_scores", "(", "scores", ",", "pc1", "=", "0", ",", "pc2", "=", "1", ",", "fcol", "=", "None", ",", "ecol", "=", "None", ",", "marker", "=", "'o'", ",", "markersize", "=", "30", ",", "label_scores", "=", "None", ",", "show_covariance_elli...
Plot a scores plot for two principal components as AxB scatter plot. Returns the plotted axis. :param scores: DataFrame containing scores :param pc1: Column indexer into scores for PC1 :param pc2: Column indexer into scores for PC2 :param fcol: Face (fill) color definition :param ecol: Edge co...
[ "Plot", "a", "scores", "plot", "for", "two", "principal", "components", "as", "AxB", "scatter", "plot", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L117-L200
mfitzp/padua
padua/visualize.py
_pca_weights
def _pca_weights( weights, pc, threshold=None, label_threshold=None, label_weights=None, optimize_label_iter=OPTIMIZE_LABEL_ITER_DEFAULT, **kwargs ): """ :param weights: :param pc: :param threshold: :param label_threshold: :param label_...
python
def _pca_weights( weights, pc, threshold=None, label_threshold=None, label_weights=None, optimize_label_iter=OPTIMIZE_LABEL_ITER_DEFAULT, **kwargs ): """ :param weights: :param pc: :param threshold: :param label_threshold: :param label_...
[ "def", "_pca_weights", "(", "weights", ",", "pc", ",", "threshold", "=", "None", ",", "label_threshold", "=", "None", ",", "label_weights", "=", "None", ",", "optimize_label_iter", "=", "OPTIMIZE_LABEL_ITER_DEFAULT", ",", "*", "*", "kwargs", ")", ":", "fig", ...
:param weights: :param pc: :param threshold: :param label_threshold: :param label_weights: :param kwargs: :return:
[ ":", "param", "weights", ":", ":", "param", "pc", ":", ":", "param", "threshold", ":", ":", "param", "label_threshold", ":", ":", "param", "label_weights", ":", ":", "param", "kwargs", ":", ":", "return", ":" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L203-L263
mfitzp/padua
padua/visualize.py
pca
def pca(df, n_components=2, mean_center=False, fcol=None, ecol=None, marker='o', markersize=40, threshold=None, label_threshold=None, label_weights=None, label_scores=None, return_df=False, show_covariance_ellipse=False, *args, **kwargs): """ Perform Principal Component Analysis (PCA) from input DataFrame and g...
python
def pca(df, n_components=2, mean_center=False, fcol=None, ecol=None, marker='o', markersize=40, threshold=None, label_threshold=None, label_weights=None, label_scores=None, return_df=False, show_covariance_ellipse=False, *args, **kwargs): """ Perform Principal Component Analysis (PCA) from input DataFrame and g...
[ "def", "pca", "(", "df", ",", "n_components", "=", "2", ",", "mean_center", "=", "False", ",", "fcol", "=", "None", ",", "ecol", "=", "None", ",", "marker", "=", "'o'", ",", "markersize", "=", "40", ",", "threshold", "=", "None", ",", "label_threshol...
Perform Principal Component Analysis (PCA) from input DataFrame and generate scores and weights plots. Principal Component Analysis is a technique for identifying the largest source of variation in a dataset. This function uses the implementation available in scikit-learn. The PCA is calculated via `analysis.p...
[ "Perform", "Principal", "Component", "Analysis", "(", "PCA", ")", "from", "input", "DataFrame", "and", "generate", "scores", "and", "weights", "plots", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L266-L309
mfitzp/padua
padua/visualize.py
plsda
def plsda(df, a, b, n_components=2, mean_center=False, scale=True, fcol=None, ecol=None, marker='o', markersize=40, threshold=None, label_threshold=None, label_weights=None, label_scores=None, return_df=False, show_covariance_ellipse=False, *args, **kwargs): """ Partial Least Squares Regression Analysis, based ...
python
def plsda(df, a, b, n_components=2, mean_center=False, scale=True, fcol=None, ecol=None, marker='o', markersize=40, threshold=None, label_threshold=None, label_weights=None, label_scores=None, return_df=False, show_covariance_ellipse=False, *args, **kwargs): """ Partial Least Squares Regression Analysis, based ...
[ "def", "plsda", "(", "df", ",", "a", ",", "b", ",", "n_components", "=", "2", ",", "mean_center", "=", "False", ",", "scale", "=", "True", ",", "fcol", "=", "None", ",", "ecol", "=", "None", ",", "marker", "=", "'o'", ",", "markersize", "=", "40"...
Partial Least Squares Regression Analysis, based on `sklearn.cross_decomposition.PLSRegression` Performs a partial least squares regression (PLS-R) on the supplied dataframe ``df`` against the provided continuous variable ``v``, selecting the first ``n_components``. For more information on PLS regression ...
[ "Partial", "Least", "Squares", "Regression", "Analysis", "based", "on", "sklearn", ".", "cross_decomposition", ".", "PLSRegression" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L312-L358
mfitzp/padua
padua/visualize.py
plsr
def plsr(df, v, n_components=2, mean_center=False, scale=True, fcol=None, ecol=None, marker='o', markersize=40, threshold=None, label_threshold=None, label_weights=None, label_scores=None, return_df=False, show_covariance_ellipse=False, *args, **kwargs): """ Partial Least Squares Regression Analysis, based on `...
python
def plsr(df, v, n_components=2, mean_center=False, scale=True, fcol=None, ecol=None, marker='o', markersize=40, threshold=None, label_threshold=None, label_weights=None, label_scores=None, return_df=False, show_covariance_ellipse=False, *args, **kwargs): """ Partial Least Squares Regression Analysis, based on `...
[ "def", "plsr", "(", "df", ",", "v", ",", "n_components", "=", "2", ",", "mean_center", "=", "False", ",", "scale", "=", "True", ",", "fcol", "=", "None", ",", "ecol", "=", "None", ",", "marker", "=", "'o'", ",", "markersize", "=", "40", ",", "thr...
Partial Least Squares Regression Analysis, based on `sklearn.cross_decomposition.PLSRegression` Performs a partial least squares regression (PLS-R) on the supplied dataframe ``df`` against the provided continuous variable ``v``, selecting the first ``n_components``. For more information on PLS regression ...
[ "Partial", "Least", "Squares", "Regression", "Analysis", "based", "on", "sklearn", ".", "cross_decomposition", ".", "PLSRegression" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L362-L429
mfitzp/padua
padua/visualize.py
enrichment
def enrichment(dfenr, level=None): """ Generates an enrichment pie chart series from a calculate enrichment table :param dfenr: dataframe with enrichments :param level: the level to ungroup the :return: """ df = dfenr.sort_index(level=("Group", "Replicate","Timepoint","Technical" ), axis=1) ...
python
def enrichment(dfenr, level=None): """ Generates an enrichment pie chart series from a calculate enrichment table :param dfenr: dataframe with enrichments :param level: the level to ungroup the :return: """ df = dfenr.sort_index(level=("Group", "Replicate","Timepoint","Technical" ), axis=1) ...
[ "def", "enrichment", "(", "dfenr", ",", "level", "=", "None", ")", ":", "df", "=", "dfenr", ".", "sort_index", "(", "level", "=", "(", "\"Group\"", ",", "\"Replicate\"", ",", "\"Timepoint\"", ",", "\"Technical\"", ")", ",", "axis", "=", "1", ")", "if",...
Generates an enrichment pie chart series from a calculate enrichment table :param dfenr: dataframe with enrichments :param level: the level to ungroup the :return:
[ "Generates", "an", "enrichment", "pie", "chart", "series", "from", "a", "calculate", "enrichment", "table", ":", "param", "dfenr", ":", "dataframe", "with", "enrichments", ":", "param", "level", ":", "the", "level", "to", "ungroup", "the", ":", "return", ":"...
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L433-L455
mfitzp/padua
padua/visualize.py
volcano
def volcano(df, a, b=None, fdr=0.05, figsize=(8,10), show_numbers=True, threshold=2, minimum_sample_n=0, estimate_qvalues=False, labels_from=None, labels_for=None, title=None, label_format=None, ...
python
def volcano(df, a, b=None, fdr=0.05, figsize=(8,10), show_numbers=True, threshold=2, minimum_sample_n=0, estimate_qvalues=False, labels_from=None, labels_for=None, title=None, label_format=None, ...
[ "def", "volcano", "(", "df", ",", "a", ",", "b", "=", "None", ",", "fdr", "=", "0.05", ",", "figsize", "=", "(", "8", ",", "10", ")", ",", "show_numbers", "=", "True", ",", "threshold", "=", "2", ",", "minimum_sample_n", "=", "0", ",", "estimate_...
Volcano plot of two sample groups showing t-test p value vs. log2(fc). Generates a volcano plot for two sample groups, selected from `df` using `a` and `b` indexers. The mean of each group is calculated along the y-axis (per protein) and used to generate a log2 ratio. If a log2-transformed dataset is suppl...
[ "Volcano", "plot", "of", "two", "sample", "groups", "showing", "t", "-", "test", "p", "value", "vs", ".", "log2", "(", "fc", ")", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L458-L676
mfitzp/padua
padua/visualize.py
modifiedaminoacids
def modifiedaminoacids(df, kind='pie'): """ Generate a plot of relative numbers of modified amino acids in source DataFrame. Plot a pie or bar chart showing the number and percentage of modified amino acids in the supplied data frame. The amino acids displayed will be determined from the supplied d...
python
def modifiedaminoacids(df, kind='pie'): """ Generate a plot of relative numbers of modified amino acids in source DataFrame. Plot a pie or bar chart showing the number and percentage of modified amino acids in the supplied data frame. The amino acids displayed will be determined from the supplied d...
[ "def", "modifiedaminoacids", "(", "df", ",", "kind", "=", "'pie'", ")", ":", "colors", "=", "[", "'#6baed6'", ",", "'#c6dbef'", ",", "'#bdbdbd'", "]", "total_aas", ",", "quants", "=", "analysis", ".", "modifiedaminoacids", "(", "df", ")", "df", "=", "pd"...
Generate a plot of relative numbers of modified amino acids in source DataFrame. Plot a pie or bar chart showing the number and percentage of modified amino acids in the supplied data frame. The amino acids displayed will be determined from the supplied data/modification type. :param df: processed Dat...
[ "Generate", "a", "plot", "of", "relative", "numbers", "of", "modified", "amino", "acids", "in", "source", "DataFrame", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L697-L748
mfitzp/padua
padua/visualize.py
modificationlocalization
def modificationlocalization(df): """ Plot the % of Class I, II and III localised peptides according to standard thresholds. Generates a pie chart showing the % of peptides that fall within the Class I, II and III classifications based on localisation probability. These definitions are:: Class...
python
def modificationlocalization(df): """ Plot the % of Class I, II and III localised peptides according to standard thresholds. Generates a pie chart showing the % of peptides that fall within the Class I, II and III classifications based on localisation probability. These definitions are:: Class...
[ "def", "modificationlocalization", "(", "df", ")", ":", "colors", "=", "[", "\"#78c679\"", ",", "\"#d9f0a3\"", ",", "\"#ffffe5\"", "]", "lp", "=", "df", "[", "'Localization prob'", "]", ".", "values", "class_i", "=", "np", ".", "sum", "(", "lp", ">", "0....
Plot the % of Class I, II and III localised peptides according to standard thresholds. Generates a pie chart showing the % of peptides that fall within the Class I, II and III classifications based on localisation probability. These definitions are:: Class I 0.75 < x Class II 0.50 > x <...
[ "Plot", "the", "%", "of", "Class", "I", "II", "and", "III", "localised", "peptides", "according", "to", "standard", "thresholds", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L751-L795
mfitzp/padua
padua/visualize.py
box
def box(df, s=None, title_from=None, subplots=False, figsize=(18,6), groups=None, fcol=None, ecol=None, hatch=None, ylabel="", xlabel=""): """ Generate a box plot from pandas DataFrame with sample grouping. Plot group mean, median and deviations for specific values (proteins) in the dataset. Plotting is co...
python
def box(df, s=None, title_from=None, subplots=False, figsize=(18,6), groups=None, fcol=None, ecol=None, hatch=None, ylabel="", xlabel=""): """ Generate a box plot from pandas DataFrame with sample grouping. Plot group mean, median and deviations for specific values (proteins) in the dataset. Plotting is co...
[ "def", "box", "(", "df", ",", "s", "=", "None", ",", "title_from", "=", "None", ",", "subplots", "=", "False", ",", "figsize", "=", "(", "18", ",", "6", ")", ",", "groups", "=", "None", ",", "fcol", "=", "None", ",", "ecol", "=", "None", ",", ...
Generate a box plot from pandas DataFrame with sample grouping. Plot group mean, median and deviations for specific values (proteins) in the dataset. Plotting is controlled via the `s` param, which is used as a search string along the y-axis. All matching values will be returned and plotted. Multiple searc...
[ "Generate", "a", "box", "plot", "from", "pandas", "DataFrame", "with", "sample", "grouping", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L798-L928
mfitzp/padua
padua/visualize.py
venn
def venn(df1, df2, df3=None, labels=None, ix1=None, ix2=None, ix3=None, return_intersection=False, fcols=None): """ Plot a 2 or 3-part venn diagram showing the overlap between 2 or 3 pandas DataFrames. Provided with two or three Pandas DataFrames, this will return a venn diagram showing the overlap calcula...
python
def venn(df1, df2, df3=None, labels=None, ix1=None, ix2=None, ix3=None, return_intersection=False, fcols=None): """ Plot a 2 or 3-part venn diagram showing the overlap between 2 or 3 pandas DataFrames. Provided with two or three Pandas DataFrames, this will return a venn diagram showing the overlap calcula...
[ "def", "venn", "(", "df1", ",", "df2", ",", "df3", "=", "None", ",", "labels", "=", "None", ",", "ix1", "=", "None", ",", "ix2", "=", "None", ",", "ix3", "=", "None", ",", "return_intersection", "=", "False", ",", "fcols", "=", "None", ")", ":", ...
Plot a 2 or 3-part venn diagram showing the overlap between 2 or 3 pandas DataFrames. Provided with two or three Pandas DataFrames, this will return a venn diagram showing the overlap calculated between the DataFrame indexes provided as ix1, ix2, ix3. Labels for each DataFrame can be provided as a list in the ...
[ "Plot", "a", "2", "or", "3", "-", "part", "venn", "diagram", "showing", "the", "overlap", "between", "2", "or", "3", "pandas", "DataFrames", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L979-L1033
mfitzp/padua
padua/visualize.py
sitespeptidesproteins
def sitespeptidesproteins(df, labels=None, colors=None, site_localization_probability=0.75): """ Plot the number of sites, peptides and proteins in the dataset. Generates a plot with sites, peptides and proteins displayed hierarchically in chevrons. The site count is limited to Class I (<=0.75 site loc...
python
def sitespeptidesproteins(df, labels=None, colors=None, site_localization_probability=0.75): """ Plot the number of sites, peptides and proteins in the dataset. Generates a plot with sites, peptides and proteins displayed hierarchically in chevrons. The site count is limited to Class I (<=0.75 site loc...
[ "def", "sitespeptidesproteins", "(", "df", ",", "labels", "=", "None", ",", "colors", "=", "None", ",", "site_localization_probability", "=", "0.75", ")", ":", "fig", "=", "plt", ".", "figure", "(", "figsize", "=", "(", "4", ",", "6", ")", ")", "ax", ...
Plot the number of sites, peptides and proteins in the dataset. Generates a plot with sites, peptides and proteins displayed hierarchically in chevrons. The site count is limited to Class I (<=0.75 site localization probability) by default but may be altered using the `site_localization_probability` parame...
[ "Plot", "the", "number", "of", "sites", "peptides", "and", "proteins", "in", "the", "dataset", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L1036-L1071
mfitzp/padua
padua/visualize.py
rankintensity
def rankintensity(df, colors=None, labels_from='Protein names', number_of_annotations=3, show_go_enrichment=False, go_ids_from=None, go_enrichment='function', go_max_labels=8, go_fdr=None, progress_callback=None): """ Rank intensity plot, showing intensity order vs. raw intensity value S curve. Generates a...
python
def rankintensity(df, colors=None, labels_from='Protein names', number_of_annotations=3, show_go_enrichment=False, go_ids_from=None, go_enrichment='function', go_max_labels=8, go_fdr=None, progress_callback=None): """ Rank intensity plot, showing intensity order vs. raw intensity value S curve. Generates a...
[ "def", "rankintensity", "(", "df", ",", "colors", "=", "None", ",", "labels_from", "=", "'Protein names'", ",", "number_of_annotations", "=", "3", ",", "show_go_enrichment", "=", "False", ",", "go_ids_from", "=", "None", ",", "go_enrichment", "=", "'function'", ...
Rank intensity plot, showing intensity order vs. raw intensity value S curve. Generates a plot showing detected protein intensity plotted against protein intensity rank. A series of colors can be provided to segment the S curve into regions. Gene ontology enrichments (as calculated via `analysis.go_enrichment`...
[ "Rank", "intensity", "plot", "showing", "intensity", "order", "vs", ".", "raw", "intensity", "value", "S", "curve", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L1075-L1274
mfitzp/padua
padua/visualize.py
correlation
def correlation(df, cm=cm.PuOr_r, vmin=None, vmax=None, labels=None, show_scatter=False): """ Generate a column-wise correlation plot from the provided data. The columns of the supplied dataframes will be correlated (using `analysis.correlation`) to generate a Pearson correlation plot heatmap. Scatter ...
python
def correlation(df, cm=cm.PuOr_r, vmin=None, vmax=None, labels=None, show_scatter=False): """ Generate a column-wise correlation plot from the provided data. The columns of the supplied dataframes will be correlated (using `analysis.correlation`) to generate a Pearson correlation plot heatmap. Scatter ...
[ "def", "correlation", "(", "df", ",", "cm", "=", "cm", ".", "PuOr_r", ",", "vmin", "=", "None", ",", "vmax", "=", "None", ",", "labels", "=", "None", ",", "show_scatter", "=", "False", ")", ":", "data", "=", "analysis", ".", "correlation", "(", "df...
Generate a column-wise correlation plot from the provided data. The columns of the supplied dataframes will be correlated (using `analysis.correlation`) to generate a Pearson correlation plot heatmap. Scatter plots of correlated samples can also be generated over the redundant half of the plot to give a vi...
[ "Generate", "a", "column", "-", "wise", "correlation", "plot", "from", "the", "provided", "data", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L1278-L1371
mfitzp/padua
padua/visualize.py
_areadist
def _areadist(ax, v, xr, c, bins=100, by=None, alpha=1, label=None): """ Plot the histogram distribution but as an area plot """ y, x = np.histogram(v[~np.isnan(v)], bins) x = x[:-1] if by is None: by = np.zeros((bins,)) ax.fill_between(x, y, by, facecolor=c, alpha=alpha, label=lab...
python
def _areadist(ax, v, xr, c, bins=100, by=None, alpha=1, label=None): """ Plot the histogram distribution but as an area plot """ y, x = np.histogram(v[~np.isnan(v)], bins) x = x[:-1] if by is None: by = np.zeros((bins,)) ax.fill_between(x, y, by, facecolor=c, alpha=alpha, label=lab...
[ "def", "_areadist", "(", "ax", ",", "v", ",", "xr", ",", "c", ",", "bins", "=", "100", ",", "by", "=", "None", ",", "alpha", "=", "1", ",", "label", "=", "None", ")", ":", "y", ",", "x", "=", "np", ".", "histogram", "(", "v", "[", "~", "n...
Plot the histogram distribution but as an area plot
[ "Plot", "the", "histogram", "distribution", "but", "as", "an", "area", "plot" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L1374-L1385
mfitzp/padua
padua/visualize.py
compareimputed
def compareimputed(df1, df2, bins=50): """ Compare the distributions of two DataFrames giving visualisations of: - individual and combined distributions - distribution of non-common values - distribution of non-common values vs. each side Useful for visualising effects of data imputation. ...
python
def compareimputed(df1, df2, bins=50): """ Compare the distributions of two DataFrames giving visualisations of: - individual and combined distributions - distribution of non-common values - distribution of non-common values vs. each side Useful for visualising effects of data imputation. ...
[ "def", "compareimputed", "(", "df1", ",", "df2", ",", "bins", "=", "50", ")", ":", "fig", ",", "(", "ax1", ",", "ax2", ",", "ax3", ")", "=", "plt", ".", "subplots", "(", "1", ",", "3", ",", "figsize", "=", "(", "30", ",", "10", ")", ")", "x...
Compare the distributions of two DataFrames giving visualisations of: - individual and combined distributions - distribution of non-common values - distribution of non-common values vs. each side Useful for visualising effects of data imputation. Plot distribution as area (fill_between) + mean,...
[ "Compare", "the", "distributions", "of", "two", "DataFrames", "giving", "visualisations", "of", ":", "-", "individual", "and", "combined", "distributions", "-", "distribution", "of", "non", "-", "common", "values", "-", "distribution", "of", "non", "-", "common"...
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L1387-L1435
mfitzp/padua
padua/visualize.py
comparedist
def comparedist(df, *args, **kwargs): """ Compare the distributions of two DataFrames giving visualisations of: - individual and combined distributions - distribution of non-common values - distribution of non-common values vs. each side Plot distribution as area (fill_between) + mean, media...
python
def comparedist(df, *args, **kwargs): """ Compare the distributions of two DataFrames giving visualisations of: - individual and combined distributions - distribution of non-common values - distribution of non-common values vs. each side Plot distribution as area (fill_between) + mean, media...
[ "def", "comparedist", "(", "df", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "bins", "=", "kwargs", ".", "get", "(", "'bins'", ",", "50", ")", "xlabel", "=", "kwargs", ".", "get", "(", "'xlabel'", ",", "'Value'", ")", "ylabel", "=", "kwa...
Compare the distributions of two DataFrames giving visualisations of: - individual and combined distributions - distribution of non-common values - distribution of non-common values vs. each side Plot distribution as area (fill_between) + mean, median vertical bars. :param df1: `pandas.DataFram...
[ "Compare", "the", "distributions", "of", "two", "DataFrames", "giving", "visualisations", "of", ":", "-", "individual", "and", "combined", "distributions", "-", "distribution", "of", "non", "-", "common", "values", "-", "distribution", "of", "non", "-", "common"...
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L1438-L1491
mfitzp/padua
padua/visualize.py
kegg_pathway
def kegg_pathway(df, pathway, a, b=None, ids_from="Proteins", cmap=cm.PuOr_r, is_log2=False, fillna=None, z_score=1): """ Visualize data on a kegg pathway. :param df: :param pathway: :param a: :param b: :param ids_from: :param cmap: :param is_log2: :param fillna: :param z_s...
python
def kegg_pathway(df, pathway, a, b=None, ids_from="Proteins", cmap=cm.PuOr_r, is_log2=False, fillna=None, z_score=1): """ Visualize data on a kegg pathway. :param df: :param pathway: :param a: :param b: :param ids_from: :param cmap: :param is_log2: :param fillna: :param z_s...
[ "def", "kegg_pathway", "(", "df", ",", "pathway", ",", "a", ",", "b", "=", "None", ",", "ids_from", "=", "\"Proteins\"", ",", "cmap", "=", "cm", ".", "PuOr_r", ",", "is_log2", "=", "False", ",", "fillna", "=", "None", ",", "z_score", "=", "1", ")",...
Visualize data on a kegg pathway. :param df: :param pathway: :param a: :param b: :param ids_from: :param cmap: :param is_log2: :param fillna: :param z_score: :return:
[ "Visualize", "data", "on", "a", "kegg", "pathway", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L1495-L1605
mfitzp/padua
padua/visualize.py
hierarchical
def hierarchical(df, cluster_cols=True, cluster_rows=False, n_col_clusters=False, n_row_clusters=False, row_labels=True, col_labels=True, fcol=None, z_score=0, method='ward', cmap=cm.PuOr_r, return_clusters=False, rdistance_fn=distance.pdist, cdistance_fn=distance.pdist ): """ Hierarchical clustering of samples...
python
def hierarchical(df, cluster_cols=True, cluster_rows=False, n_col_clusters=False, n_row_clusters=False, row_labels=True, col_labels=True, fcol=None, z_score=0, method='ward', cmap=cm.PuOr_r, return_clusters=False, rdistance_fn=distance.pdist, cdistance_fn=distance.pdist ): """ Hierarchical clustering of samples...
[ "def", "hierarchical", "(", "df", ",", "cluster_cols", "=", "True", ",", "cluster_rows", "=", "False", ",", "n_col_clusters", "=", "False", ",", "n_row_clusters", "=", "False", ",", "row_labels", "=", "True", ",", "col_labels", "=", "True", ",", "fcol", "=...
Hierarchical clustering of samples or proteins Peform a hiearchical clustering on a pandas DataFrame and display the resulting clustering as a heatmap. The axis of clustering can be controlled with `cluster_cols` and `cluster_rows`. By default clustering is performed along the X-axis, therefore to clus...
[ "Hierarchical", "clustering", "of", "samples", "or", "proteins" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L1733-L1869
mfitzp/padua
padua/visualize.py
hierarchical_timecourse
def hierarchical_timecourse( df, cluster_cols=True, cluster_rows=False, n_col_clusters=False, n_row_clusters=False, fcol=None, z_score=0, method='ward', cmap=cm.PuOr_r, return_clusters=False, rdistance_fn=distance.pdist, cdi...
python
def hierarchical_timecourse( df, cluster_cols=True, cluster_rows=False, n_col_clusters=False, n_row_clusters=False, fcol=None, z_score=0, method='ward', cmap=cm.PuOr_r, return_clusters=False, rdistance_fn=distance.pdist, cdi...
[ "def", "hierarchical_timecourse", "(", "df", ",", "cluster_cols", "=", "True", ",", "cluster_rows", "=", "False", ",", "n_col_clusters", "=", "False", ",", "n_row_clusters", "=", "False", ",", "fcol", "=", "None", ",", "z_score", "=", "0", ",", "method", "...
Hierarchical clustering of samples across timecourse experiment. Peform a hiearchical clustering on a pandas DataFrame and display the resulting clustering as a timecourse density plot. Samples are z-scored along the 0-axis (y) by default. To override this use the `z_score` param with the axis to `z_score...
[ "Hierarchical", "clustering", "of", "samples", "across", "timecourse", "experiment", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L1872-L1965
mfitzp/padua
padua/normalization.py
subtract_column_median
def subtract_column_median(df, prefix='Intensity '): """ Apply column-wise normalisation to expression columns. Default is median transform to expression columns beginning with Intensity :param df: :param prefix: The column prefix for expression columns :return: """ df = df.copy() ...
python
def subtract_column_median(df, prefix='Intensity '): """ Apply column-wise normalisation to expression columns. Default is median transform to expression columns beginning with Intensity :param df: :param prefix: The column prefix for expression columns :return: """ df = df.copy() ...
[ "def", "subtract_column_median", "(", "df", ",", "prefix", "=", "'Intensity '", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "df", ".", "replace", "(", "[", "np", ".", "inf", ",", "-", "np", ".", "inf", "]", ",", "np", ".", "nan", ",", "in...
Apply column-wise normalisation to expression columns. Default is median transform to expression columns beginning with Intensity :param df: :param prefix: The column prefix for expression columns :return:
[ "Apply", "column", "-", "wise", "normalisation", "to", "expression", "columns", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/normalization.py#L4-L22
mfitzp/padua
padua/utils.py
qvalues
def qvalues(pv, m = None, verbose = False, lowmem = False, pi0 = None): """ Copyright (c) 2012, Nicolo Fusi, University of Sheffield All rights reserved. Estimates q-values from p-values Args ===== m: number of tests. If not specified m = pv.size verbose: print verbose messages? (defa...
python
def qvalues(pv, m = None, verbose = False, lowmem = False, pi0 = None): """ Copyright (c) 2012, Nicolo Fusi, University of Sheffield All rights reserved. Estimates q-values from p-values Args ===== m: number of tests. If not specified m = pv.size verbose: print verbose messages? (defa...
[ "def", "qvalues", "(", "pv", ",", "m", "=", "None", ",", "verbose", "=", "False", ",", "lowmem", "=", "False", ",", "pi0", "=", "None", ")", ":", "assert", "(", "pv", ".", "min", "(", ")", ">=", "0", "and", "pv", ".", "max", "(", ")", "<=", ...
Copyright (c) 2012, Nicolo Fusi, University of Sheffield All rights reserved. Estimates q-values from p-values Args ===== m: number of tests. If not specified m = pv.size verbose: print verbose messages? (default False) lowmem: use memory-efficient in-place algorithm pi0: if None, it'...
[ "Copyright", "(", "c", ")", "2012", "Nicolo", "Fusi", "University", "of", "Sheffield", "All", "rights", "reserved", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/utils.py#L8-L105
mfitzp/padua
padua/utils.py
get_protein_id_list
def get_protein_id_list(df, level=0): """ Return a complete list of shortform IDs from a DataFrame Extract all protein IDs from a dataframe from multiple rows containing protein IDs in MaxQuant output format: e.g. P07830;P63267;Q54A44;P63268 Long names (containing species information) are eliminat...
python
def get_protein_id_list(df, level=0): """ Return a complete list of shortform IDs from a DataFrame Extract all protein IDs from a dataframe from multiple rows containing protein IDs in MaxQuant output format: e.g. P07830;P63267;Q54A44;P63268 Long names (containing species information) are eliminat...
[ "def", "get_protein_id_list", "(", "df", ",", "level", "=", "0", ")", ":", "protein_list", "=", "[", "]", "for", "s", "in", "df", ".", "index", ".", "get_level_values", "(", "level", ")", ":", "protein_list", ".", "extend", "(", "get_protein_ids", "(", ...
Return a complete list of shortform IDs from a DataFrame Extract all protein IDs from a dataframe from multiple rows containing protein IDs in MaxQuant output format: e.g. P07830;P63267;Q54A44;P63268 Long names (containing species information) are eliminated (split on ' ') and isoforms are removed (sp...
[ "Return", "a", "complete", "list", "of", "shortform", "IDs", "from", "a", "DataFrame" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/utils.py#L142-L162
mfitzp/padua
padua/utils.py
format_label
def format_label(sl, fmt=None): """ Combine a list of strings to a single str, joined by sep. Passes through single strings. :param sl: :return: """ if isinstance(sl, str): # Already is a string. return sl if fmt: return fmt.format(*sl) return ' '.join(str(s...
python
def format_label(sl, fmt=None): """ Combine a list of strings to a single str, joined by sep. Passes through single strings. :param sl: :return: """ if isinstance(sl, str): # Already is a string. return sl if fmt: return fmt.format(*sl) return ' '.join(str(s...
[ "def", "format_label", "(", "sl", ",", "fmt", "=", "None", ")", ":", "if", "isinstance", "(", "sl", ",", "str", ")", ":", "# Already is a string.", "return", "sl", "if", "fmt", ":", "return", "fmt", ".", "format", "(", "*", "sl", ")", "return", "' '"...
Combine a list of strings to a single str, joined by sep. Passes through single strings. :param sl: :return:
[ "Combine", "a", "list", "of", "strings", "to", "a", "single", "str", "joined", "by", "sep", ".", "Passes", "through", "single", "strings", ".", ":", "param", "sl", ":", ":", "return", ":" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/utils.py#L191-L205
mfitzp/padua
padua/utils.py
build_combined_label
def build_combined_label(sl, idxs, sep=' ', label_format=None): """ Generate a combined label from a list of indexes into sl, by joining them with `sep` (str). :param sl: Strings to combine :type sl: dict of str :param idxs: Indexes into sl :type idxs: list of sl keys :param sep: :...
python
def build_combined_label(sl, idxs, sep=' ', label_format=None): """ Generate a combined label from a list of indexes into sl, by joining them with `sep` (str). :param sl: Strings to combine :type sl: dict of str :param idxs: Indexes into sl :type idxs: list of sl keys :param sep: :...
[ "def", "build_combined_label", "(", "sl", ",", "idxs", ",", "sep", "=", "' '", ",", "label_format", "=", "None", ")", ":", "if", "label_format", ":", "return", "label_format", "%", "tuple", "(", "[", "get_shortstr", "(", "str", "(", "sl", "[", "n", "]"...
Generate a combined label from a list of indexes into sl, by joining them with `sep` (str). :param sl: Strings to combine :type sl: dict of str :param idxs: Indexes into sl :type idxs: list of sl keys :param sep: :return: `str` of combined label
[ "Generate", "a", "combined", "label", "from", "a", "list", "of", "indexes", "into", "sl", "by", "joining", "them", "with", "sep", "(", "str", ")", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/utils.py#L208-L225
mfitzp/padua
padua/utils.py
hierarchical_match
def hierarchical_match(d, k, default=None): """ Match a key against a dict, simplifying element at a time :param df: DataFrame :type df: pandas.DataFrame :param level: Level of DataFrame index to extract IDs from :type level: int or str :return: hiearchically matched value or default "...
python
def hierarchical_match(d, k, default=None): """ Match a key against a dict, simplifying element at a time :param df: DataFrame :type df: pandas.DataFrame :param level: Level of DataFrame index to extract IDs from :type level: int or str :return: hiearchically matched value or default "...
[ "def", "hierarchical_match", "(", "d", ",", "k", ",", "default", "=", "None", ")", ":", "if", "d", "is", "None", ":", "return", "default", "if", "type", "(", "k", ")", "!=", "list", "and", "type", "(", "k", ")", "!=", "tuple", ":", "k", "=", "[...
Match a key against a dict, simplifying element at a time :param df: DataFrame :type df: pandas.DataFrame :param level: Level of DataFrame index to extract IDs from :type level: int or str :return: hiearchically matched value or default
[ "Match", "a", "key", "against", "a", "dict", "simplifying", "element", "at", "a", "time" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/utils.py#L228-L256
mfitzp/padua
padua/utils.py
chunks
def chunks(seq, num): """ Separate `seq` (`np.array`) into `num` series of as-near-as possible equal length values. :param seq: Sequence to split :type seq: np.array :param num: Number of parts to split sequence into :type num: int :return: np.array of split parts """ avg = len...
python
def chunks(seq, num): """ Separate `seq` (`np.array`) into `num` series of as-near-as possible equal length values. :param seq: Sequence to split :type seq: np.array :param num: Number of parts to split sequence into :type num: int :return: np.array of split parts """ avg = len...
[ "def", "chunks", "(", "seq", ",", "num", ")", ":", "avg", "=", "len", "(", "seq", ")", "/", "float", "(", "num", ")", "out", "=", "[", "]", "last", "=", "0.0", "while", "last", "<", "len", "(", "seq", ")", ":", "out", ".", "append", "(", "s...
Separate `seq` (`np.array`) into `num` series of as-near-as possible equal length values. :param seq: Sequence to split :type seq: np.array :param num: Number of parts to split sequence into :type num: int :return: np.array of split parts
[ "Separate", "seq", "(", "np", ".", "array", ")", "into", "num", "series", "of", "as", "-", "near", "-", "as", "possible", "equal", "length", "values", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/utils.py#L259-L279
mfitzp/padua
padua/utils.py
calculate_s0_curve
def calculate_s0_curve(s0, minpval, maxpval, minratio, maxratio, curve_interval=0.1): """ Calculate s0 curve for volcano plot. Taking an min and max p value, and a min and max ratio, calculate an smooth curve starting from parameter `s0` in each direction. The `curve_interval` parameter defines th...
python
def calculate_s0_curve(s0, minpval, maxpval, minratio, maxratio, curve_interval=0.1): """ Calculate s0 curve for volcano plot. Taking an min and max p value, and a min and max ratio, calculate an smooth curve starting from parameter `s0` in each direction. The `curve_interval` parameter defines th...
[ "def", "calculate_s0_curve", "(", "s0", ",", "minpval", ",", "maxpval", ",", "minratio", ",", "maxratio", ",", "curve_interval", "=", "0.1", ")", ":", "mminpval", "=", "-", "np", ".", "log10", "(", "minpval", ")", "mmaxpval", "=", "-", "np", ".", "log1...
Calculate s0 curve for volcano plot. Taking an min and max p value, and a min and max ratio, calculate an smooth curve starting from parameter `s0` in each direction. The `curve_interval` parameter defines the smoothness of the resulting curve. :param s0: `float` offset of curve from interset :pa...
[ "Calculate", "s0", "curve", "for", "volcano", "plot", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/utils.py#L282-L317
mfitzp/padua
padua/analysis.py
correlation
def correlation(df, rowvar=False): """ Calculate column-wise Pearson correlations using ``numpy.ma.corrcoef`` Input data is masked to ignore NaNs when calculating correlations. Data is returned as a Pandas ``DataFrame`` of column_n x column_n dimensions, with column index copied to both axes. ...
python
def correlation(df, rowvar=False): """ Calculate column-wise Pearson correlations using ``numpy.ma.corrcoef`` Input data is masked to ignore NaNs when calculating correlations. Data is returned as a Pandas ``DataFrame`` of column_n x column_n dimensions, with column index copied to both axes. ...
[ "def", "correlation", "(", "df", ",", "rowvar", "=", "False", ")", ":", "# Create a correlation matrix for all correlations", "# of the columns (filled with na for all values)", "df", "=", "df", ".", "copy", "(", ")", "maskv", "=", "np", ".", "ma", ".", "masked_wher...
Calculate column-wise Pearson correlations using ``numpy.ma.corrcoef`` Input data is masked to ignore NaNs when calculating correlations. Data is returned as a Pandas ``DataFrame`` of column_n x column_n dimensions, with column index copied to both axes. :param df: Pandas DataFrame :return: Pandas...
[ "Calculate", "column", "-", "wise", "Pearson", "correlations", "using", "numpy", ".", "ma", ".", "corrcoef" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L26-L48
mfitzp/padua
padua/analysis.py
pca
def pca(df, n_components=2, mean_center=False, **kwargs): """ Principal Component Analysis, based on `sklearn.decomposition.PCA` Performs a principal component analysis (PCA) on the supplied dataframe, selecting the first ``n_components`` components in the resulting model. The model scores and weights ...
python
def pca(df, n_components=2, mean_center=False, **kwargs): """ Principal Component Analysis, based on `sklearn.decomposition.PCA` Performs a principal component analysis (PCA) on the supplied dataframe, selecting the first ``n_components`` components in the resulting model. The model scores and weights ...
[ "def", "pca", "(", "df", ",", "n_components", "=", "2", ",", "mean_center", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "not", "sklearn", ":", "assert", "(", "'This library depends on scikit-learn (sklearn) to perform PCA analysis'", ")", "from", "skl...
Principal Component Analysis, based on `sklearn.decomposition.PCA` Performs a principal component analysis (PCA) on the supplied dataframe, selecting the first ``n_components`` components in the resulting model. The model scores and weights are returned. For more information on PCA and the algorithm used,...
[ "Principal", "Component", "Analysis", "based", "on", "sklearn", ".", "decomposition", ".", "PCA" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L51-L93
mfitzp/padua
padua/analysis.py
plsda
def plsda(df, a, b, n_components=2, mean_center=False, scale=True, **kwargs): """ Partial Least Squares Discriminant Analysis, based on `sklearn.cross_decomposition.PLSRegression` Performs a binary group partial least squares discriminant analysis (PLS-DA) on the supplied dataframe, selecting the first...
python
def plsda(df, a, b, n_components=2, mean_center=False, scale=True, **kwargs): """ Partial Least Squares Discriminant Analysis, based on `sklearn.cross_decomposition.PLSRegression` Performs a binary group partial least squares discriminant analysis (PLS-DA) on the supplied dataframe, selecting the first...
[ "def", "plsda", "(", "df", ",", "a", ",", "b", ",", "n_components", "=", "2", ",", "mean_center", "=", "False", ",", "scale", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "not", "sklearn", ":", "assert", "(", "'This library depends on scikit-l...
Partial Least Squares Discriminant Analysis, based on `sklearn.cross_decomposition.PLSRegression` Performs a binary group partial least squares discriminant analysis (PLS-DA) on the supplied dataframe, selecting the first ``n_components``. Sample groups are defined by the selectors ``a`` and ``b`` which a...
[ "Partial", "Least", "Squares", "Discriminant", "Analysis", "based", "on", "sklearn", ".", "cross_decomposition", ".", "PLSRegression" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L96-L161
mfitzp/padua
padua/analysis.py
plsr
def plsr(df, v, n_components=2, mean_center=False, scale=True, **kwargs): """ Partial Least Squares Regression Analysis, based on `sklearn.cross_decomposition.PLSRegression` Performs a partial least squares regression (PLS-R) on the supplied dataframe ``df`` against the provided continuous variable ``v...
python
def plsr(df, v, n_components=2, mean_center=False, scale=True, **kwargs): """ Partial Least Squares Regression Analysis, based on `sklearn.cross_decomposition.PLSRegression` Performs a partial least squares regression (PLS-R) on the supplied dataframe ``df`` against the provided continuous variable ``v...
[ "def", "plsr", "(", "df", ",", "v", ",", "n_components", "=", "2", ",", "mean_center", "=", "False", ",", "scale", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "not", "sklearn", ":", "assert", "(", "'This library depends on scikit-learn (sklearn) ...
Partial Least Squares Regression Analysis, based on `sklearn.cross_decomposition.PLSRegression` Performs a partial least squares regression (PLS-R) on the supplied dataframe ``df`` against the provided continuous variable ``v``, selecting the first ``n_components``. For more information on PLS regression ...
[ "Partial", "Least", "Squares", "Regression", "Analysis", "based", "on", "sklearn", ".", "cross_decomposition", ".", "PLSRegression" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L164-L216
mfitzp/padua
padua/analysis.py
enrichment_from_evidence
def enrichment_from_evidence(dfe, modification="Phospho (STY)"): """ Calculate relative enrichment of peptide modifications from evidence.txt. Taking a modifiedsitepeptides ``DataFrame`` returns the relative enrichment of the specified modification in the table. The returned data columns are gener...
python
def enrichment_from_evidence(dfe, modification="Phospho (STY)"): """ Calculate relative enrichment of peptide modifications from evidence.txt. Taking a modifiedsitepeptides ``DataFrame`` returns the relative enrichment of the specified modification in the table. The returned data columns are gener...
[ "def", "enrichment_from_evidence", "(", "dfe", ",", "modification", "=", "\"Phospho (STY)\"", ")", ":", "dfe", "=", "dfe", ".", "reset_index", "(", ")", ".", "set_index", "(", "'Experiment'", ")", "dfe", "[", "'Modifications'", "]", "=", "np", ".", "array", ...
Calculate relative enrichment of peptide modifications from evidence.txt. Taking a modifiedsitepeptides ``DataFrame`` returns the relative enrichment of the specified modification in the table. The returned data columns are generated from the input data columns. :param df: Pandas ``DataFrame`` of evi...
[ "Calculate", "relative", "enrichment", "of", "peptide", "modifications", "from", "evidence", ".", "txt", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L232-L258
mfitzp/padua
padua/analysis.py
enrichment_from_msp
def enrichment_from_msp(dfmsp, modification="Phospho (STY)"): """ Calculate relative enrichment of peptide modifications from modificationSpecificPeptides.txt. Taking a modifiedsitepeptides ``DataFrame`` returns the relative enrichment of the specified modification in the table. The returned data ...
python
def enrichment_from_msp(dfmsp, modification="Phospho (STY)"): """ Calculate relative enrichment of peptide modifications from modificationSpecificPeptides.txt. Taking a modifiedsitepeptides ``DataFrame`` returns the relative enrichment of the specified modification in the table. The returned data ...
[ "def", "enrichment_from_msp", "(", "dfmsp", ",", "modification", "=", "\"Phospho (STY)\"", ")", ":", "dfmsp", "[", "'Modifications'", "]", "=", "np", ".", "array", "(", "[", "modification", "in", "m", "for", "m", "in", "dfmsp", "[", "'Modifications'", "]", ...
Calculate relative enrichment of peptide modifications from modificationSpecificPeptides.txt. Taking a modifiedsitepeptides ``DataFrame`` returns the relative enrichment of the specified modification in the table. The returned data columns are generated from the input data columns. :param df: Pandas ...
[ "Calculate", "relative", "enrichment", "of", "peptide", "modifications", "from", "modificationSpecificPeptides", ".", "txt", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L263-L287
mfitzp/padua
padua/analysis.py
sitespeptidesproteins
def sitespeptidesproteins(df, site_localization_probability=0.75): """ Generate summary count of modified sites, peptides and proteins in a processed dataset ``DataFrame``. Returns the number of sites, peptides and proteins as calculated as follows: - `sites` (>0.75; or specified site localization pro...
python
def sitespeptidesproteins(df, site_localization_probability=0.75): """ Generate summary count of modified sites, peptides and proteins in a processed dataset ``DataFrame``. Returns the number of sites, peptides and proteins as calculated as follows: - `sites` (>0.75; or specified site localization pro...
[ "def", "sitespeptidesproteins", "(", "df", ",", "site_localization_probability", "=", "0.75", ")", ":", "sites", "=", "filters", ".", "filter_localization_probability", "(", "df", ",", "site_localization_probability", ")", "[", "'Sequence window'", "]", "peptides", "=...
Generate summary count of modified sites, peptides and proteins in a processed dataset ``DataFrame``. Returns the number of sites, peptides and proteins as calculated as follows: - `sites` (>0.75; or specified site localization probability) count of all sites > threshold - `peptides` the set of `Sequence ...
[ "Generate", "summary", "count", "of", "modified", "sites", "peptides", "and", "proteins", "in", "a", "processed", "dataset", "DataFrame", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L291-L309
mfitzp/padua
padua/analysis.py
modifiedaminoacids
def modifiedaminoacids(df): """ Calculate the number of modified amino acids in supplied ``DataFrame``. Returns the total of all modifications and the total for each amino acid individually, as an ``int`` and a ``dict`` of ``int``, keyed by amino acid, respectively. :param df: Pandas ``DataFrame``...
python
def modifiedaminoacids(df): """ Calculate the number of modified amino acids in supplied ``DataFrame``. Returns the total of all modifications and the total for each amino acid individually, as an ``int`` and a ``dict`` of ``int``, keyed by amino acid, respectively. :param df: Pandas ``DataFrame``...
[ "def", "modifiedaminoacids", "(", "df", ")", ":", "amino_acids", "=", "list", "(", "df", "[", "'Amino acid'", "]", ".", "values", ")", "aas", "=", "set", "(", "amino_acids", ")", "quants", "=", "{", "}", "for", "aa", "in", "aas", ":", "quants", "[", ...
Calculate the number of modified amino acids in supplied ``DataFrame``. Returns the total of all modifications and the total for each amino acid individually, as an ``int`` and a ``dict`` of ``int``, keyed by amino acid, respectively. :param df: Pandas ``DataFrame`` containing processed data. :return:...
[ "Calculate", "the", "number", "of", "modified", "amino", "acids", "in", "supplied", "DataFrame", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L312-L333
mfitzp/padua
padua/analysis.py
go_enrichment
def go_enrichment(df, enrichment='function', organism='Homo sapiens', summary=True, fdr=0.05, ids_from=['Proteins','Protein IDs']): """ Calculate gene ontology (GO) enrichment for a specified set of indices, using the PantherDB GO enrichment service. Provided with a processed data ``DataFrame`` will calcul...
python
def go_enrichment(df, enrichment='function', organism='Homo sapiens', summary=True, fdr=0.05, ids_from=['Proteins','Protein IDs']): """ Calculate gene ontology (GO) enrichment for a specified set of indices, using the PantherDB GO enrichment service. Provided with a processed data ``DataFrame`` will calcul...
[ "def", "go_enrichment", "(", "df", ",", "enrichment", "=", "'function'", ",", "organism", "=", "'Homo sapiens'", ",", "summary", "=", "True", ",", "fdr", "=", "0.05", ",", "ids_from", "=", "[", "'Proteins'", ",", "'Protein IDs'", "]", ")", ":", "if", "is...
Calculate gene ontology (GO) enrichment for a specified set of indices, using the PantherDB GO enrichment service. Provided with a processed data ``DataFrame`` will calculate the GO ontology enrichment specified by `enrichment`, for the specified `organism`. The IDs to use for genes are taken from the field `i...
[ "Calculate", "gene", "ontology", "(", "GO", ")", "enrichment", "for", "a", "specified", "set", "of", "indices", "using", "the", "PantherDB", "GO", "enrichment", "service", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L336-L384
mfitzp/padua
padua/analysis.py
anova_1way
def anova_1way(df, *args, **kwargs): """ Perform Analysis of Variation (ANOVA) on provided dataframe and for specified groups. Groups for analysis can be specified as individual arguments, e.g. anova(df, "Group A", "Group B") anova(df, ("Group A", 5), ("Group B", 5)) At least 2 gro...
python
def anova_1way(df, *args, **kwargs): """ Perform Analysis of Variation (ANOVA) on provided dataframe and for specified groups. Groups for analysis can be specified as individual arguments, e.g. anova(df, "Group A", "Group B") anova(df, ("Group A", 5), ("Group B", 5)) At least 2 gro...
[ "def", "anova_1way", "(", "df", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", "<", "2", ":", "raise", "Exception", "(", "\"Not enough arguments. Provide at least two group/indexes for comparison.\"", ")", "# Select columns for...
Perform Analysis of Variation (ANOVA) on provided dataframe and for specified groups. Groups for analysis can be specified as individual arguments, e.g. anova(df, "Group A", "Group B") anova(df, ("Group A", 5), ("Group B", 5)) At least 2 groups must be provided. :return: Dataframe...
[ "Perform", "Analysis", "of", "Variation", "(", "ANOVA", ")", "on", "provided", "dataframe", "and", "for", "specified", "groups", ".", "Groups", "for", "analysis", "can", "be", "specified", "as", "individual", "arguments", "e", ".", "g", ".", "anova", "(", ...
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L387-L432
mfitzp/padua
padua/process.py
build_index_from_design
def build_index_from_design(df, design, remove_prefix=None, types=None, axis=1, auto_convert_numeric=True, unmatched_columns='index'): """ Build a MultiIndex from a design table. Supply with a table with column headings for the new multiindex and a index containing the labels to search for in the data....
python
def build_index_from_design(df, design, remove_prefix=None, types=None, axis=1, auto_convert_numeric=True, unmatched_columns='index'): """ Build a MultiIndex from a design table. Supply with a table with column headings for the new multiindex and a index containing the labels to search for in the data....
[ "def", "build_index_from_design", "(", "df", ",", "design", ",", "remove_prefix", "=", "None", ",", "types", "=", "None", ",", "axis", "=", "1", ",", "auto_convert_numeric", "=", "True", ",", "unmatched_columns", "=", "'index'", ")", ":", "df", "=", "df", ...
Build a MultiIndex from a design table. Supply with a table with column headings for the new multiindex and a index containing the labels to search for in the data. :param df: :param design: :param remove: :param types: :param axis: :param auto_convert_numeric: :return:
[ "Build", "a", "MultiIndex", "from", "a", "design", "table", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/process.py#L23-L111
mfitzp/padua
padua/process.py
build_index_from_labels
def build_index_from_labels(df, indices, remove_prefix=None, types=None, axis=1): """ Build a MultiIndex from a list of labels and matching regex Supply with a dictionary of Hierarchy levels and matching regex to extract this level from the sample label :param df: :param indices: Tuples of ind...
python
def build_index_from_labels(df, indices, remove_prefix=None, types=None, axis=1): """ Build a MultiIndex from a list of labels and matching regex Supply with a dictionary of Hierarchy levels and matching regex to extract this level from the sample label :param df: :param indices: Tuples of ind...
[ "def", "build_index_from_labels", "(", "df", ",", "indices", ",", "remove_prefix", "=", "None", ",", "types", "=", "None", ",", "axis", "=", "1", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "if", "remove_prefix", "is", "None", ":", "remove_prefix...
Build a MultiIndex from a list of labels and matching regex Supply with a dictionary of Hierarchy levels and matching regex to extract this level from the sample label :param df: :param indices: Tuples of indices ('label','regex') matches :param strip: Strip these strings from labels before matchi...
[ "Build", "a", "MultiIndex", "from", "a", "list", "of", "labels", "and", "matching", "regex" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/process.py#L114-L165
mfitzp/padua
padua/process.py
combine_expression_columns
def combine_expression_columns(df, columns_to_combine, remove_combined=True): """ Combine expression columns, calculating the mean for 2 columns :param df: Pandas dataframe :param columns_to_combine: A list of tuples containing the column names to combine :return: """ df = df.copy() ...
python
def combine_expression_columns(df, columns_to_combine, remove_combined=True): """ Combine expression columns, calculating the mean for 2 columns :param df: Pandas dataframe :param columns_to_combine: A list of tuples containing the column names to combine :return: """ df = df.copy() ...
[ "def", "combine_expression_columns", "(", "df", ",", "columns_to_combine", ",", "remove_combined", "=", "True", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "for", "ca", ",", "cb", "in", "columns_to_combine", ":", "df", "[", "\"%s_(x+y)/2_%s\"", "%", ...
Combine expression columns, calculating the mean for 2 columns :param df: Pandas dataframe :param columns_to_combine: A list of tuples containing the column names to combine :return:
[ "Combine", "expression", "columns", "calculating", "the", "mean", "for", "2", "columns" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/process.py#L198-L218
mfitzp/padua
padua/process.py
expand_side_table
def expand_side_table(df): """ Perform equivalent of 'expand side table' in Perseus by folding Multiplicity columns down onto duplicate rows The id is remapped to UID___Multiplicity, which is different to Perseus behaviour, but prevents accidental of non-matching rows from occurring later in an...
python
def expand_side_table(df): """ Perform equivalent of 'expand side table' in Perseus by folding Multiplicity columns down onto duplicate rows The id is remapped to UID___Multiplicity, which is different to Perseus behaviour, but prevents accidental of non-matching rows from occurring later in an...
[ "def", "expand_side_table", "(", "df", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "idx", "=", "df", ".", "index", ".", "names", "df", ".", "reset_index", "(", "inplace", "=", "True", ")", "def", "strip_multiplicity", "(", "df", ")", ":", "df...
Perform equivalent of 'expand side table' in Perseus by folding Multiplicity columns down onto duplicate rows The id is remapped to UID___Multiplicity, which is different to Perseus behaviour, but prevents accidental of non-matching rows from occurring later in analysis. :param df: :return:
[ "Perform", "equivalent", "of", "expand", "side", "table", "in", "Perseus", "by", "folding", "Multiplicity", "columns", "down", "onto", "duplicate", "rows" ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/process.py#L221-L277
mfitzp/padua
padua/process.py
apply_experimental_design
def apply_experimental_design(df, f, prefix='Intensity '): """ Load the experimental design template from MaxQuant and use it to apply the label names to the data columns. :param df: :param f: File path for the experimental design template :param prefix: :return: dt """ df = df.copy() ...
python
def apply_experimental_design(df, f, prefix='Intensity '): """ Load the experimental design template from MaxQuant and use it to apply the label names to the data columns. :param df: :param f: File path for the experimental design template :param prefix: :return: dt """ df = df.copy() ...
[ "def", "apply_experimental_design", "(", "df", ",", "f", ",", "prefix", "=", "'Intensity '", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "edt", "=", "pd", ".", "read_csv", "(", "f", ",", "sep", "=", "'\\t'", ",", "header", "=", "0", ")", "e...
Load the experimental design template from MaxQuant and use it to apply the label names to the data columns. :param df: :param f: File path for the experimental design template :param prefix: :return: dt
[ "Load", "the", "experimental", "design", "template", "from", "MaxQuant", "and", "use", "it", "to", "apply", "the", "label", "names", "to", "the", "data", "columns", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/process.py#L280-L306
mfitzp/padua
padua/process.py
transform_expression_columns
def transform_expression_columns(df, fn=np.log2, prefix='Intensity '): """ Apply transformation to expression columns. Default is log2 transform to expression columns beginning with Intensity :param df: :param prefix: The column prefix for expression columns :return: """ df = df.copy(...
python
def transform_expression_columns(df, fn=np.log2, prefix='Intensity '): """ Apply transformation to expression columns. Default is log2 transform to expression columns beginning with Intensity :param df: :param prefix: The column prefix for expression columns :return: """ df = df.copy(...
[ "def", "transform_expression_columns", "(", "df", ",", "fn", "=", "np", ".", "log2", ",", "prefix", "=", "'Intensity '", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "mask", "=", "np", ".", "array", "(", "[", "l", ".", "startswith", "(", "pref...
Apply transformation to expression columns. Default is log2 transform to expression columns beginning with Intensity :param df: :param prefix: The column prefix for expression columns :return:
[ "Apply", "transformation", "to", "expression", "columns", "." ]
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/process.py#L309-L327
mfitzp/padua
padua/process.py
fold_columns_to_rows
def fold_columns_to_rows(df, levels_from=2): """ Take a levels from the columns and fold down into the row index. This destroys the existing index; existing rows will appear as columns under the new column index :param df: :param levels_from: The level (inclusive) from which column index will b...
python
def fold_columns_to_rows(df, levels_from=2): """ Take a levels from the columns and fold down into the row index. This destroys the existing index; existing rows will appear as columns under the new column index :param df: :param levels_from: The level (inclusive) from which column index will b...
[ "def", "fold_columns_to_rows", "(", "df", ",", "levels_from", "=", "2", ")", ":", "df", "=", "df", ".", "copy", "(", ")", "df", ".", "reset_index", "(", "inplace", "=", "True", ",", "drop", "=", "True", ")", "# Wipe out the current index", "df", "=", "...
Take a levels from the columns and fold down into the row index. This destroys the existing index; existing rows will appear as columns under the new column index :param df: :param levels_from: The level (inclusive) from which column index will be folded :return:
[ "Take", "a", "levels", "from", "the", "columns", "and", "fold", "down", "into", "the", "row", "index", ".", "This", "destroys", "the", "existing", "index", ";", "existing", "rows", "will", "appear", "as", "columns", "under", "the", "new", "column", "index"...
train
https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/process.py#L330-L377
ECRL/ecabc
ecabc/abc.py
ABC.add_argument
def add_argument(self, arg_name, arg_value): '''Add an additional argument to be passed to the fitness function via additional arguments dictionary; this argument/value is not tuned Args: arg_name (string): name/dictionary key of argument arg_value (any): dictionary valu...
python
def add_argument(self, arg_name, arg_value): '''Add an additional argument to be passed to the fitness function via additional arguments dictionary; this argument/value is not tuned Args: arg_name (string): name/dictionary key of argument arg_value (any): dictionary valu...
[ "def", "add_argument", "(", "self", ",", "arg_name", ",", "arg_value", ")", ":", "if", "len", "(", "self", ".", "_employers", ")", ">", "0", ":", "self", ".", "_logger", ".", "log", "(", "'warn'", ",", "'Adding an argument after the employers have been created...
Add an additional argument to be passed to the fitness function via additional arguments dictionary; this argument/value is not tuned Args: arg_name (string): name/dictionary key of argument arg_value (any): dictionary value of argument
[ "Add", "an", "additional", "argument", "to", "be", "passed", "to", "the", "fitness", "function", "via", "additional", "arguments", "dictionary", ";", "this", "argument", "/", "value", "is", "not", "tuned" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L96-L112
ECRL/ecabc
ecabc/abc.py
ABC.add_value
def add_value(self, value_type, value_min, value_max): '''Add a tunable value to the ABC (fitness function must be configured to handle it) Args: value_type (string): type of the value, 'int' or 'float' value_min (int or float): minimum bound for the value va...
python
def add_value(self, value_type, value_min, value_max): '''Add a tunable value to the ABC (fitness function must be configured to handle it) Args: value_type (string): type of the value, 'int' or 'float' value_min (int or float): minimum bound for the value va...
[ "def", "add_value", "(", "self", ",", "value_type", ",", "value_min", ",", "value_max", ")", ":", "if", "len", "(", "self", ".", "_employers", ")", ">", "0", ":", "self", ".", "_logger", ".", "log", "(", "'warn'", ",", "'Adding a value after employers have...
Add a tunable value to the ABC (fitness function must be configured to handle it) Args: value_type (string): type of the value, 'int' or 'float' value_min (int or float): minimum bound for the value value_max (int or float): maximum bound for the value Retur...
[ "Add", "a", "tunable", "value", "to", "the", "ABC", "(", "fitness", "function", "must", "be", "configured", "to", "handle", "it", ")" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L114-L138
ECRL/ecabc
ecabc/abc.py
ABC.args
def args(self, args): '''Set additional arguments to be passed to the fitness function Args: args (dict): additional arguments ''' self._args = args self._logger.log('debug', 'Args set to {}'.format(args))
python
def args(self, args): '''Set additional arguments to be passed to the fitness function Args: args (dict): additional arguments ''' self._args = args self._logger.log('debug', 'Args set to {}'.format(args))
[ "def", "args", "(", "self", ",", "args", ")", ":", "self", ".", "_args", "=", "args", "self", ".", "_logger", ".", "log", "(", "'debug'", ",", "'Args set to {}'", ".", "format", "(", "args", ")", ")" ]
Set additional arguments to be passed to the fitness function Args: args (dict): additional arguments
[ "Set", "additional", "arguments", "to", "be", "passed", "to", "the", "fitness", "function" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L147-L154
ECRL/ecabc
ecabc/abc.py
ABC.minimize
def minimize(self, minimize): '''Configures the ABC to minimize fitness function return value or derived score Args: minimize (bool): if True, minimizes fitness function return value; if False, minimizes derived score ''' self._minimize = minimize ...
python
def minimize(self, minimize): '''Configures the ABC to minimize fitness function return value or derived score Args: minimize (bool): if True, minimizes fitness function return value; if False, minimizes derived score ''' self._minimize = minimize ...
[ "def", "minimize", "(", "self", ",", "minimize", ")", ":", "self", ".", "_minimize", "=", "minimize", "self", ".", "_logger", ".", "log", "(", "'debug'", ",", "'Minimize set to {}'", ".", "format", "(", "minimize", ")", ")" ]
Configures the ABC to minimize fitness function return value or derived score Args: minimize (bool): if True, minimizes fitness function return value; if False, minimizes derived score
[ "Configures", "the", "ABC", "to", "minimize", "fitness", "function", "return", "value", "or", "derived", "score" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L165-L175
ECRL/ecabc
ecabc/abc.py
ABC.num_employers
def num_employers(self, num_employers): '''Sets the number of employer bees; at least two are required Args: num_employers (int): number of employer bees ''' if num_employers < 2: self._logger.log( 'warn', 'Two employers are neede...
python
def num_employers(self, num_employers): '''Sets the number of employer bees; at least two are required Args: num_employers (int): number of employer bees ''' if num_employers < 2: self._logger.log( 'warn', 'Two employers are neede...
[ "def", "num_employers", "(", "self", ",", "num_employers", ")", ":", "if", "num_employers", "<", "2", ":", "self", ".", "_logger", ".", "log", "(", "'warn'", ",", "'Two employers are needed: setting to two'", ")", "num_employers", "=", "2", "self", ".", "_num_...
Sets the number of employer bees; at least two are required Args: num_employers (int): number of employer bees
[ "Sets", "the", "number", "of", "employer", "bees", ";", "at", "least", "two", "are", "required" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L184-L202
ECRL/ecabc
ecabc/abc.py
ABC.value_ranges
def value_ranges(self, value_ranges): '''Set the types, min/max values for tunable parameters Args: value_ranges (list): each element defines a tunable variable in the form "(type ('int' or 'float'), (min_val, max_val))"; initial, random values for each bee w...
python
def value_ranges(self, value_ranges): '''Set the types, min/max values for tunable parameters Args: value_ranges (list): each element defines a tunable variable in the form "(type ('int' or 'float'), (min_val, max_val))"; initial, random values for each bee w...
[ "def", "value_ranges", "(", "self", ",", "value_ranges", ")", ":", "self", ".", "_value_ranges", "=", "value_ranges", "self", ".", "_logger", ".", "log", "(", "'debug'", ",", "'Value ranges set to {}'", ".", "format", "(", "value_ranges", ")", ")" ]
Set the types, min/max values for tunable parameters Args: value_ranges (list): each element defines a tunable variable in the form "(type ('int' or 'float'), (min_val, max_val))"; initial, random values for each bee will between "min_val" and "max_va...
[ "Set", "the", "types", "min", "/", "max", "values", "for", "tunable", "parameters" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L211-L224
ECRL/ecabc
ecabc/abc.py
ABC.processes
def processes(self, processes): '''Set the number of concurrent processes the ABC will utilize for fitness function evaluation; if <= 1, single process is used Args: processes (int): number of concurrent processes ''' if self._processes > 1: self._pool.c...
python
def processes(self, processes): '''Set the number of concurrent processes the ABC will utilize for fitness function evaluation; if <= 1, single process is used Args: processes (int): number of concurrent processes ''' if self._processes > 1: self._pool.c...
[ "def", "processes", "(", "self", ",", "processes", ")", ":", "if", "self", ".", "_processes", ">", "1", ":", "self", ".", "_pool", ".", "close", "(", ")", "self", ".", "_pool", ".", "join", "(", ")", "self", ".", "_pool", "=", "multiprocessing", "....
Set the number of concurrent processes the ABC will utilize for fitness function evaluation; if <= 1, single process is used Args: processes (int): number of concurrent processes
[ "Set", "the", "number", "of", "concurrent", "processes", "the", "ABC", "will", "utilize", "for", "fitness", "function", "evaluation", ";", "if", "<", "=", "1", "single", "process", "is", "used" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L268-L284
ECRL/ecabc
ecabc/abc.py
ABC.infer_process_count
def infer_process_count(self): '''Infers the number of CPU cores in the current system, sets the number of concurrent processes accordingly ''' try: self.processes = multiprocessing.cpu_count() except NotImplementedError: self._logger.log( ...
python
def infer_process_count(self): '''Infers the number of CPU cores in the current system, sets the number of concurrent processes accordingly ''' try: self.processes = multiprocessing.cpu_count() except NotImplementedError: self._logger.log( ...
[ "def", "infer_process_count", "(", "self", ")", ":", "try", ":", "self", ".", "processes", "=", "multiprocessing", ".", "cpu_count", "(", ")", "except", "NotImplementedError", ":", "self", ".", "_logger", ".", "log", "(", "'error'", ",", "'Could infer CPU coun...
Infers the number of CPU cores in the current system, sets the number of concurrent processes accordingly
[ "Infers", "the", "number", "of", "CPU", "cores", "in", "the", "current", "system", "sets", "the", "number", "of", "concurrent", "processes", "accordingly" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L286-L298
ECRL/ecabc
ecabc/abc.py
ABC.create_employers
def create_employers(self): '''Generate employer bees. This should be called directly after the ABC is initialized. ''' self.__verify_ready(True) employers = [] for i in range(self._num_employers): employer = EmployerBee(self.__gen_random_values()) ...
python
def create_employers(self): '''Generate employer bees. This should be called directly after the ABC is initialized. ''' self.__verify_ready(True) employers = [] for i in range(self._num_employers): employer = EmployerBee(self.__gen_random_values()) ...
[ "def", "create_employers", "(", "self", ")", ":", "self", ".", "__verify_ready", "(", "True", ")", "employers", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "_num_employers", ")", ":", "employer", "=", "EmployerBee", "(", "self", ".", "_...
Generate employer bees. This should be called directly after the ABC is initialized.
[ "Generate", "employer", "bees", ".", "This", "should", "be", "called", "directly", "after", "the", "ABC", "is", "initialized", "." ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L300-L344
ECRL/ecabc
ecabc/abc.py
ABC.run_iteration
def run_iteration(self): '''Runs a single iteration of the ABC; employer phase -> probability calculation -> onlooker phase -> check positions ''' self._employer_phase() self._calc_probability() self._onlooker_phase() self._check_positions()
python
def run_iteration(self): '''Runs a single iteration of the ABC; employer phase -> probability calculation -> onlooker phase -> check positions ''' self._employer_phase() self._calc_probability() self._onlooker_phase() self._check_positions()
[ "def", "run_iteration", "(", "self", ")", ":", "self", ".", "_employer_phase", "(", ")", "self", ".", "_calc_probability", "(", ")", "self", ".", "_onlooker_phase", "(", ")", "self", ".", "_check_positions", "(", ")" ]
Runs a single iteration of the ABC; employer phase -> probability calculation -> onlooker phase -> check positions
[ "Runs", "a", "single", "iteration", "of", "the", "ABC", ";", "employer", "phase", "-", ">", "probability", "calculation", "-", ">", "onlooker", "phase", "-", ">", "check", "positions" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L346-L354
ECRL/ecabc
ecabc/abc.py
ABC._employer_phase
def _employer_phase(self): '''Iterates through the employer bees and merges each with another random bee (one value is moved in accordance with the second bee's value); if the mutation performs better, the bee is moved to the new position ''' self._logger.log('debug', 'E...
python
def _employer_phase(self): '''Iterates through the employer bees and merges each with another random bee (one value is moved in accordance with the second bee's value); if the mutation performs better, the bee is moved to the new position ''' self._logger.log('debug', 'E...
[ "def", "_employer_phase", "(", "self", ")", ":", "self", ".", "_logger", ".", "log", "(", "'debug'", ",", "'Employer bee phase'", ")", "modified", "=", "[", "]", "for", "bee", "in", "self", ".", "_employers", ":", "if", "self", ".", "_processes", "<=", ...
Iterates through the employer bees and merges each with another random bee (one value is moved in accordance with the second bee's value); if the mutation performs better, the bee is moved to the new position
[ "Iterates", "through", "the", "employer", "bees", "and", "merges", "each", "with", "another", "random", "bee", "(", "one", "value", "is", "moved", "in", "accordance", "with", "the", "second", "bee", "s", "value", ")", ";", "if", "the", "mutation", "perform...
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L356-L375
ECRL/ecabc
ecabc/abc.py
ABC._calc_probability
def _calc_probability(self): '''Determines the probability that each bee will be chosen during the onlooker phase; also determines if a new best-performing bee is found ''' self._logger.log('debug', 'Calculating bee probabilities') self.__verify_ready() self._total_score...
python
def _calc_probability(self): '''Determines the probability that each bee will be chosen during the onlooker phase; also determines if a new best-performing bee is found ''' self._logger.log('debug', 'Calculating bee probabilities') self.__verify_ready() self._total_score...
[ "def", "_calc_probability", "(", "self", ")", ":", "self", ".", "_logger", ".", "log", "(", "'debug'", ",", "'Calculating bee probabilities'", ")", "self", ".", "__verify_ready", "(", ")", "self", ".", "_total_score", "=", "0", "for", "employer", "in", "self...
Determines the probability that each bee will be chosen during the onlooker phase; also determines if a new best-performing bee is found
[ "Determines", "the", "probability", "that", "each", "bee", "will", "be", "chosen", "during", "the", "onlooker", "phase", ";", "also", "determines", "if", "a", "new", "best", "-", "performing", "bee", "is", "found" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L377-L398
ECRL/ecabc
ecabc/abc.py
ABC._onlooker_phase
def _onlooker_phase(self): '''Well-performing bees (chosen probabilistically based on fitness score) have a value merged with a second random bee ''' self.__verify_ready() self._logger.log('debug', 'Onlooker bee phase') modified = [] for _ in self._employers: ...
python
def _onlooker_phase(self): '''Well-performing bees (chosen probabilistically based on fitness score) have a value merged with a second random bee ''' self.__verify_ready() self._logger.log('debug', 'Onlooker bee phase') modified = [] for _ in self._employers: ...
[ "def", "_onlooker_phase", "(", "self", ")", ":", "self", ".", "__verify_ready", "(", ")", "self", ".", "_logger", ".", "log", "(", "'debug'", ",", "'Onlooker bee phase'", ")", "modified", "=", "[", "]", "for", "_", "in", "self", ".", "_employers", ":", ...
Well-performing bees (chosen probabilistically based on fitness score) have a value merged with a second random bee
[ "Well", "-", "performing", "bees", "(", "chosen", "probabilistically", "based", "on", "fitness", "score", ")", "have", "a", "value", "merged", "with", "a", "second", "random", "bee" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L400-L428
ECRL/ecabc
ecabc/abc.py
ABC._check_positions
def _check_positions(self): '''Checks each bee to see if it abandons its current food source (has not found a better one in self._limit iterations); if abandoning, it becomes a scout and generates a new, random food source ''' self.__verify_ready() max_trials = 0 ...
python
def _check_positions(self): '''Checks each bee to see if it abandons its current food source (has not found a better one in self._limit iterations); if abandoning, it becomes a scout and generates a new, random food source ''' self.__verify_ready() max_trials = 0 ...
[ "def", "_check_positions", "(", "self", ")", ":", "self", ".", "__verify_ready", "(", ")", "max_trials", "=", "0", "scout", "=", "None", "for", "bee", "in", "self", ".", "_employers", ":", "if", "(", "bee", ".", "failed_trials", ">=", "max_trials", ")", ...
Checks each bee to see if it abandons its current food source (has not found a better one in self._limit iterations); if abandoning, it becomes a scout and generates a new, random food source
[ "Checks", "each", "bee", "to", "see", "if", "it", "abandons", "its", "current", "food", "source", "(", "has", "not", "found", "a", "better", "one", "in", "self", ".", "_limit", "iterations", ")", ";", "if", "abandoning", "it", "becomes", "a", "scout", ...
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L430-L450
ECRL/ecabc
ecabc/abc.py
ABC._merge_bee
def _merge_bee(self, bee): '''Shifts a random value for a supplied bee with in accordance with another random bee's value Args: bee (EmployerBee): supplied bee to merge Returns: tuple: (score of new position, values of new position, fitness funct...
python
def _merge_bee(self, bee): '''Shifts a random value for a supplied bee with in accordance with another random bee's value Args: bee (EmployerBee): supplied bee to merge Returns: tuple: (score of new position, values of new position, fitness funct...
[ "def", "_merge_bee", "(", "self", ",", "bee", ")", ":", "random_dimension", "=", "randint", "(", "0", ",", "len", "(", "self", ".", "_value_ranges", ")", "-", "1", ")", "second_bee", "=", "randint", "(", "0", ",", "self", ".", "_num_employers", "-", ...
Shifts a random value for a supplied bee with in accordance with another random bee's value Args: bee (EmployerBee): supplied bee to merge Returns: tuple: (score of new position, values of new position, fitness function return value of new position)
[ "Shifts", "a", "random", "value", "for", "a", "supplied", "bee", "with", "in", "accordance", "with", "another", "random", "bee", "s", "value" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L452-L478
ECRL/ecabc
ecabc/abc.py
ABC._move_bee
def _move_bee(self, bee, new_values): '''Moves a bee to a new position if new fitness score is better than the bee's current fitness score Args: bee (EmployerBee): bee to move new_values (tuple): (new score, new values, new fitness function return value) ...
python
def _move_bee(self, bee, new_values): '''Moves a bee to a new position if new fitness score is better than the bee's current fitness score Args: bee (EmployerBee): bee to move new_values (tuple): (new score, new values, new fitness function return value) ...
[ "def", "_move_bee", "(", "self", ",", "bee", ",", "new_values", ")", ":", "score", "=", "np", ".", "nan_to_num", "(", "new_values", "[", "0", "]", ")", "if", "bee", ".", "score", ">", "score", ":", "bee", ".", "failed_trials", "+=", "1", "else", ":...
Moves a bee to a new position if new fitness score is better than the bee's current fitness score Args: bee (EmployerBee): bee to move new_values (tuple): (new score, new values, new fitness function return value)
[ "Moves", "a", "bee", "to", "a", "new", "position", "if", "new", "fitness", "score", "is", "better", "than", "the", "bee", "s", "current", "fitness", "score" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L480-L498
ECRL/ecabc
ecabc/abc.py
ABC.__update
def __update(self, score, values, error): '''Update the best score and values if the given score is better than the current best score Args: score (float): new score to evaluate values (list): new value ranges to evaluate error (float): new fitness function r...
python
def __update(self, score, values, error): '''Update the best score and values if the given score is better than the current best score Args: score (float): new score to evaluate values (list): new value ranges to evaluate error (float): new fitness function r...
[ "def", "__update", "(", "self", ",", "score", ",", "values", ",", "error", ")", ":", "if", "self", ".", "_minimize", ":", "if", "self", ".", "_best_score", "is", "None", "or", "score", ">", "self", ".", "_best_score", ":", "self", ".", "_best_score", ...
Update the best score and values if the given score is better than the current best score Args: score (float): new score to evaluate values (list): new value ranges to evaluate error (float): new fitness function return value to evaluate Returns: ...
[ "Update", "the", "best", "score", "and", "values", "if", "the", "given", "score", "is", "better", "than", "the", "current", "best", "score" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L500-L537
ECRL/ecabc
ecabc/abc.py
ABC.__gen_random_values
def __gen_random_values(self): '''Generate random values based on supplied value ranges Returns: list: random values, one per tunable variable ''' values = [] if self._value_ranges is None: self._logger.log( 'crit', 'Must ...
python
def __gen_random_values(self): '''Generate random values based on supplied value ranges Returns: list: random values, one per tunable variable ''' values = [] if self._value_ranges is None: self._logger.log( 'crit', 'Must ...
[ "def", "__gen_random_values", "(", "self", ")", ":", "values", "=", "[", "]", "if", "self", ".", "_value_ranges", "is", "None", ":", "self", ".", "_logger", ".", "log", "(", "'crit'", ",", "'Must set the type/range of possible values'", ")", "raise", "RuntimeE...
Generate random values based on supplied value ranges Returns: list: random values, one per tunable variable
[ "Generate", "random", "values", "based", "on", "supplied", "value", "ranges" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L539-L567
ECRL/ecabc
ecabc/abc.py
ABC.__verify_ready
def __verify_ready(self, creating=False): '''Some cleanup, ensures that everything is set up properly to avoid random errors during execution Args: creating (bool): True if currently creating employer bees, False for checking all other operations ''' ...
python
def __verify_ready(self, creating=False): '''Some cleanup, ensures that everything is set up properly to avoid random errors during execution Args: creating (bool): True if currently creating employer bees, False for checking all other operations ''' ...
[ "def", "__verify_ready", "(", "self", ",", "creating", "=", "False", ")", ":", "if", "len", "(", "self", ".", "_value_ranges", ")", "==", "0", ":", "self", ".", "_logger", ".", "log", "(", "'crit'", ",", "'Attribute value_ranges must have at least one value'",...
Some cleanup, ensures that everything is set up properly to avoid random errors during execution Args: creating (bool): True if currently creating employer bees, False for checking all other operations
[ "Some", "cleanup", "ensures", "that", "everything", "is", "set", "up", "properly", "to", "avoid", "random", "errors", "during", "execution" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L569-L588
ECRL/ecabc
ecabc/abc.py
ABC.import_settings
def import_settings(self, filename): '''Import settings from a JSON file Args: filename (string): name of the file to import from ''' if not os.path.isfile(filename): self._logger.log( 'error', 'File: {} not found, continuing with...
python
def import_settings(self, filename): '''Import settings from a JSON file Args: filename (string): name of the file to import from ''' if not os.path.isfile(filename): self._logger.log( 'error', 'File: {} not found, continuing with...
[ "def", "import_settings", "(", "self", ",", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "self", ".", "_logger", ".", "log", "(", "'error'", ",", "'File: {} not found, continuing with default settings'", ".", ...
Import settings from a JSON file Args: filename (string): name of the file to import from
[ "Import", "settings", "from", "a", "JSON", "file" ]
train
https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L590-L618